users@jersey.java.net

[Jersey] How to add XML node to existing JAXB annotatied class?

From: bndi <bndi_at_naver.com>
Date: Fri, 13 Feb 2009 14:38:08 +0900

Hi all.
Product.java :
---------------------------------------
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class Product {
 private int code;
 private String name;
}
---------------------------------------
ProductResource.java :
---------------------------------------
public class ProductResource {
 @Path("info/")
 public Response getProductInfo() {
 Product p = new Product();
 p.setCode(1234);
 p.setName("test");
 // how to add XML node this point? e.g. "total=1000"
 return ResponseImpl.ok(p).build();
 }
}
---------------------------------------
expected result :
---------------------------------------
 1234
 test
 1000
---------------------------------------
how to do this?
==========================================
https://jersey.dev.java.net/servlets/ReadMsg?list=users&msgNo=3785
Paul. wrote.
> But. given that the client states what the function should be in the
> query parameter why can't it do the work itself and wrap the JSON
> around the function? why it is necessary to do this on the server side?
I'm provide json format data to OpenAPI service.
but what if problem is cross domain security error. e.g) my domain is 'aaa.com' and user's domain is 'bbb.com'
therefore wrap javascript callback function name to json message body. e.g) zzz({"code":"12312","name":"yyy"})
and using below javascript to avoid cross domain problem.
------------------------------------------
 aaa : function()
 {
 obj.s = document.createElement('script');
 obj.s.type ='text/javascript';
 obj.s.charset ='utf-8';
 obj.s.src = 'http://aaa.com?callback=obj.bbb' + encodeURI(obj.q.value);
 }
 },
 bbb : function(z)
 {
 // TODO
 },
------------------------------------------