• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

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 ]
 
passwords must contain 14 characters, a number, punctuation, a small bird, a bit of cheese and a tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!