Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么Java值对象作为通用Flex对象回归?_Java_Apache Flex_Hibernate_Actionscript_Cairngorm - Fatal编程技术网

为什么Java值对象作为通用Flex对象回归?

为什么Java值对象作为通用Flex对象回归?,java,apache-flex,hibernate,actionscript,cairngorm,Java,Apache Flex,Hibernate,Actionscript,Cairngorm,我将尽可能多地提供细节 我正在使用Flex(Cairngorm 2)/Java/Hibernate创建一个CRM应用程序。 我面临的基本问题是: 我有一个Java中的Customer类,它有一个地址类的ArrayList。 我在Flex中有一个Customer类,它有一个地址类的ArrayCollection 当我为客户进行远程对象调用时,我在Flex中得到一个客户对象,但是ArrayCollection对象的数据类型是object而不是Address 如果我尝试调用地址类列表,我会得到相同的结

我将尽可能多地提供细节

我正在使用Flex(Cairngorm 2)/Java/Hibernate创建一个CRM应用程序。 我面临的基本问题是:

我有一个Java中的Customer类,它有一个地址类的ArrayList。 我在Flex中有一个Customer类,它有一个地址类的ArrayCollection

当我为客户进行远程对象调用时,我在Flex中得到一个客户对象,但是ArrayCollection对象的数据类型是object而不是Address

如果我尝试调用地址类列表,我会得到相同的结果。 如果我尝试调用一个客户类列表,我会在Flex中得到一个客户类列表

将tomcat 6与以下JAR一起使用:

antlr-2.7.6.jar               
flex-messaging-proxy.jar
backport-util-concurrent.jar  
flex-messaging-remoting.jar
cfgatewayadapter.jar          
hibernate3.jar
commons-codec-1.3.jar         
hibernate-jpa-2.0-api-1.0.0.Final.jar
commons-collections-3.1.jar   
javassist-3.12.0.GA.jar
commons-httpclient-3.0.1.jar  
jta-1.1.jar
commons-logging.jar           
logback-classic-0.9.28.jar
concurrent.jar                
logback-core-0.9.28.jar
dom4j-1.6.1.jar               
mybatis-3.0.4.jar
flex-messaging-common.jar     
mysql-connector-java-5.1.16-bin.jar
flex-messaging-core.jar       
slf4j-api-1.6.1.jar
flex-messaging-opt.jar        
xalan.jar
Customer.as

package com.middleburgsalesandservice.gryphon.vo.customer

{


import com.middleburgsalesandservice.gryphon.vo.common.AttributeCollection;



import mx.collections.ArrayCollection;



[Bindable]

[RemoteClass(alias="com.middleburgsalesandservice.gryphon.pojo.customer.Customer")]

public class Customer

{

    public var customerId:int;

    public var startDate:Date = new Date();

    public var endDate:Date = new Date();

    public var createdDate:Date = new Date();

    public var customerFirstName:String;            

    public var customerLastName:String;         

    public var customerUserName:String;     

    public var customerPassWord:String;

    public var addresses:ArrayCollection = new ArrayCollection();

    public var phones:ArrayCollection = new ArrayCollection();

    public var customerOrders:ArrayCollection = new ArrayCollection();

    public var webSites:ArrayCollection = new ArrayCollection();

    public var emails:ArrayCollection = new ArrayCollection();

    public var attributes:ArrayCollection = new ArrayCollection();

    public var attributeCollection:AttributeCollection = new AttributeCollection();



    public function Customer()

    {

        super();

    }



}
}

地址

package com.middleburgsalesandservice.gryphon.vo.common

{



[Bindable]

[RemoteClass(alias="com.middleburgsalesandservice.gryphon.pojo.common.Address")]

public class Address 

{

    public var addressId:int;

    public var address1:String;

    public var address2:String; 

    public var city:String;

    public var state:State = new State();

    public var zipCode:String;

    public var addressType:AddressType = new AddressType();

    public var country:Country = new Country();

    public var primaryNumber:int;

    public var primaryAddress:Boolean;

    public var startDate:Date;

    public var endDate:Date;



    public function Address()

    {

        super();

    }



}
}

Customer.java

