instanceof validation error on checking value obects from server

Jonathan Thompson <[email protected]>
Newsgroups gmane.comp.java.openamf.user
Message-ID <[email protected]>
Hi,

I am currently working on a project with openAMF, and any input on this 
problem would be greatly appreciated.

Jonathan

Here is our situation.We are successfully sending data to and from our 
server via openAMF. Using the following code, I can walk the objects 
properties and get name/value pairs.

        var item = result.result;

        for(var prop in item)
        {
            TRACE(Flashout.DEBUG + prop + ": " + item[prop]);   
        }

However, when I attempt to validate the object's class type in Flash 
like so:

TRACE(Flashout.DEBUG + "item instanceof 
com.rbx.selfservice.model.vo.ContentTemplate: " + (item instanceof 
com.rbx.selfservice.model.vo.ContentTemplate));

and Flash returns false every time. This happens for any object or 
collection of objects we send across. We are sometimes taking a result 
set collection of objects and setting it as a data provider to a 
mx.controls.DataGrid component. The data will appear in the datagrid, 
however, because it is not the class type that the datagrid is 
expecting, the datagrid renders the data, but quits responding to any 
click or change events. The only way I have been able to get our data to 
work is to manually parse the server response and manually create and 
populate the corresponding value object. Once I have completed that 
process, the datagrid will render data properly and respond to events 
normally.

All AS2 value objects are being successfully registered via the 
Object.registerClass(remoteObject, localObject); function.

The following is one of our simplest objects we are working with. I have 
attached a copy of our Java value object class, our AS2.0 value object, 
and our openamf-config.xml.

The server call we are testing with is getAContentTemplate();

Here is our Java class:

/*********
 *
 */
package com.roundbox.oss.om;

import java.io.Serializable;
import java.util.Date;

import org.apache.commons.lang.builder.ReflectionToStringBuilder;

public class ContentTemplate implements Serializable {
   
    /**
     *  for serialization
     */
    private static final long serialVersionUID = 4311769467706990813L;
    private String id;
    private String title;
    private Date lastUpdated;
    private String templateText;
   
    /**
     * @return Returns the id.
     * @hibernate.id generator-class="uuid.hex" column="content_template_id"
     */
    public String getId() {
        return id;
    }
   
    /**
     * @param id The id to set.
     */
    public void setId(String id) {
        this.id = id;
    }
   
    /**
     * @return Returns the lastUpdated.
     * @hibernate.property column="last_updated"
     */
    public Date getLastUpdated() {
        return lastUpdated;
    }
   
    /**
     * @param lastUpdated The lastUpdated to set.
     */
    public void setLastUpdated(Date lastUpdated) {
        this.lastUpdated = lastUpdated;
    }
   
    /**
     * @return Returns the templateText.
     * @hibernate.property column="template_text" type="clob"
     */
    public String getTemplateText() {
        return templateText;
    }
   
    /**
     * @param templateText The templateText to set.
     */
    public void setTemplateText(String templateText) {
        this.templateText = templateText;
    }
   
    /**
     * @return Returns the title.
     * @hibernate.property type="string" size="64"
     */
    public String getTitle() {
        return title;
    }
   
    /**
     * @param title The title to set.
     */
    public void setTitle(String title) {
        this.title = title;
    }
   
    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    public String toString() {
        return ReflectionToStringBuilder.toString(this);
    }
   

}

//////////////////////////
//and here is our AS2 class:
/////////////////////////
/**
 * @author *****
 *
 */
class com.rbx.selfservice.model.vo.ContentTemplate
{

    private var id:String;
    private var title:String;
    private var lastUpdated:Date;
    private var templateText:String;
   
    public function ContentTemplate() {
       
    }
   
    /**
     * @return Returns the id.
     */
    public function getId():String {
        return id;
    }
   
    /**
     * @param id The id to set.
     */
    public function setId(id:String):Void {
        this.id = id;
    }
   
    /**
     * @return Returns the lastUpdated.
     */
    public function getLastUpdated():Date {
        return lastUpdated;
    }
   
    /**
     * @param lastUpdated The lastUpdated to set.
     */
    public function setLastUpdated(lastUpdated:Date):Void {
        this.lastUpdated = lastUpdated;
    }
   
    /**
     * @return Returns the templateText.
     */
    public function getTemplateText():String {
        return templateText;
    }
   
    /**
     * @param templateText The templateText to set.
     */
    public function setTemplateText(templateText:String):Void {
        this.templateText = templateText;
    }
   
    /**
     * @return Returns the title.
     */
    public function getTitle():String {
        return title;
    }
   
    /**
     * @param title The title to set.
     */
    public function setTitle(title:String):Void {
        this.title = title;
    }
   
    public function toString(Void) : String {
        return "ContentTemplate";
    }

}

/////////////////////////////////////////
// our openamf-config.xml
////////////////////////////////////////

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

    <!--
        Configure behavior of outgoing AMF messages:
        forceLowerCaseKeys - if true, the hash maps used to return 
