Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html:checkbox

 
Shankar Narayana
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In regular HTML checkbox, the value of the checkbox can practically be
anything but the struts html:checkbox limits us to just yes/true/on
values?

If I have a list of records that I get from the database and I want to
display it with a checkbox at the left, the value of the checkbox being
the id of the record, how do I do that? Should there be another hidden
field for the checkbox with the actual value? And how do I connect the
checkbox to its corresponding hidden field?

Thanks
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should there be another hidden
field for the checkbox with the actual value? And how do I connect the
checkbox to its corresponding hidden field?


Why you use hidden field ???

I think, After render to html is like this

<input type="checkbox" name="test" value="1">

you can keep name, value any time.

 
Shankar Narayana
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think, After render to html is like this

<input type="checkbox" name="test" value="1">

you can keep name, value any time.



Struts says that the value should be a string (true/yes/on),and if the value doesn't return any of these values , I hope it is an error and moreover on editing this page , how does the struts tag know which
checkbox to be checked, if the value is and integer constant.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shankar,
If you use html:multibox, you can set the value to anything.
 
Girish Varde
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have used checkBox and not multiBox. I have not faced any restriction on th value passed by the checkBox. I have used bean:write and passed value from database.
value='<bean:write name="leads" property="leadId"/>'
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic