Skip to Content
author's profile photo
Former Member

Web Service Model with ArrayList return value

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • author's profile photo
    Former Member
    May 09, 2004 at 03:46 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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