custom classes
        will convert all keys to lower case;
        set this to:
        true if you're using ActionScript 1.0 on the client,
        false if you're using ActionScript 2.0 (which is case-sensitive)
    -->
    <amf-serializer>
        <force-lower-case-keys>false</force-lower-case-keys>
    </amf-serializer>

    <invoker>
        <name>Java</name>
        <class>org.openamf.invoker.SpringBeanInvoker</class>
    </invoker>

    <custom-class-mapping>
        <java-class>
            com.roundbox.oss.om.AssociatedContentItem
        </java-class>
        <custom-class>
            com.rbx.selfservice.model.vo.AssociatedContentItem
        </custom-class>
    </custom-class-mapping>

    <custom-class-mapping>
        <java-class>com.roundbox.oss.om.ContentEntry</java-class>
        <custom-class>
            com.rbx.selfservice.model.vo.ContentEntry
        </custom-class>
    </custom-class-mapping>

    <custom-class-mapping>
        <java-class>com.roundbox.oss.om.ContentSection</java-class>
        <custom-class>
            com.rbx.selfservice.model.vo.ContentSection
        </custom-class>
    </custom-class-mapping>

    <custom-class-mapping>
        <java-class>com.roundbox.oss.om.ContentTemplate</java-class>
        <custom-class>
            com.rbx.selfservice.model.vo.ContentTemplate
        </custom-class>
    </custom-class-mapping>

    <custom-class-mapping>
        <java-class>com.roundbox.oss.om.FaqCollection</java-class>
        <custom-class>
            com.rbx.selfservice.model.vo.FaqCollection
        </custom-class>
    </custom-class-mapping>

    <custom-class-mapping>
        <java-class>com.roundbox.oss.om.FaqPair</java-class>
        <custom-class>
            com.rbx.selfservice.model.vo.FaqPair
        </custom-class>
    </custom-class-mapping>

    <custom-class-mapping>
        <java-class>com.roundbox.oss.om.Folder</java-class>
        <custom-class>com.rbx.selfservice.model.vo.Folder</custom-class>
    </custom-class-mapping>

    <custom-class-mapping>
        <java-class>com.roundbox.oss.om.QuickLink</java-class>
        <custom-class>
            com.rbx.selfservice.model.vo.QuickLink
        </custom-class>
    </custom-class-mapping>

    <custom-class-mapping>
        <java-class>
            com.roundbox.oss.om.RestrictableContentEntry
        </java-class>
        <custom-class>
            com.rbx.selfservice.model.vo.RestrictableContentEntry
        </custom-class>
    </custom-class-mapping>

    <!--
        Article.java
        Contact.java
        ContentComponent.java
        ContentComponentSet.java
        Download.java
        Forum.java
        ForumContact.java
        Link.java
        Poll.java
        PollChoice.java
        PollResponse.java
        PollResponseRating.java
        SectionContact.java
    -->

    <!-- Template
        <custom-class-mapping>
        <java-class>com.rbx.selfservice.model.vo.Folder</java-class>
        <custom-class>com.roundbox.oss.om.Folder</custom-class>
        </custom-class-mapping>
    -->

    <service>
        <name>TemplatePortal</name>
        <service-location>templatePortal</service-location>
        <invoker-ref>Java</invoker-ref>
        <method>
            <!-- Operations are matched by the name and parameters -->
            <name>getTemplates</name>
            <parameter>
                <type>*</type>
            </parameter>
        </method>
    </service>

    <!--
        type can be the the name of the class,
        a * for any types,
        or a ? any 1 type
    -->

    <service>
        <name>SuperAdminPortal</name>
        <service-location>superAdminPortal</service-location>
        <invoker-ref>Java</invoker-ref>
        <!--  createContentSection(ContentSection section, String 
sessionId) -->
        <method>
            <name>saveContentSection</name>
            <!--  the content section to save -->
            <parameter>
                <type>*</type>
            </parameter>
            <!--  the user's session ID -->
            <parameter>
                <type>java.lang.String</type>
            </parameter>
        </method>


    </service>

    <service>
        <name>AdminPortal</name>
        <service-location>adminPortal</service-location>
        <invoker-ref>Java</invoker-ref>
        <!--  getAllContentSections(String sessionId) -->
        <method>
            <name>getAllContentSections</name>
            <!--  the user's session ID -->
            <parameter>
                <type>java.lang.String</type>
            </parameter>
        </method>
        <method>
            <name>getContentSection</name>
            <!--  the content section id -->
            <parameter>
                <type>*</type>
            </parameter>
            <!--  the user's session ID -->
            <parameter>
                <type>java.lang.String</type>
            </parameter>
        </method>
        <method>
            <name>getFaqCollection</name>
            <!--  the FaqCollection id -->
            <parameter>
                <type>java.lang.String</type>
            </parameter>
            <!--  the user's session ID -->
            <parameter>
                <type>java.lang.String</type>
            </parameter>
        </method>
        <method>
            <!--  List getContentTemplates(String sessionId) -->
            <name>getContentTemplates</name>
            <!--  the user's session ID -->
            <parameter>
                <type>java.lang.String</type>
            </parameter>
        </method>
        <method>
            <!--  for testing only, remove for production -->
            <!--  ContentTemplate getAContentTemplates() -->
            <name>getAContentTemplate</name>
            <parameter><type>*</type></parameter>
        </method>
    </service>

    <!-- service>
        <name>AdminPortal</name>
        <service-location>adminPortal</service-location>
        <invoker-ref>Java</invoker-ref>
        <method>
        <name></name>
        <parameter><type></type></parameter>
        </method>
        </service-->

    <!--  for testing only remove for production -->
    <service>
        <name>TestPortal</name>
        <service-location>testPortal</service-location>
        <invoker-ref>Java</invoker-ref>
        <method>
            <name>templateTest</name>
            <parameter>
                <type>java.lang.String</type>
            </parameter>
        </method>
    </service>

</config>



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.