Preface
The purpose of this article is to create a new integrated application of Flex and Java EE, starting with the first page of enterprise application development for Java and Flex, for a novice who is completely ignorant.
development environment and tools
Windows 7
JAVA SDK 1.6.0_17
Flash Builder 4.5
SpringSource Tool Suite IDE
BlazeDS
The SpringSource Tool Suite IDE is chosen because the commonly used plug-ins have been integrated with us, and there is no need to say about spring's operational support.
Step by Step Create the demo
1. First use the SpringSource Tool Suite to create our dynamic WEB Project project named Blazejavademo. Change the default output folder to "Blazejavademo/webcontent/web-inf/classes" after the creation is complete
2. Unzip our downloaded BlazeDS turnkey package in the root directory we will see a series of directories and files containing Doc,resource samples, and so on, here do not do detailed introduction. I just need blazeds.war.
3. Put Blazeds.war into our Tomcat WebApps directory and start tomcat familiar with Java know that this is a release package. OK to navigate to our Blazeds\web-inf folder,
You will see the following:
4. Copy all this content to our Java Project \web-inf and overwrite all of its original files.
BlazeDS is a middleware of Java and Flex Communications, using Adobe's own AMF Binary transport protocol, is open source for different development languages have its implementation, the advantage is that the high transmission rate and efficiency, which is why enterprise applications are often used for reasons. With him we can easily access the Java object directly in Flex, his function is very powerful more information please check the Adobe website. Here we simply write a Java class and expose it to flex through BlazeDS to complete our first simple demo.
5. A very simple Java class his role is to accept the flex-side parameters and response information to the flex side.
[Java] View plain copy/** * */ package com.swq.services; & nbsp; /** * @author Administrator * */ public class demoservice { /** * */ public demoservice () { // TODO Auto-generated constructor stub } /** * receive parameter name and response information to flex side * @param name * @return */ public string sayhello (String naMe) { return "hello " +name; } }
6. Then we need to make the following configuration to Remoting-config.xml to tell the flex end "Hey here I am", if multiple classes, in order to define multiple destination can be. Here we have completed the Java side writing and configuration, is not very simple, if you are a completely ignorant novice through this article to complete the flex and Java through Blaze communication, this article is a success.
[HTML] view plain copy <destination id= "Demoservice" > <properties> <source>co M.swq.services.demoservice</source> </properties> </destination>
7. Complete the Java end, next we look at how to use flash Builder4.5 to establish and BlazeDS communication project
(1) Establishment of a project named Blazeflexdemo
(2) After completing the correct path to verify the configuration, the next step is to complete the creation of the Flex project.
URL error path error or invalid may be reported here, only need to run: HTTP://LOCALHOST:8080/BLAZEJAVADEMO/MESSAGEBROKER/AMF
The reason may be the need to build the path: **webapps\flexdemo\javaflex-debug
8. Complete the creation of the Flex project next we look at the code, very simple code. Here to explain: the declaration of the RemoteObject component of the destination attribute must correspond to the destination in Remoting-config.xml, Flex is based on this, and then we can through its ID attribute directly access to our Java side of the side Law. The endpoint attribute specifies our terminal location, and when our Java side is released, we can test the HTTP://LOCALHOST:8080/BLAZEJAVADEMO/MESSAGEBROKER/AMF if it is correct to say that our project is OK.
[HTML] view plain copy <?xml version= "1.0 encoding=" Utf-8 "?> <s:application xmlns:fx=" Http://ns.ado be.com/mxml/2009 "&n