Aug 31, 2009

Saving changes not permitted MSSQL 2008

We recently upgraded a few SQL server boxes to MS SQL Server 2008. I also installed the new Enterprise Admin tools and after working on a new project I hit a slight brick wall.

"Saving changes not permitted" 

This kept coming up when I tried to change column attributes and re-arrange column orders for a table that existed.



It was odd I could make schema changes like this with SQL 2005 why not 2008?

Turns out its a simple setting that's on by default in the SQL 2008 Enterprise manager ( Express and Full ) and João Fernandes gave me the solution over twitter only a few mintues after I asked.

Here are the exact steps:

Click "Tools" , Select "Options", Expand "Designers", select "Table and Database Designers" then deselect "Prevent saving changes that require table re-creation"


 
  
 

Aug 30, 2009

Multi Line Buttons in FlexBuilder / FlashBuilder

Recently I have been working on a project where I have to dynamically make a bunch of forms based on Questions and Answers from a SQL database.  This was going along nicely till I requested some real data that was to be used and the answers were much more verbose then I had anticipated causing the radio buttons to not display the text for the answer. What I needed was a multiline radion button.

There is no way to make a multi line button in flex out of the box which is a bit of a shame.

I started extending the button class to make it work how I needed while chatting with Rob Parkhill I got a few minutes into coding my own solution when Rob pointed me to this http://blogs.adobe.com/aharui/2007/04/multiline_buttons.html post by Alex Harui which did exactly what I needed.

The demo shows both the new Multiline Radio button and the same code creating the standard radio button.



Here is the structure for the demo:


The code:

Aug 23, 2009

Java and ColdFusion its not that difficult.

Java and ColdFusion ( well CFML including OpenBD and Railo ) work really well together as you would expect. However there is not a lot of information out there about exactly how to create (or use) existing Java within ColdFusion, which is whyy I decide to make a simple example and a step by step post of how to create java code and execute it from ColdFusion.

All the files use are available for download at the bottom of the post.

You don't need alot of tools. Initially I created the whole demo with notepad++ and compiled the .java files from the CLI but its easier to manager if you use eclipse. The only real component you need is a jdk you can confirm you have this installed by running the following:
javac -version

notice its javac not java as we need to be able to compile .java code. I completed the example on Windows but it will be the same on any operating system.

javaVersion

If you do not have a JDK installed you can download it here Sun JDK

Launch Eclipse, create a project and right click src and select “new” and then “package”. Create com.transport

This is the package structure for this example. In transport you then make 3 new class's Vehicle.java, Car.java and Bicycle.java

eclipse

Vehicle.java:

javaVehicle

Car.java:

javaCar

Bicycle.java:

javaBicycle

I also made a Demo.java to test the code:

javaDemo

You can run the Demo.java from withing eclipse to see if you made any errors, the result will be displayed in the console:

javaConsoleOutput

You can now export the code as a jar.

To extract to a jar to use with ColdFusion, Railo or OpenBD:

Select the .java files you want ( Vehicle, Car, Bicycle ) right click and select “Export” , expand “Java” and select “Jar file” you can export this to any location and jar name. As I have ColdFusion running locally I exported directly to c:\ColdFusion8\lib as paul.jar

( on railo this location is: /var/www/virtual/sitename.com/WEB-INF/railo/lib/ basically the /WEB-INF/railo/lib/ under your webcontext you want access to the jar )

You need to restart ColdFusion to pick up the file.

One CF restarts it should have access to the java class’s we just made:

Create a new .cfm page and we can now create java objects of the classes we just made directly from ColdFusion:

cftojavamethods

The output:

cftojavamethodsresults

I wrote the same code as a cfc to show the comparison:
( I used CF8 so I write the components in tags )

Vehicle.cfc:

cfVehicle


Car.cfc:


cfCar

I then made a page to create a few of each object type ( cf and java ) and show how the code is almost identical.

javacfspeed

I then increased the loops to 10k to see the results:

cfVJavaObjects

Yes java objects are much faster then ColdFusion.

The point of the post is to show how easy it is to jump between java and CF and if you have algorithms, class's or any code that's already built in java you can easily leverage this in ColdFusion.

Also note that I compiled the code on Windows 7 64 bit and tested on ColdFusion 8 I then dropped the jar onto my linux VPS running Railo without a single change in code or recompiling the java code.

Here is the speed test running on ColdFusion9 under Ubuntu: http://demo.kukiel.net/java

Here are the files: DemoFiles.Zip

Aug 18, 2009

Free SVN hosting with SSL

I have said it before and I'll say it again. If you're not using some type of source control you should be.

SVN makes life easy. I'm the type of person that likes to run the latest Betas (Win7 for one) and that often means I reformat and reinstall my Operating System regularly. I also jump between Linux, Windows and OSX.

One of the hardest things to move between machines is my development environment and making sure I have my code and don't lose anything. We use SVN at work and I use SVN for all my personal projects its just easy to check out my code and continue working.

I have recently moved my projects to Project Locker as they have free accounts with up to 500mb storage, SSL plus more.

If you're not using SVN then you should really check this out and start.

Railo is now stable 3.1.1 released


I have been away from blogging for the last few weeks. I had an excellent time at CFUnited which I may still talk about but this short post is to spread the word that Railo Open Source is now golden. It is no longer in Beta ( not that that was stopping me for a few personal projects ).

How do you upgrade? Simple in the Server admin click "Upgrade" wait 5-10 seconds and your done.

There are several fixes but the most noticeable is the new Admin look and feel and the addition of cfc caching inline with ColdFusion 9 which increases objects creation time dramatically.

This is really great news for any CFML developer and if you havent at least takena look at Railo I recommend you do.

http://www.getrailo.org/railoorg/index.cfm/download/

Aug 4, 2009

Install mySQL on Debian & Ubuntu and connecting to ColdFusion

Well since I got a mention on CFHour about my CF9/8 Debian install Michael mentions mySQL as part of the install and I figured I would add this to my screen capture. Debian and Ubuntu make this so easy.

Here is the original tutorial.

From that point you can follow on here:

apt-get install mysql-server mysql-client
vi /etc/mysql/my.cnf ( I use vi you can use any editor )

on line 47

comment out this line:
bind-address = 127.0.0.1

so it looks like this:
#bind-address = 127.0.0.1

This will allow remote connections from your host machine if you use a GUI tool to admin mySQL.

Restart the mySQL service:
/etc/init.d/mysql restart

Login to mysql from the cli:
mysql -u root -p
this will ask for your password can can optionally pass it as a parameter like so: mysql -u root -p password

Execute these 2 commands:
grant all privileges on *.* to root@"%" identified by "password";
flush privileges;

the % means root can log in from any IP address.

Now you should be able to connect to mysql from a separate machine.



On Windows I have been using Toad here is a quick walk through of connecting Toad to mySQL in the VM and then adding the new database as a datasource in CF9.

Aug 2, 2009

Sending Value Objects from Railo & ColdFusion to Flex

Can you send VO's for Flex to Railo via remoting? Yes Railo 3.1.0.16 introduced working flashremoting between Flex and Railo cfc's I already have a post on sending simple datatypes between Railo and Flex so I wanted to make a slightly more complex example of sending Value Object from Flex to Railo and back.

I also demonstrate that you can place data into session via remoting. In the 2nd iframe you can see a dump of session and see the data passed back to flex and sent from flex.

Click "Send" or/and "Get" then reload the dump of session.

You can view the source here or right click and select view source on the Flex Example.





PeopleDemo.mxml


Person.as


Person.cfc


service.cfc

The code will work on both Railo and ColdFusion