0 Replies Latest reply on May 26, 2009 12:36 AM by robinthapa

    Using J2EE Server+JAVA + FLEX BUILDER 3

    robinthapa

      Dear All,
      i got some nasty errors when i followed the instructions from:

      http://www.brucephillips.name/blog/index.cfm/2008/6/22/Using-Flex-BlazeDS-and-Java-Togethe r--A-Simple-Tutorial


      I downloaded the blazeDs.war from the site as recommended.
      I am using flex builder 3.
      I did the following to create a project:
          File->New->FlexProject..

               Project name: HelloFlexFromJava
                Project location is the default:C:\Documents and Settings\Administrator\My Documents\Flex Builder 3
               Application Type: Web Application(runs in Flash Player)
                Application server type:J2EE
               selected the Useremote object access service & Live Cycle Data Services
                Selected Create combined Java/Flex project using WTP.....
        Next Button is clicked and leads me to:
          J2EE Settings:
                Target runtime: Apache Tomcat v6.0

                Context root:HelloFlexFromJava
                Content Folder:WebContent
               Flex War file:C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.18\webapps\blazeds.war
           Other options are as default
      Then i click Finish.


      The Directory structure in Flex Navigator is as:
      ---------HelloFlexFromJava
                  +bin-debug
                  flex_libs
                  -flex_src
                     +HelloFlexFromJava.mxml
                  +html-templates
                  -src
                     -example
                         HelloWorld.java
                   -WebContent
                   +META-INF
                   -WEB-INF
                     -classes
                          -example
                                 HelloWorld.class
                      -flex
                           messageing-config.xml
                           proxy-config.xml
                           remoting-config.xml
                           services-config.xml
                      +libs
                      src
                     web.xml

       

      The above is the flex navigator structure.

       

      My Java File:

           package examples;

       

      public class HelloWorld {
          public HelloWorld(){}
          public String getHelloWorld(){
              return "This is me from Java Class";
          }
      }

       

      My HelloFlexFromJava.mxml:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
          <mx:Script>
              <![CDATA[
                  import mx.rpc.events.ResultEvent;
                  import mx.rpc.events.FaultEvent;
                  import mx.utils.ObjectUtil;
                  import mx.utils.StringUtil;
                  import mx.controls.Alert;
                  private function resultHandler(event:ResultEvent):void{
                      Alert.show( ObjectUtil.toString(event.result));
                  }
                  private function faultHandler(event:FaultEvent):void{
                      Alert.show(ObjectUtil.toString(event.fault));
                  }
              ]]>
          </mx:Script>
          <mx:RemoteObject id="ro" destination="helloworld" source="examples.HelloWorld"
              result="resultHandler(event)" fault="faultHandler(event)"/>
                   <mx:Panel x="10" y="10" width="440" height="200" layout="vertical"
                        title="Test Flex 3 Using Java" borderColor="#008040" fontFamily="Arial" fontWeight="bold" fontSize="13">
                         <mx:Text text="Getting Data Into Flex From A Java Class"     fontWeight="bold" width="301"/>
                             <mx:Spacer height="20"/>

                              <mx:Button label="Get Hello World!" click="ro.getHelloWorld()"/>
                </mx:Panel>
      </mx:Application>

       

       

       

       

      Please help me,i come from the back-ground of using wicket and i want to try my fingers in Flex