package com.middleburgsalesandservice.gryphon.pojo.customer;



 import java.util.ArrayList;

 import java.util.Date;

 import java.util.HashSet;

 import java.util.List;

 import java.util.Set;



 import com.middleburgsalesandservice.gryphon.pojo.common.Address;

 import com.middleburgsalesandservice.gryphon.pojo.common.Attribute;

 import com.middleburgsalesandservice.gryphon.pojo.common.AttributeCollection;

 import com.middleburgsalesandservice.gryphon.pojo.common.EmailAddress;

 import com.middleburgsalesandservice.gryphon.pojo.common.Phone;

 import com.middleburgsalesandservice.gryphon.pojo.common.WebAddress;

 import com.middleburgsalesandservice.gryphon.pojo.order.Order;




 public class Customer {

private int customerId;

private Date startDate;

private Date endDate;

private String customerFirstName;           

private String customerLastName;            

private Date createdDate;

private String customerUserName;        

private String customerPassWord;

private List<Address> addresses = new ArrayList<Address>();

private List<Phone> phones = new ArrayList<Phone>();

private List<Order> customerOrders = new ArrayList<Order>();

private List<WebAddress> webSites = new ArrayList<WebAddress>();

private List<EmailAddress> emails = new ArrayList<EmailAddress>();

private List<Attribute> attributes = new ArrayList<Attribute>();

private AttributeCollection attributeCollection;

public String getCustomerFirstName() {

    return customerFirstName;

}

public void setCustomerFirstName(String customerFirstName) {

    this.customerFirstName = customerFirstName;

}

public String getCustomerLastName() {

    return customerLastName;

}

public void setCustomerLastName(String customerLastName) {

    this.customerLastName = customerLastName;

}

public String getCustomerUserName() {

    return customerUserName;

}

public void setCustomerUserName(String customerUserName) {

    this.customerUserName = customerUserName;

}

public String getCustomerPassWord() {

    return customerPassWord;

}

public void setCustomerPassWord(String customerPassWord) {

    this.customerPassWord = customerPassWord;

}

public List<Address> getAddresses() {

    return addresses;

}

public void setAddresses(List<Address> addresses) {

    this.addresses = addresses;

}

public List<Phone> getPhones() {

    return phones;

}

public void setPhones(List<Phone> phones) {

    this.phones = phones;

}

public String getFullName(){

    return this.getCustomerFirstName() + " " + this.getCustomerLastName();

}

/**

 * @return the createdDate

 */

public Date getCreatedDate() {

    return createdDate;

}

/**

 * @param createdDate the createdDate to set

 */

public void setCreatedDate(Date createdDate) {

    this.createdDate = createdDate;

}

/**

 * @return the customerOrders

 */

public List<Order> getCustomerOrders() {

    return customerOrders;

}

/**

 * @param customerOrders the customerOrders to set

 */

public void setCustomerOrders(List<Order> customerOrders) {

    this.customerOrders = customerOrders;

}

/**

 * @return the webSites

 */

public List<WebAddress> getWebSites() {

    return webSites;

}

/**

 * @param webSites the webSites to set

 */

public void setWebSites(List<WebAddress> webSites) {

    this.webSites = webSites;

}

/**

 * @return the emails

 */

public List<EmailAddress> getEmails() {

    return emails;

}

/**

 * @param emails the emails to set

 */

public void setEmails(List<EmailAddress> emails) {

    this.emails = emails;

}

/**

 * @return the attributeCollection

 */

public AttributeCollection getAttributeCollection() {

    return attributeCollection;

}

/**

 * @param attributeCollection the attributeCollection to set

 */

public void setAttributeCollection(AttributeCollection attributeCollection) {

    this.attributeCollection = attributeCollection;

}

/**

 * @return the attributes

 */

public List<Attribute> getAttributes() {

    return attributes;

}

/**

 * @param attributes the attributes to set

 */

public void setAttributes(List<Attribute> attributes) {

    this.attributes = attributes;

}

/**

 * @return the customerId

 */

public int getCustomerId() {

    return customerId;

}

/**

 * @param customerId the customerId to set

 */

public void setCustomerId(int customerId) {

    this.customerId = customerId;

}

/**

 * @return the startDate

 */

public Date getStartDate() {

    return startDate;

}

/**

 * @param startDate the startDate to set

 */

public void setStartDate(Date startDate) {

    this.startDate = startDate;

}

/**

 * @return the endDate

 */

public Date getEndDate() {

    return endDate;

}

/**

 * @param endDate the endDate to set

 */

public void setEndDate(Date endDate) {

    this.endDate = endDate;

}

/* (non-Javadoc)

 * @see java.lang.Object#toString()

 */

@Override

public String toString() {

    return "ID=" + this.getCustomerId() + "|FirstName=" + this.getCustomerFirstName() + "|LastName=" + this.getCustomerLastName();

}
休眠映射: Customer.hbm.xml

  <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE hibernate-mapping PUBLIC

        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"

        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

    <hibernate-mapping>

    <class name="com.middleburgsalesandservice.gryphon.pojo.customer.Customer" table="customer">

        <id column="customer_id" name="customerId" type="int">

            <generator class="native"/>

        </id>

        <property column="cust_f_name" name="customerFirstName" />

        <property column="cust_l_name" name="customerLastName" />

        <property column="cust_user_name" name="customerUserName" />

        <property column="cust_pass_word" name="customerPassWord" />

        <property column="startdate" name="startDate" type="java.util.Date"/>

        <property column="enddate" name="endDate" type="java.util.Date"/>

        <property column="created_dt" name="createdDate" type="java.util.Date"/>

        <many-to-one column="attribute_col_id" name="attributeCollection" class="com.middleburgsalesandservice.gryphon.pojo.common.AttributeCollection"/>

        <bag name="addresses" table="cust_address" lazy="false">

            <key column="customer_id"/>

            <many-to-many column="address_id" class="com.middleburgsalesandservice.gryphon.pojo.common.Address"/>

        </bag>

        <bag name="phones" table="cust_phone" lazy="false">

            <key column="customer_id"/>

            <many-to-many column="phone_id" class="com.middleburgsalesandservice.gryphon.pojo.common.Phone"/>

        </bag>

        <bag name="webSites" table="cust_web_address" lazy="false">

            <key column="customer_id"/>

            <many-to-many column="web_address_id" class="com.middleburgsalesandservice.gryphon.pojo.common.WebAddress"/>

        </bag>

        <bag name="emails" table="cust_email" lazy="false">

            <key column="customer_id"/>

            <many-to-many column="email_id" class="com.middleburgsalesandservice.gryphon.pojo.common.EmailAddress"/>

        </bag>

        <bag name="attributes" table="cust_attributes" lazy="false">

            <key column="customer_id"/>

            <many-to-many column="attribute_id" class="com.middleburgsalesandservice.gryphon.pojo.common.Attribute"/>

        </bag>

        <bag name="customerOrders" table="customer_orders" lazy="false">

            <key column="customer_id"/>

            <many-to-many column="order_id" class="com.middleburgsalesandservice.gryphon.pojo.order.Order"/>

        </bag>

     </class>

   </hibernate-mapping>

Address.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
  <class name="com.middleburgsalesandservice.gryphon.pojo.common.Address" table="address">
        <id column="address_id" name="addressId" type="int">
            <generator class="native"/>
        </id>
        <property column="startdate" name="startDate" type="java.util.Date"/>
        <property column="enddate" name="endDate" type="java.util.Date"/>
        <property column ="addr1" name="address1" />
        <property column ="addr2" name="address2" />
        <property column="city" name="city" />
        <property column="zip_code" name="zipCode" />
        <many-to-one column="state_id" name="state" class="com.middleburgsalesandservice.gryphon.pojo.common.State" />      
        <many-to-one column="address_type_id" name="addressType" class="com.middleburgsalesandservice.gryphon.pojo.common.AddressType" />
        <many-to-one column="country_id" name="country" class="com.middleburgsalesandservice.gryphon.pojo.common.Country" />
        <property column="primary_address" name="primaryAddress" type="java.lang.Boolean" />
  </class>
  </hibernate-mapping>

你应该在SWF的某个地方找到你的
地址。最好的方法是在主应用程序中声明一个字段:

private var references:Object = {addressClass:Address, someOtheClass:SomeOtherClass};

问题是ActionScript中的
ArrayCollection
没有类型引用(Java中的泛型)。所以类的字节码不包括在SWF中。

Constantiner说得对,我们通常只在main中的on initialize方法中执行此操作。另一个地方是,即使您在代码中的某个地方引用了对象,但使用模块时,该对象不会被编译到应用程序中,并将作为对象出现。同样的补救方法也适用。如果我理解正确,我需要引用该类,以便在编译时包含它。我可以引用:public var address:address;或者我需要像上面那样做。两种方法都有效吗?我想我应该把这句话放在这里:两种方法都试过,但都没有乐趣。我知道我把它放在了正确的位置,因为当我动态创建视图时,我必须做一些类似的事情。这些都在编译中,所以我有了“public var newCustWin:CustomerForm;公共var findCustWin:FindCustomer;公共var测试:TestView//尝试此公共变量引用:对象={addressClass:Address}//这是一个单独的公共地址:address;'您可以使用查看真实的AMF数据。它显示了类映射。若数据传输正确,你们应该在客户端挖掘铲斗。在另一种情况下,问题出现在服务器端。我有一个Flex dump实用程序,可以转储对象,查看对象的所有内容,我在错误的位置查找。您的解决方案非常有效。谢谢你,两种方法都试过了,但都不高兴。我知道我把它放在了正确的位置,因为当我动态创建视图时,我必须做一些类似的事情。这些都在编译中,所以我有了“public var newCustWin:CustomerForm;公共var findCustWin:FindCustomer;公共var测试:TestView//尝试此公共变量引用:对象={addressClass:Address}//这是一个单独的公共地址:address;'
private var references:Object = {addressClass:Address, someOtheClass:SomeOtherClass};