cancel
Showing results for 
Search instead for 
Did you mean: 

Web Service Model with ArrayList return value

Former Member
0 Kudos

Hi,

I wrote a session bean method that returns an java.util.ArrayList.

Then I generated a web service for this session bean and imported this web service into a Web Dynpro model.

I can then execute this web service model and get the ArrayList in the method result (means in the result of the model instance) but I cannot bind this model to e.g. a table control with the following error message:

"ContextAttribute has JavaNativeType ArrayList. ContextAttribute with java native type cannot be selected."

This is o.k. so far but is there a way (workaround) to use any collection class as result of my web service method?

Background: Normally I´m and many users work with the java collection framework. At the moment I have to convert the Collection into an array with the following construct and return the array.

MyType[] tmp = new MyType[1];

return (MyType[])list.toArray(tmp);

When I then create a model in Web Dynpro the members of MyType are generated as model attributes.

This works but is not the way I would like to work. I would prefer to work with my Collection class.

Thanks for an answer

Helmut

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Helmut,

i guess, collections cannot be used for model binding, since they may contain different kinds of objects. As you know for sure, this is not the case for model- and value nodes, their entries are restricted to one element "type". So from my point of view the only workaround is to convert collections into arrays, like you're already doing it.

Best regards

Stefan

htammen
Active Contributor
0 Kudos

Hi Stefan,

thank you for your answer. My question was more thought as a suggestion.

When using the Value Objects Pattern in J2EE applications I use the same value object class at server (EJB) and client side (web app.) by utilizing the same class file.

If I could do the same with Web Dynpro models (declarativly tell the model wich class to use) this would be great, wouldn´t it?

Regards Helmut