This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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
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
I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.