Hi
I have to send data from Flex to Struts. On struts side I have one form having
five fields from which four are Strings and one is
Address type. Here is the code
/**************************** Struts Side*************************************/
public class Student extends org.apache.struts.action.ActionForm
{
private String firstName;
private String lastName;
private String phone;
private String email;
private Address address = new Address();
//There are getters and setters off course.
}
public class Address
{
private String street;
public String getStreet()
{
return street;
}
public void setStreet(String street)
{
this.street = street;
}
/**************************** Flex Side *************************************/
At flex side I am using the httpservice(I do not have to use Flex Data Service)
here is the code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.CloseEvent;
]]>
</mx:Script>
<mx:HTTPService id="registrationRequest"
url="http://localhost:8084/FlexStruts/registration.do" method="GET"
result="Alert.show(
registrationRequest.lastResult.registration.status)"
useProxy="false" showBusyCursor="true">
<mx:request>
<firstName>{firstName.text}</firstName>
<lastName>{lastName.text}</lastName>
<phone>{phone.text}</phone>
<email>{email.text}</email>
<Address>
<street>{street.text}</street>
</Address>
</mx:request>
</mx:HTTPService>
<mx:Form horizontalCenter="0" y="25">
<mx:FormItem label="First Name" required="true">
<mx:TextInput id="firstName" width="200"/>
</mx:FormItem>
<mx:FormItem label="Last Name" required="true">
<mx:TextInput id="lastName" width="200"/>
</mx:FormItem>
<mx:FormItem label="Phone" required="true">
<mx:TextInput id="phone" width="200"/>
</mx:FormItem>
<mx:FormItem label="Email" required="true">
<mx:TextInput id="email" width="200"/>
</mx:FormItem>
<mx:FormItem label="Address" required="true">
<mx:TextInput id="street" width="200"/>
</mx:FormItem>
<mx:FormItem>
<mx:Button label="Register" click="registrationRequest.send()"/>
</mx:FormItem>
</mx:Form>
<mx:TextInput text="{registrationRequest.lastResult.registration.status}"
y="209" horizontalCenter="96"/>
<mx:Repeater id="errorList"
dataProvider="{registrationRequest.lastResult.registration.error}">
</mx:Repeater>
<mx:Label text="{errorList.currentItem}" y="273"
horizontalCenter="0"></mx:Label>
</mx:Application>
If there is any solution then please help to solve it.
Thanks in advance,
Warm Regards,
Jai Kumar
Send instant messages to your online friends http://uk.messenger.yahoo.com