This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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...
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.
Joined: Nov 27, 2008
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 ..