• 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

Struts - Default radio value

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all -
I have a list of items in a JSP. An item can be selected by clicking its radio button. The value of each radion button is the id of its associated item. How can I have the first item pre-selected on initial display of the JSP?
An example in Mastering Jakarta Struts suggests that I need to set the property in the associated ActionForm. Is the ActionForm available at this point? How do I get it? Is this the best way to do this? In general how do you (dynamically) set defaults for html controls in Struts?
Thanks in advance,
Mars
 
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would set the property in the action form, which is available to the jsp when you configure the struts-config.xml properly and use the formbean in the jsp via a html:form tag.
The examples should show you how to do the xml and the tag.
I would use the Action to set the radio property's default value. In the Action you can determine whether the jsp is being called for the first time (and so set the default) or whether it's being called again due to validation failure etc. (in which case you would want to leave the radio property in the formbean, which would be just how the user submitted it).
Adam
 
Marcellus Tryk
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Adam, I'll give it a try.
Mars
 
reply
    Bookmark Topic Watch Topic
  • New Topic