Here are the sample programs which shows a way to pass the data object between views:
Default view:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:tcustomerservice="services.tcustomerservice.*"
xmlns:valueObjects="valueObjects.*"
xmlns:supportClasses="spark.skins.mobile.supportClasses.*"
fontSize="14" overlayControls="false" textAlign="left" title="PHP Test">
<s:layout>
<s:FormLayout/>
</s:layout>
<fx:Script>
<![CDATA[
import com.adobe.fiber.core.model_public;
protected function fetch_clickHandler(event:MouseEvent):void
{
getT_customerByIDResult.token = tcustomerService.getT_customerByID(parseInt(itemIDTextInput.text));
//navigator.pushView(SearchResult);
}
protected function next_clickHandler(event:MouseEvent):void
{
getT_customerByIDResultForNewView.token = tcustomerService.getT_customerByID(parseInt(itemIDTextInput.text));
}
protected function update_clickHandler(event:MouseEvent):void
{
t_customer.cno = parseInt(cnoTextInput.text);
t_customer.cname = cnameTextInput.text;
t_customer.ccity = ccityTextInput.text;
}
]]>
</fx:Script>
<fx:Declarations>
<tcustomerservice:TcustomerService id="tcustomerService"/>
<s:CallResponder id="getT_customerByIDResult"
result="t_customer = getT_customerByIDResult.lastResult as T_customer"/>
<s:CallResponder id="getT_customerByIDResultForNewView"
result="navigator.pushView(SearchResult, (getT_customerByIDResultForNewView.lastResult as T_customer));"/>
<valueObjects:T_customer id="t_customer"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Form width="376" height="93" defaultButton="{fetch}">
<s:layout>
<s:FormLayout/>
</s:layout>
<s:FormItem label="CNO">
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<s:TextInput id="itemIDTextInput" width="64" height="45"/>
<s:Button id="fetch" width="71" height="44" label="Fetch"
click="fetch_clickHandler(event)"/>
<s:Button width="162" height="45" label="Show in Next Page"
click="next_clickHandler(event)"/>
</s:FormItem>
</s:Form>
<s:Form x="0" y="152" width="375" defaultButton="{update}">
<s:FormHeading width="331" label="Details" fontSize="20" textAlign="center"/>
<s:FormItem label="CNO">
<s:TextInput id="cnoTextInput" width="82" text="{t_customer.cno}"/>
</s:FormItem>
<s:FormItem width="331" label="Name">
<s:TextInput id="cnameTextInput" width="234" text="{t_customer.cname}"/>
</s:FormItem>
<s:FormItem width="337" label="Addr">
<s:TextInput id="ccityTextInput" width="233" text="{t_customer.ccity}"/>
</s:FormItem>
<s:FormItem>
<s:Group width="200" height="58">
<s:Button id="update" x="60" y="0" width="130" height="52" label="Update"
click="update_clickHandler(event)"/>
</s:Group>
</s:FormItem>
</s:Form>
</s:View>
Result Page View:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
title="SearchResult">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Form height="419" defaultButton="{back}">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<s:FormHeading width="266" label="Customer Details" fontSize="18" fontWeight="bold"
textAlign="center"/>
<s:FormItem label="CNO">
<s:TextInput id="cnoTextInput" width="165" text="{data.cno}"/>
</s:FormItem>
<s:FormItem label="Name">
<s:TextInput id="cnameTextInput" width="195" text="{data.cname}"/>
</s:FormItem>
<s:FormItem label="Addr">
<s:TextInput id="ccityTextInput" width="200" text="{data.ccity}"/>
</s:FormItem>
<s:FormItem width="248" height="64" label="" textAlign="center">
<s:layout>
<s:FormLayout/>
</s:layout>
<s:HGroup width="222" height="47" horizontalAlign="center" horizontalCenter="-69"
textAlign="center" verticalCenter="0">
<s:Button id="back" width="110" label="Back" click="navigator.popView()"
styleName="back"/>
</s:HGroup>
</s:FormItem>
</s:Form>
</s:View>
No comments:
Post a Comment