logo       

RE: How to declare an array signature in this case?: msg#00102

java.dwr.user

Subject: RE: How to declare an array signature in this case?

Hi Joe,
 
I've had some similar quirks with collection properties lately, so I've done some tests on what you suggest here: 
Did you try this:

<signatures>
import whatever;
void ContainerClass.setElements(Set<ElementClass> s);
</signatures> 
In short, with Java5 and latest DWR from CVS it looks like beans with collection properties are ok without adding signatures, but objects with collection properties are broken even when using signatures. It would be nice to fix this before 2.0.
 
Test setup
 
I'm sending a _javascript_ structure like this to the server:
    var objwithlist = {
        list: [
            {firstName:"Donald", lastName:"Duck", age:72},
            {firstName:"Mickey", lastName:"Mouse", age:79}
        ]
    }
 
public class TestDataTypes {
    public void writeObjectWithList( ObjectWithList data ) { ... }
    public void writeBeanWithList( BeanWithList data ) { ... }
}
 
public class ObjectWithList {
    public List<PersonObject> list;
}
 
public class BeanWithList {
    private List<PersonObject> list;
    public List<PersonObject> getList() { ... }
    public void setList( List<PersonObject> list ) { ... }
}
 
public class PersonObject {
    public String firstName;
    public String lastName;
    public int age;
}
 
<create creator="new" _javascript_="testDataTypes">
    <param name="class" value="TestDataTypes" />
</create>
<convert match="ObjectWithList" converter="object"/>
<convert match="BeanWithList" converter="bean"/>
<convert match="PersonObject" converter="object"/>
 
Results
 
writeObjectWithList:

Wrong: The List<PersonObject> property is set to an ArrayList of String instances where the strings contain "firstName:reference:c0-e3, lastName:reference:c0-e4, age:reference:c0-e5}".

Console: "WARNING: Missing type info for writeObjectWithList(0<0>). Assuming this is a map with String keys. Please add to <signatures> in dwr.xml"

writeBeanWithList:
Correct: The List<PersonObject> is set to an ArrayList containing PersonObject instances.
Signatures
 
I tried adding a signature:
    <signatures>
        <![CDATA[
        import ...
        void ObjectWithList.setList(List<PersonObject> list);
        ]]>
    </signatures>
in case the method signature would be used for the ObjectWithList.list property assignment even though there is no such method, but it doesn't react on this.
 
I can post my test project if you're interested.
 
Best regards
Mike
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise