This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Hi guys. I ve got an action class that calls an EJB that returns a list. I am storing that list in the request scope and getting it back in the front end
As you can see I also want to use a check box for deleting the elements in my collection. I am retrieving the values normally so there is not problem here. But the problem I am facing is that I need to have these values in a bean (Form) and call that form from another Action
But of course I am getting an error message that "clients could not be found in any scope". So how am I gonna call the Form that I want my selected values stored in and at the same time extracting the collection that I have stored from the previus Action servlet??
First of all, if you want to use attributes of the client bean in an <html:checkbox> tag, you need to add the collection of clients as an attribute to the ActionForm bean, rather than just storing it in the request.
Secondly, you need to code your JSP so that Struts will know you're using an indexed property. You can find the details on how to do this in this link. This includes adding an indexed getter (getClient(int index)) to your ActionForm.
Thirdly, you need to decide on how to deal with the ActionForm. If you change it's scope to session, the collection of clients will still be there when the form is submitted. If you want to keep it in the request, you are going to have to add code to your ActionForm to rebuild the collection of clients either in the indexed getter or in the reset() method. One option is to use the "LazyActionForm" as described in This link.