It would be quite tricky to create such an annotation to work
in a generic way. Is there any reason, why Tatu's suggested
generic list wrapper would not work for you?
You can still keep your original method generating the list
(if it needs to be present) and only add the other one serving
the REST call:
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("getAllOrganicas")
public ListWrapper<OrganicaMobileEntity> getOrganicasList() {
return new OrganicasWrapper(getOrganicas());
}
~Jakub
On 05/30/2011 03:24 PM, Maxrunner wrote:
> Well that's only a way to solve my issue. I just want tho change the
> List type name to one my own, like in here:
>
>
> @GET
> @Produces(MediaType.APPLICATION_JSON)
> @Path("/getAllOrganicas")
> *//SOME ANNOTATION HERE TO OVERRIDE TYPE NAME TO ONE OF MY ONWN? *
> public Organicas<OrganicaMobileEntity> getOrganicas(@Context HttpServletRequest req){
>
> List<OrganicaMobileEntity> organicas= new ArrayList<OrganicaMobileEntity>();
> //dummy data
> organicas.add(fillOrganica(123,req.getParameter("lastUpdate"),"2010-12-23",true));
> organicas.add(fillOrganica(124,"Organica Mind","2000-05-21",false));
> organicas.add(fillOrganica(125,"Organica Strength","2002-12-23",true));
> organicas.add(fillOrganica(126,"Organica Stamina","2011-06-14",true));
> organicas.add(fillOrganica(127,"Organica Luck","2006-02-01",false));
> organicas.add(fillOrganica(128,"Organica Love","2003-04-07", false));
> System.out.println(req.getParameter("lastUpdate"));
>
>
>
> return new Organicas<OrganicaMobileEntity>(organicas);
> }
>
> Wouldn't it be easier to make an annotation possible, to change the
> resource return method name?
>
>
> regards,
>
>
> On Mon, May 30, 2011 at 12:30 PM, Jakub Podlesak-2 [via Jersey]
> <[hidden email] </user/SendEmail.jtp?type=node&node=6419105&i=0>> wrote:
>
> Hi Maxrunner,
>
> I am afraid there is a bug in Jersey's JSON POJO mapping feature.
> It currently does not allow the application
> ContextResolver<ObjectMapper>
> to register different mappers for different types.
> Then if you want to set the root wrapping feature set for certain
> types, and unset for others, you are blocked, unless
> you register the Jackson providers directly.
>
> Let me check how can i fix that in the trunk.
>
> ~Jakub
>
>
> On 05/30/2011 11:54 AM, Maxrunner wrote:
>> But im using Jackson, anyway im going to post you my
>> contextresolver and web.xml configs, plus the classes that give
>> this result. Just give some minutes. :)
>>
>> regards,
>>
>>
>> On Sat, May 28, 2011 at 6:35 PM, Cowtowncoder [via Jersey]
>> <[hidden email]
>> <http://user/SendEmail.jtp?type=node&node=6418441&i=0>> wrote:
>>
>> On Sat, May 28, 2011 at 2:33 AM, Maxrunner <[hidden email]
>> <http://user/SendEmail.jtp?type=node&node=6414780&i=0>> wrote:
>> > That's what i get unless im doing something wrong...ill try
>> to post the full
>> > code when im back at work. Or ill try to get a run
>> environment here.
>>
>> Ok. It sounds as if maybe there is some configuration that
>> uses one of
>> other json producing methods.
>> I know that some conventions (badgerfish?) use more wrapping
>> around
>> things, mostly since these are needed for XML, and they go
>> through XML
>> api route where some information is missing.
>>
>> -+ Tatu +-
>>
>>
>> ------------------------------------------------------------------------
>> If you reply to this email, your message will be added to the
>> discussion below:
>> http://jersey.576304.n2.nabble.com/how-to-rename-XmlRootElement-in-JSON-tp6173292p6414780.html
>>
>> To unsubscribe from how to rename XmlRootElement in JSON,
>> click here.
>>
>>
>>
>> ------------------------------------------------------------------------
>> View this message in context: Re: how to rename XmlRootElement in
>> JSON
>> <http://jersey.576304.n2.nabble.com/how-to-rename-XmlRootElement-in-JSON-tp6173292p6418441.html>
>>
>>
>> Sent from the Jersey mailing list archive
>> <http://jersey.576304.n2.nabble.com/> at Nabble.com.
>
>
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the
> discussion below:
> http://jersey.576304.n2.nabble.com/how-to-rename-XmlRootElement-in-JSON-tp6173292p6418652.html
>
> To unsubscribe from how to rename XmlRootElement in JSON, click here.
>
>
>
> ------------------------------------------------------------------------
> View this message in context: Re: how to rename XmlRootElement in JSON
> <http://jersey.576304.n2.nabble.com/how-to-rename-XmlRootElement-in-JSON-tp6173292p6419105.html>
> Sent from the Jersey mailing list archive
> <http://jersey.576304.n2.nabble.com/> at Nabble.com.