PDA

View Full Version : Returning a list of object?


mythinky
08-30-2007, 11:43 PM
Hi All,
Based on the code, if I call the getAllPets() from http://localhost:8080/myapp/dwr/,
it will always return an array of null value. Any idea why it's so?
When I try returning the size of the list, it will return me 1.


When I call testStringList(), it will return an array of the string, which is [test String].




public class Pet {

private String id;
private String name;
private String type;

public Pet() {
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

}

public class PetService {
public List getAllPets(){
Pet pet = new Pet();
pet.setId("Pet1");
pet.setName("MyPuppy");
pet.setType("Dog");

List list = new ArrayList();
list.add(pet);
return list;

}

public List testStringList(){

List list = new ArrayList();
list.add(new String("test String"));
return list;

}
}



Thanks.

evant
08-30-2007, 11:47 PM
What does this have to do with Ext? :-/

mythinky
08-30-2007, 11:56 PM
I am using DWR with Ext. Sorry if I have post it in the wrong forum.

Animal
08-31-2007, 02:18 AM
The correct forum would be the DWR mailing list. Biut it could be something to do with converters.

maybe add this to dwr.xml:


<convert converter="collection" match="java.util.List"/>

mythinky
08-31-2007, 03:05 AM
Thanks.

For all users that have this problem.

You may add this into dwr.xml
<convert converter="bean" match="com.test.Pet">
<param name="include" value="id,name,type" />
</convert>

:)