• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

html:checkbox

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shankar,
If you use html:multibox, you can set the value to anything.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"/>'
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic