Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Retaining value of checkbox on the form

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?
<pre name="code" class="core">public SomeObject getCList(int index)</pre>
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.
[ July 16, 2008: Message edited by: Merrill Higginson ]
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic