This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Retaining value of checkbox on the form

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
rubbery bacon. crispy tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic