前台的as 类:最重要的是要加com.system.domain.FlowType以便前台的类和后台的类对应。
- package
- {
- /**
- * 描述:
- * 创建时间:2012-12-26 上午10:09:29
- */
- [ Bindable]
- [ RemoteClass( alias= "com.system.domain.FlowType")]
- public class FlowType
- {
- public function FlowType()
- {
- }
- private var _pkId:int;
- private var _flowId:int;
- private var _typeId:int;
- public function get typeId():int
- {
- return _typeId;
- }
- public function set typeId(value:int):void
- {
- _typeId = value;
- }
- public function get flowId():int
- {
- return _flowId;
- }
- public function set flowId(value:int):void
- {
- _flowId = value;
- }
- public function get pkId():int
- {
- return _pkId;
- }
- public function set pkId(value:int):void
- {
- _pkId = value;
- }
- }
- }
package
{
/**
* 描述:
* 创建时间:2012-12-26 上午10:09:29
*/
[ Bindable]
[ RemoteClass( alias= "com.system.domain.FlowType")]
public class FlowType
{
public function FlowType()
{
}
private var _pkId:int;
private var _flowId:int;
private var _typeId:int;
public function get typeId():int
{
return _typeId;
}
public function set typeId(value:int):void
{
_typeId = value;
}
public function get flowId():int
{
return _flowId;
}
public function set flowId(value:int):void
{
_flowId = value;
}
public function get pkId():int
{
return _pkId;
}
public function set pkId(value:int):void
{
_pkId = value;
}
}
}
前台的代码:
- <?xml version="1.0" encoding="utf-8"?>
- <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:s="library://ns.adobe.com/flex/spark"
- xmlns:mx="library://ns.adobe.com/flex/mx"
- creationComplete="application1_creationCompleteHandler(event)"
- minWidth="955" minHeight="600">
- <s:layout>
- <s:BasicLayout/>
- </s:layout>
- <fx:Declarations>
- <mx:RemoteObject id="workflowRO" destination="workflowActionDest" fault="faultHandler(event)"/>
- </fx:Declarations>
- <fx:Script>
- <![CDATA[
- import mx.collections.ArrayCollection;
- import mx.controls.Alert;
- import mx.events.FlexEvent;
- import mx.rpc.events.FaultEvent;
- import mx.rpc.events.ResultEvent;
- [ Bindable]
- public var flowtypelist:ArrayCollection;
- private function faultHandler(event:FaultEvent):void {
- Alert.show(event.toString(), 'FaultHandlerError' );
- }
- protected function application1_creationCompleteHandler(event:FlexEvent):void
- {
- workflowRO.addEventListener(ResultEvent.RESULT,findflowTypereturn);
- workflowRO.findFlowTypes();
- }
- private function findflowTypereturn(event:ResultEvent):void
- {
- workflowRO.removeEventListener(ResultEvent.RESULT,findflowTypereturn);
- flowtypelist=event.result as ArrayCollection ;
- trace(flowtypelist.getItemAt(0));
- var ft:FlowType=flowtypelist.getItemAt(0) as FlowType;
- trace(ft.flowId);
- }
- protected function button1_clickHandler(event:MouseEvent):void
- {
- var ft:FlowType= dg.selectedItem as FlowType;
- Alert.show(ft.flowId.toString());
- ft.flowId=1000;
- workflowRO.addEventListener(ResultEvent.RESULT,chargereturn);
- workflowRO.saveFlowTypes(ft);
- }
- private function chargereturn(event:ResultEvent):void
- {
- workflowRO.removeEventListener(ResultEvent.RESULT,chargereturn);
- }
- ]]>
- </fx:Script>
- <s:VGroup>
- <s:Button label="添加" click="button1_clickHandler(event)"/>
- <mx:DataGrid id="dg" width="500" height="600" dataProvider="{flowtypelist}">
- <mx:columns>
- <mx:DataGridColumn dataField="flowId" headerText="flowId"/>
- <mx:DataGridColumn dataField="pkId" width="100" headerText="pkId"/>
- <mx:DataGridColumn dataField="typeId" headerText="typeId"/>
- </mx:columns>
- </mx:DataGrid>
- </s:VGroup>
- </s:Application>
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="application1_creationCompleteHandler(event)" minWidth="955" minHeight="600"> <s:layout> <s:BasicLayout/> </s:layout> <fx:Declarations> <mx:RemoteObject id="workflowRO" destination="workflowActionDest" fault="faultHandler(event)"/> </fx:Declarations> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.controls.Alert; import mx.events.FlexEvent; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; [ Bindable] public var flowtypelist:ArrayCollection; private function faultHandler(event:FaultEvent):void { Alert.show(event.toString(), 'FaultHandlerError' ); } protected function application1_creationCompleteHandler(event:FlexEvent):void { workflowRO.addEventListener(ResultEvent.RESULT,findflowTypereturn); workflowRO.findFlowTypes(); } private function findflowTypereturn(event:ResultEvent):void { workflowRO.removeEventListener(ResultEvent.RESULT,findflowTypereturn); flowtypelist=event.result as ArrayCollection ; trace(flowtypelist.getItemAt(0)); var ft:FlowType=flowtypelist.getItemAt(0) as FlowType; trace(ft.flowId); } protected function button1_clickHandler(event:MouseEvent):void { var ft:FlowType= dg.selectedItem as FlowType; Alert.show(ft.flowId.toString()); ft.flowId=1000; workflowRO.addEventListener(ResultEvent.RESULT,chargereturn); workflowRO.saveFlowTypes(ft); } private function chargereturn(event:ResultEvent):void { workflowRO.removeEventListener(ResultEvent.RESULT,chargereturn); } ]]> </fx:Script> <s:VGroup> <s:Button label="添加" click="button1_clickHandler(event)"/> <mx:DataGrid id="dg" width="500" height="600" dataProvider="{flowtypelist}"> <mx:columns> <mx:DataGridColumn dataField="flowId" headerText="flowId"/> <mx:DataGridColumn dataField="pkId" width="100" headerText="pkId"/> <mx:DataGridColumn dataField="typeId" headerText="typeId"/> </mx:columns> </mx:DataGrid> </s:VGroup> </s:Application>
后台对应的类:
- ackage com.system.domain;
- import java.io.Serializable;
- import javax.persistence.Column;
- import javax.persistence.Entity;
- import javax.persistence.GeneratedValue;
- import javax.persistence.Id;
- import javax.persistence.Table;
- @Entity
- @Table (name = "flow_type")
- public class FlowType implements Serializable {
- private Integer pkId;
- private Integer flowId;
- private Integer typeId;
- // empty Constructor
- public FlowType(){
- super();
- }
- // full Constructor
- public FlowType(Integer pkId , Integer flowId , Integer typeId){
- super();
- this.pkId = pkId;
- this.flowId = flowId;
- this.typeId = typeId;
- }
- // auto Constructor
- public FlowType(Integer flowId , Integer typeId){
- super();
- this.flowId = flowId;
- this.typeId = typeId;
- }
- @Id
- @GeneratedValue
- @Column(name = "pk_id")
- public Integer getPkId() {
- return pkId ;
- }
- public void setPkId( Integer pkId ) {
- this.pkId = pkId;
- }
- @Column(name = "flow_id")
- public Integer getFlowId() {
- return flowId ;
- }
- public void setFlowId( Integer flowId ) {
- this.flowId = flowId;
- }
- @Column(name = "type_id")
- public Integer getTypeId() {
- return typeId ;
- }
- public void setTypeId( Integer typeId ) {
- this.typeId = typeId;
- }