flex4 数据绑定
发布时间:2020-12-15 01:24:07 所属栏目:百科 来源:网络整理
导读:Flex 中的数据并不像之前开发通过表单进行绑定,Flex中的FORM 标签只用于布局显示。Flex 的数据和java的pojo类通过as类来实现对应。mxml中标签用双向绑定就可以了。 列子如下: pojo类 package cn.com.chinamobil.pojo; import javax.persistence.Column; imp
Flex中的数据并不像之前开发通过表单进行绑定,Flex中的FORM 标签只用于布局显示。Flex 的数据和java的pojo类通过as类来实现对应。mxml中标签用双向绑定就可以了。
列子如下: pojo类 package cn.com.chinamobil.pojo; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.Parameter; /** * WhcPark entity. @author MyEclipse Persistence Tools */ @Entity @Table(name = "WHC_PARK",schema = "CMGXQ") public class WhcPark implements java.io.Serializable { ? ? ? ? ? ? ? ? private static final long serialVersionUID = 1L; ? ? ? ? private String id; ? ? ? ? private String parkName; ? ? ? ? private String territoriality; ? ? ? ? // Constructors ? ? ? ? /** default constructor */ ? ? ? ? public WhcPark() { ? ? ? ? } ? ? ? ? public WhcPark(String id){ ? ? ? ? ? ? ? ? this.id=id; ? ? ? ? } ? ? ? ? public WhcPark(String territoriality,String parkName) { ? ? ? ? ? ? ? ? this.territoriality = territoriality; ? ? ? ? ? ? ? ? this.parkName = parkName; ? ? ? ? } ? ? ? ? /** full constructor */ ? ? ? ? public WhcPark(String id,String territoriality,String parkName) { ? ? ? ? ? ? ? ? this.id = id; ? ? ? ? ? ? ? ? this.territoriality = territoriality; ? ? ? ? ? ? ? ? this.parkName = parkName; ? ? ? ? } ? ? ? ? // Property accessors ? ? ? ? @Id ? ? @Column(name = "ID",unique = true,nullable = false,length = 16) ? ? ? ? @GeneratedValue(generator="company_seq") ? ? @GenericGenerator(name="company_seq",strategy="sequence",parameters={@Parameter(name="sequence",value="WHC_PARK_SEQ")}) ? ? ? ? public String getId() { ? ? ? ? ? ? ? ? return this.id; ? ? ? ? } ? ? ? ? public void setId(String id) { ? ? ? ? ? ? ? ? this.id = id; ? ? ? ? } ? ? ? ? @Column(name = "TERRITORIALITY",length = 40) ? ? ? ? public String getTerritoriality() { ? ? ? ? ? ? ? ? return this.territoriality; ? ? ? ? } ? ? ? ? public void setTerritoriality(String territoriality) { ? ? ? ? ? ? ? ? this.territoriality = territoriality; ? ? ? ? } ? ? ? ? @Column(name = "PARK_NAME",length = 100) ? ? ? ? public String getParkName() { ? ? ? ? ? ? ? ? return this.parkName; ? ? ? ? } ? ? ? ? public void setParkName(String parkName) { ? ? ? ? ? ? ? ? this.parkName = parkName; ? ? ? ? } ? ? ? ? } as 类 package asfile { ? ? ? ? import mx.messaging.channels.StreamingAMFChannel; ? ? ? ? [RemoteClass(alias="cn.com.chinamobil.pojo.WhcPark")] ? ? ? ? public class WhcPark ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [Bindable] ? ? ? ? ? ? ? ? public var id:String; ? ? ? ? ? ? ? ? [Bindable] ? ? ? ? ? ? ? ? public var parkName:String; ? ? ? ? ? ? ? ? [Bindable] ? ? ? ? ? ? ? ? public var territoriality:String; ? ? ? ? ? ? ? ? public function WhcPark() ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? } } 注意: as 类中的每个属性必须和java类中对应 路径要配置对 [RemoteClass(alias="cn.com.chinamobil.pojo.WhcPark")] 在进行调用的时候直接把As类的对象当成java对象就可以了 下面是调用的方法 protected function btn1_clickHandler(event:MouseEvent):void { srv.add(_whcpark); } <s:RemoteObject id="srv" destination="parkinfoService" endpoint="/chinaMobil/messagebroker/amf"> ? ? ? ? ? ? ? ? ? ? ? ? <s:method name="add" result="fillData(event)" /> </s:RemoteObject> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |