This week's book giveaway is in the Reactive Progamming forum. We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line! See this thread for details.
In Struts i've an action that initializes an Arraylist of JavaBeans
The bean Category includes atrributes such id, name, data and sign.
Once i'm in the jsp, i generate a combobox throught the <s:select> tag giving as list the catList array.
We can imagine the various option of the select box as different beans/objects, each with own attributes (id, name, data and sign). Once the user submits the form into the struts action, can i retrieve the entire Category bean that has been selected?
Actually i only pass the id as value, but i'm in doubt about this fact...
Luca Coraggio wrote:Once the user submits the form into the struts action, can i retrieve the entire Category bean that has been selected?
You get in the action what you send from the JSP, so in the case of the code above, you would get the Category ID. That's probably what you want because you will use the ID, not the entire category, to create a relationship in a database (i.e. add a line item to an invoice). Presumably you would then forward to an action that would display the newly created relationship (i.e. display the invoice with line items) but that should be a separate action, along the lines of what we discussed in your previous post
Ok, and if i use the entire javabean into the jsp, instead the key/value pair only? Is it possibile?
posted 5 years ago
Wait, i explain better my situation.
Into the action i generate an ArrayList that contains javabeans.
I iterate it into the jsp in this mode
Once i submit the form, i can't retrieve the values of the ArrayList that i've previously generated... It's like if the persistence is broken
The action that i call when the form is submitted, correctly have declared an ArrayList called listaArticoliCarrello, now i need to know how to pass it from jsp to the action
Luca Coraggio wrote:Ok, and if i use the entire javabean into the jsp, instead the key/value pair only? Is it possibile?
Yes. You will need to put each of the values above into a form tag, otherwise it is not submitted with the request (your code above just writes the values to the page).
Since you are using a collection, you will need to use indexed properties so Struts knows how to rebuild the collection.