Help

Controls

Switch Workspace

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Comparing current revision with historical revision 4.
Document History: Flex
Current revision:
10
Parent:
Alternative View Layers
Created On:
10. Jan 2008, 14:56 (pete)
Last Modified On:
15. Jun 2009, 09:30 (mschuetz)
Historical revisions:
9 15. Jun 2009, 09:09 (mschuetz) ShowDiff
8 15. Jun 2009, 09:07 (mschuetz) ShowDiff
7 15. Jun 2009, 08:56 (mschuetz) ShowDiff
6 12. Jun 2009, 15:38 (mschuetz) ShowDiff
5 12. Jun 2009, 15:37 (mschuetz) ShowDiff
4 12. Jun 2009, 15:04 (mschuetz) ShowDiff
3 28. Feb 2009, 05:31 (mschuetz) ShowDiff
2 28. Feb 2009, 05:28 (dan) ShowDiff
1 28. Feb 2009, 05:28 (dan) ShowDiff
0 01. Mar 2008, 13:23 (dan) ShowDiff

From line 21 changed to line 21:
Hello,
Here is my tutorial to combine Seam and Flex. I will use Seam 2.1, Flex SDK 3.3 and FlamingoDS 1.7. See the [following post=>http://seamframework.org/Community/DirectSeamSupportForFlex] to learn why I'm using FlamingoDS and not GraniteDS or BlazeDS.
From lines 23 to 24 changed to lines 23 to 159:
here is my tutorial to combine Seam and Flex. I will use Seam 2.1, Flex SDK 3.3 and FlamingoDS 1.7. See this post to learn why I'm using FlamingoDS and not GraniteDS or
BlazeDS.

<b>1) requirements:</b>

Seam:

=basic Seam 2.\*-project
=( e.g. created with seam-gen)

Flex:

=install Flex SDK 3.3
=set |FLEX_HOME|
=configure IDE
=configure compilation (e.g.: flexTasks with ant)
=(config AS-generation with GraniteDS, if needed)


<b>2) configure FlamingoDS</b>

<b>2.1) download</b>

=[download=>http://www.exadel.com/web/portal/flamingo]
=(version 1.7. is used here, version 1.8 is available since 01.06.09)

<b>2.2) Java libraries</b>

=add these libraries into classpath: amf-serializer-1.7.1.jar, flamingo-service-1.7.1.jar

<b>2.3.) Flex libraries</b>
To use flamingo seam components, the compiler needs to know the flamingo-flex-1.7.1.swc(/WEB-INF/lib/flex/) library; e.g. via ant:

`
<target name="compileFlex">
<mxmlc file="${war.src.flex.dir}/main.mxml"
...
<compiler.include-libraries dir="${war.lib.dir}/flex">
<include name="flamingo-flex-1.7.1.swc" />
</compiler.include-libraries>
</mxmlc>
</target>
`

<b>2.4) configure AMF-Servlet</b>
FlamingoDS allows us to acces Seam components as RemoteObjects. For that reason, AMF(Action Message Format)-protocol is used to transform Java objects into AS objects and vice versa. Flamingo provides a Servlet to manage the communication between frontend and backend. It's registered in the web.xml:

`
<servlet>
<servlet-name>AMF Remote Servlet</servlet-name>
<servlet-class>com.exadel.flamingo.service.seam.AMFToSeamServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>AMF Remote Servlet</servlet-name>
<url-pattern>/flamingo/amf/*</url-pattern>
</servlet-mapping>
`

The associated AMF-Channel needs to be configured in the services-config.xml (WEB-INF/flex):

`
<channel-definition id="seam-amf" class="mx.messaging.channels.AMFChannel">
<endpoint uri="http://{server.name}:{server.port}/CONTEXT-ROOT/flamingo/amf/"
class="flex.messaging.endpoints.AMFEndpoint" />
</channel-definition>
`

Replace |CONTEXT-ROOT| with the current application name.


<b>3) Example</b>


<b>3.1) Seam component</b>
For the example I use a simple POJO as Seam component:

`
@Name("helloWorld")
public class HelloWorld {
@Begin
public void start() {
System.out.println("starting....");
}

@End
public void stop() {
System.out.println("stopping....");
}
}
`

<b>3.2) Declaration of Seam component</b>
Seam components are declared in services-config.xml. We extract the declaration for overview issue:

`
<services>
<service-include file-path="seam-remoting-config.xml" />
</services>
`

seam-remoting-config.xml:

`
<?xml version="1.0" encoding="UTF-8"?>
<service id="seam-remoting-service" class="flex.messaging.services.RemotingService">
<default-channels>
<channel ref="seam-amf"/>
</default-channels>

<destination id="helloWorld" />
</service>
`

The name in "destination" equals the name of the Seam component.

<b>3.3) Access from MXML</b>
The SeamRemoteObject is one of the client-components Flamingo provides to control conversations. Simply assign the Seam component as remote object and it is available within Flex mxml source-file. There is no need for further initializations:

`
<mx:Application name="testHelloWorldUpdate"
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:flamingo="com.exadel.flamingo.flex.components.flamingo.*">
...
<flamingo:SeamRemoteObject id="ro" destination="helloWorld"/>
...

<mx:Button label="Start" click="ro.start()"/>
<mx:Button label="Stop" click="ro.stop()"/>
</mx:Application>
`

The buttons invoke the helloWorld-methods to begin and end a conversation.

That's it. (-:

Feedback welcome.

Michael