PDA

View Full Version : How to send json object to a restful method whose parameter is a entity class



mtigua
30 Dec 2009, 5:52 AM
Hello,

Im working with EXtjs and Resteasy. I am using JAXB annotated entity classes for marshall/unmarshall data between the two layers.

In the extjs page I have a formpanel. When the page is loaded this form calls the GET method and it is populated without any problem.

@GET
@Path("/persona/{id}")
@Produces("application/json")
public List getPersona(@PathParam("id") String id) {
Persona persona = new Persona();// JAXB annotated class
...// I fills this object with data
List listPersonas = new ArrayList();
listPersonas.add(persona);
return listPersonas;
}

The data is received by a JsonReader without any problem.

The question is if I had a method "putcustomer" that receive "Persona", how must be sent the data by the form?

@PUT
@Path("putcustomer")
@Consumes("application/json")
public void putCustomers(Persona persona)
{

}

I know that Ext JS 3.0 comes with a JsonWriter but I dont know how to use it.



Thanks in advance.

rolema
8 Mar 2010, 7:52 AM
Dis you find a solution ?

I can't find a way to POST/PUT a Json object with no Ext.data.JsonReader.root property