Hi Eric,
On 07/07/2011 08:31 PM, Eric Reagan wrote:
> Hello,
> I am using Jersey for as my front end client and I am getting a
> weird return result. I have a web service that has
>
>
> public ListWrapper getPeople(....){....}
i guess you want to specify the wrapped type here, something like:
public ListWrapper<Person> getPeople() {...}
>
> and my ListWrapper is
>
> @XmlType
> @XmlRootElement
> public ListWrapper<T>
> {
> ...... constructor (both default and to set a list)....and a
> list setter....
> T getList();
just to be clear we are on the same page:
public ListWrapper<T> {
List<T> myList;
public ListWrapper() { this(new LinkedList<T>());}
public ListWrapper(List<T> list) { myList = list; }
public List<T> getList() { return myList;}
public void setList(List<T> list) { myList = list; }
}
> }
>
> When I do
> ListWrapper lw = webResource.get(ListWrapper .class,
> QueryParams)
You should be doing the following instead:
ListWrapper<Person> lw = webResource.get(new
GenericType<ListWrapper<Person>>(){});
for (Person p : lw.getList()) ...
Does it help?
~Jakub
> for(Object obj : lw.getList())
> {
> o.cast(MyObjectClass.class)
> }
>
> I get a class cast exception in my GUI code because the list I created
> in my ListWrapper is a list of ElementNSImpl not a list of MyObject .
> When I browse to my web service with firefox I see all of the data I
> would be expecting to get from MyObject. Is there an easy way to
> reconfigure Jersey to put in the MyObject class instead of the
> ElementNSImpl?
>
> Thank you,
>
>
> --
> Eric Reagan