Flex with Struts 2 with Source

In my previous post (https://niamathbasha.wordpress.com/2008/09/01/configuring-struts-2-with-flex/) I discussed about configuring flex with Struts 2. So many guys asking me to provide the working sample. So I configured a small Login application.

Download the sample application which uses Flex as UI and Struts 2  as Back-end.cairngorm-template.rar

Configuring Struts 2 with flex

Create a dynamic web project of java in Eclipse. Add Struts2-core-2.0.11.jar file to the lib folder. You can get this jar file from appache site. Create an xml file with name Struts-plugin.xml. Open the file and write:

<?xml version=”1.0″ encoding=”UTF-8″ ?>
<!DOCTYPE struts PUBLIC
“-//Apache Software Foundation//DTD Struts Configuration 2.0//EN”
http://struts.apache.org/dtds/struts-2.0.dtd”&gt;

this is doctype now write

<struts>

<constant name=”struts.enable.DynamicMethodInvocation” value=”false” />
<constant name=”struts.devMode” value=”false” />

<package name=”nameOfYourPackage” namespace=”/nameSpace” extends=”struts-default”>

<action name=”requiredURLName” class=”className”>
</action>

<!– Add action classes here –>

</package>

<!– Add packages here –>

</struts>

Now in your flex 3 code use HTTPService tag to call the service provided the url of the configured class.

The url will look like http://localhost:8080/nameSpace/requiredURLName.action.