• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sending a List to another Action class

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

say i have a class box with two members (String color, int size) ... My Action1 creates a collection boxes read from a DB... I then need to send this to Form1.hsp as a request, then forward these boxes (collection/list) from Form1.jsp (or action1) to Action2 ... How can one do this?

Can 1 send a collection from one action to another?

PS. Action1 has mapping.findForward("action2"); and this works fine, but not the transferring of the list ... A code example would help...

Thanks in Advance
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The only thing HTTP requests can send to the server are strings. Period.

There are various options: store the list in the application or session context, re-create the list from request parameters, and so on.

If the list read from the DB is the same across the entire application storing it in the application context may make the most sense. If you want to send a list of values selected from that list, like a collection of select box options, all you can do is send, for example, the collection of IDs chosen.

In S2, type conversion can be used to re-create the actual objects represented by the collection of IDs, making it *appear* as though the request included actual objects--but they're being created from the strings sent by the browser.

So depending on what your actual requirements are there are a variety of solutions.
 
Songezo Nkukwana
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My attempt of using the session ...


Here's part of my first Action class



QualsAction is another action class. It also needs jobQuals list.

i tried getting this in QualsAction ...



PROBLEM: I get a NullPointerException sometimes ...For some reason the list is not always put on the session, or the casting isn't always working properly ..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic