• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Using checkbox/multibox to delete items from a list

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.

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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the info
An elephant? An actual elephant. Into the apartment. How is the floor still here. Hold this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic