• 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 ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Retaining value of checkbox on the form

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an array of checkboxes in my JSP. I am doing a validation that only two of these boxes can be selected but after the validation when the page shows all the checkboxes show as unchecked. How can I retain the value of the checkboxes in the form?

My code is posted below
<logic:iterate id="cList" name="cActionForm" property="cList" indexId="cListIndex">
<td><html:checkbox styleClass="checkRowsCheckbox" styleId="chkRow${cListIndex}" name="cList" property="checked" indexed="true" value="${cListIndex}"/></td>
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, there's an administrative matter you need to attend to:

The name you are currently displaying with your posts does not meet the requirements of the JavaRanch naming policy. Specifically, it requires that you use a first and last name that is not obviously fictitions. You can use the my profile link to change it.

Please change it before your next post.

Regarding your question:

Have you provided an indexed getter in the ActionForm with the following signature?
<blockquote>code:
<pre name="code" class="core">public SomeObject getCList(int index)</pre>
</blockquote>
Where SomeObject is the object the list contains.

Furthermore, have you provided lazy initialization behavior for this getter? The following link explains more about this.

http://wiki.apache.org/struts/StrutsCatalogLazyList
[ July 16, 2008: Message edited by: Merrill Higginson ]
 
Your mother is a hamster and your father smells of tiny ads!
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic