Home > Uncategorized > Flash Builder 4 makes a new marriage proposal between Flex and Java!

Flash Builder 4 makes a new marriage proposal between Flex and Java!

Data Centric Rapid Application Development one of the star-strickers in the Flash Builder 09 BETA league ensures seemless connectivity between Flex client and Java back-end. Said so, it promises literally “ZERO” Flex code to build a Rich Internet Application.It also provides kick-ass support for client-side Data Management and Paging.

Let us build a sample Inventory application which displays all the mobile phones available in a mall.

Pre-requisites:

a) Downloadand install Flash Builder 4 BETA from http://labs.adobe.com/technologies/flashbuilder4/

b) Download the latest BlazeDS release build from http://opensource.adobe.com/wiki/display/blazeds/Downloads

FYI,  BlazeDS is the server-based Java remoting and web messaging technology that enables developers to easily connect to back-end distributed data and push data in real-time to Adobe® Flex™ and Adobe AIR™ applications for more responsive rich Internet application (RIA) experiences. In short, a bunch of libraries to connect ColdFusion or Java back-ends to Flex.

c)Basic knowledge in Java Programming.

d)ZERO knowledge in Flex Programming 😦

BlazeDS  Set-Up:

BlazeDS comes bundled with Tomcat, but one may also deploy it on other servers like Apache,JBOSS etc.In this post i would assume the BlazeDS sits on in-built tomcat.

a) Go to tomcat\webapps\blazeds\WEB-INF and uncomment the servlet definition and mapping for “RDSDispatchServlet” and set the <param-value> as ‘false’.

b) Kindly set up your data base  as mentioned here

c)Add the following class files from Files

and place it under tomcat\webapps\blazeds\WEB-INF\classes\com\random.

d)Open remote-config.xml from tomcat\webapps\blazeds\WEB-INF\flex and add the following mapping:

<destination id=”CreatingRpc1″>
<properties>
<source>com.random.Inventory</source>
</properties>
<adapter ref=”java-object”/>
</destination>

<destination id=”MyService”>

<properties> <source>com.random.Inventory</source> </properties>

<adapter ref=”java-object”/>

</destination>

e) Add the mysql jdbc jar file “mysql-connector-java-5.1.7-bin” to tomcat\webapps\blazeds\WEB-INF\lib.

Your BlazeDS set-up is now complete, GOTO tomcat\bin and start the server.

Here are the step-by-step instructions to achieve the workflow:

a) Launch Flash Builder and create a Flex-BlazeDS project as shown in the image below:

Project Creation

Project Creation

Server Configuration

Server Configuration

Click NEXT from “Project Creation” wizard and set the

server configuration based on the BlazeDS  installation directory,click “Validate Configuration” and FINISH.

b) Goto Data->Connect to BlazeDS..

c) An authentication dialog will pop-up, select “No password” check-box and click OK

d)In the Import BlazeDS/LCDS service wizard, enter the service name as “MyDestination”, select the destination and FINISH.

MyDestination

e) Click on J2EEProject.mxml and switch to the design view.

f) Go to Components->Data Controls, select Data Grid and drag-drop onto the design view

Final

g) Now drag-drop getAllItems functions onto the Data Grid. The preview is shown above.

h)Context click on project and select ‘Run Application’ . All the values in the data base gets populated in the data grid launched in the browser.

Similarly all the CRUD operations can be performed including client-side Data Management and Paging without any Flex code.

Wanna know what’s the magic ?? Hoping to get back soon with the MAYA “behind the scenes” 🙂

Now how many of us agree that Java Developers can tie KNOT with Flex for their RIA development ???

Advertisements
Categories: Uncategorized
  1. June 19, 2009 at 4:47 am

    Thank you for this. It’s really imformative stuff.
    I enjoy to read balajisridhar.wordpress.com.

    sarasota teeth whitening

  2. Frank
    July 16, 2009 at 6:56 pm

    Hello.. Trying to follow your ‘cookbook’ and set up flash builder with blazeds. It seems that the links to Inventory and InventoryVO are broken. Where are these sample programs located?

    • balajisridhar
      July 20, 2009 at 12:52 pm

      Hi…sorry for the inconvinience…
      Now have updated the link.

      Please follow the cookbook and provide your feedback 🙂

      Thanks,
      Balaji

  3. Suresh
    August 8, 2009 at 1:56 pm

    🙂 very useful and good post

  4. Suresh
    August 8, 2009 at 4:10 pm

    Hi its successful can u please tell me how to write the class file for a new database, please share it.

  5. Suresh
    August 8, 2009 at 4:11 pm

    Also adding this shows its not in proper format please attach this file too for beginners like me

    • Balaji Sridhar
      August 8, 2009 at 5:50 pm

      Suresh,

      Thanks for your feedback!

      What file are you expecting? Is it the database schema(dump) or the java file which calls the database?

  6. suresh
    August 8, 2009 at 6:55 pm

    Thanks for the fast response balaji.

    From morning your blog is online in my 🙂 browser.

    Thanks for nice walk through once again.

    You have attached dump file for database and i have used it.

    But if i have created my own database how to write class files for the same.

    For eg. blog.sql has the Database dump and you have Inventory.class and InventoryVO.class

    Now i have my own sql suresh.sql i need to write two .class files for the same how to write it. I am very much new to java

    One more thing is how shall i edit .class file … which editor can be used in windows to edit it..

    • Balaji Sridhar
      August 8, 2009 at 7:04 pm

      Now I get that Suresh!

      Firstly JAVA files get converted to the .class files(the one i have attached).
      I shall mail you the JAVA files which i have used, try editing those to meet your requirements.
      You may just need to change your DB credentials, table/database names.

      Next you need to compile those JAVA files and then place it under classes folder under the blazeds/classes.

      Please revert back if you face any issues 🙂

  7. suresh
    August 8, 2009 at 7:07 pm

    Wow Balaji the Lighting Fast 🙂 Friend

    Thanks dude for the clear explaination to a novice like me. suresh.sci@gmail.com is my mail id, yes i was looking for the source files so that i can edit the db names but you know i was looking to open class he he 🙂

    What to do i am new bee to java. Thanks a lot for the support from friends like you

    Expecting the attachment of files to my mail suresh.sci@gmail.com Balaji

    Thanks a lot once again.

    Have a Happy Weekend Suresh

    • Balaji Sridhar
      August 8, 2009 at 7:22 pm

      Suresh,

      I have sent them over mail.
      Please let me know if you encounter further issues.

      Thanks,
      Balaji

  8. Brian
    September 2, 2009 at 12:43 am

    Can I get a copy of those Java files as well? I’m attempting to learn how to get this all going.

    Thanks,

    Brian

    • Balaji Sridhar
      September 2, 2009 at 6:02 am

      Hello Brian,

      I have mailed across the files to you 🙂

  9. agung
    November 21, 2009 at 4:24 am

    Hello mr balaji, i’m follow your tutorial, but i have problem at setting blazeds.

    1. this page : my web.xml
    BlazeDS
    BlazeDS Application

    flex.messaging.HttpFlexSession

    MessageBrokerServlet
    MessageBrokerServlet
    flex.messaging.MessageBrokerServlet

    services.configuration.file
    /WEB-INF/flex/services-config.xml

    1

    MessageBrokerServlet
    /messagebroker/*

    index.html
    index.htm

    RDSDispatchServlet
    RDSDispatchServlet
    flex.rds.server.servlet.FrontEndServlet

    useAppserverSecurity
    false

    10

    RDSDispatchServlet
    /CFIDE/main/ide.cfm

    and i have error like this, can you help me..?

    RDS server message:
    Error executing RDS command. Status Code : 404, Reason:
    /blazeds/CFIDE/main/ide.cfm

    • Balaji Sridhar
      November 21, 2009 at 7:57 am

      Hi,

      Your web.xml should look like this:

      RDSDispatchServlet
      RDSDispatchServlet
      flex.rds.server.servlet.FrontEndServlet

      useAppserverSecurity
      false

      10

      RDSDispatchServlet
      /CFIDE/main/ide.cfm

      Also, which version of Flash Builder and BlazeDS are you using?

  10. shyju
    December 19, 2009 at 7:52 am

    hi,

    Same problem with agung. ie;
    —————–
    rds server message
    error in executing rds command status code 404
    ————

    my blazeds version is blazeds-turnkey-3.2.0.3978.( i have tried with different versions , but same result.)
    flashbuilder is version 4.0 build(253292)

    Any suggestion?

    Thank you

    • Balaji Sridhar
      December 19, 2009 at 7:56 am

      Hi,

      Will you be able to try out with the latest build of Blazeds 4? The FlashBuilder you are using looks fine.

      Can you let us know your findings?

      Also please drop a mail to balajisridhar07@gmail.com if you still see issues

      Thanks,
      Balaji

  11. shyju
    December 19, 2009 at 2:51 pm

    i shall try and update you.
    thanks

  12. shyju
    December 19, 2009 at 7:07 pm

    It worked. I had to download blazeds 4. and uncomment the RDS servlet part, and set security =false

    Thanks.

    • veja
      November 24, 2010 at 1:31 pm

      Can you please explain, where did you had to un-comment the RDS Servlet part, and set security=true

      • Balaji Sridhar
        November 24, 2010 at 5:16 pm

        in the web.xml under tomcat\webapps\blazeds within your blazeds installation.

        uncomment the RDSDispatchServlet section

  13. Ronak Patel
    February 3, 2010 at 4:19 am

    Hi Balaji,

    I have a similar 404 going on. My backend is Blazeds 3.2 that is using BlazeDS-Spring integration. As such my web.xml is:

    flex.messaging.HttpFlexSession

    org.springframework.web.context.ContextLoaderListener

    contextConfigLocation

    classpath:META-INF/client-orm.xml
    classpath:META-INF/client-jms.xml

    client
    org.springframework.web.servlet.DispatcherServlet

    contextConfigLocation

    classpath:META-INF/client-servlet.xml

    1

    client
    /messagebroker/*

    Will this work through the wizard?

  14. d1wise
    February 17, 2010 at 3:33 pm

    RE:Ronak Patel,
    You need download blazeds-bin-4.0.0.13512.zip and place new ‘blazeds.war’ in your ..\tomcat\webapps folder and restart tomcat

  15. Seb
    June 30, 2010 at 7:59 pm

    Great tutorial and easy to use. I have followed this tutorial since I am trying to connect to a database. While creating the project I was trying to get BlazeDS setup properly. When I added the class to the Blaze folder in Tomcat and tried selecting it from the Data connection wizard, I got the following error:

    “Project.Services.AppService contains overloaded method and is not supported for Introspection. Try importing by unselecting the destination AppService”

    I tried searching online for a solution, but the only solution someone had was to decompile the java code and compile it function by function until the error goes away. Surely there has to be another way and if there is you would probably know of a way. Any information would be of great help. Thank you in advance.

  16. Prashant
    February 7, 2011 at 6:32 am

    Need some help. Tried connecting to data in flex. Tryin it out with the testdrive example in the Adobe site. Using Java as the backend technology. Deployed the war file but unable to connect to the Blazeds (data services). Encountering the 502 bad gateway error (RDS). Using tomcat 6+ with blazeds(war) in the web app folder.. Deployed the testdrive.war in eclipse which came with derby and blazeds already wit it..(it also has rds-server.jar in the lib folder)..

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: