This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using checkbox/multibox to delete items from a list

 
sonusgr sonusgr
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

something like





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??

Any reply is highly appreciated.

Thanks
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
sonusgr sonusgr
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the info
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic