My problem is setting up an initial value for a Radio field using Struts. In plain old HTML you could do something by adding a "checked" key word. With Struts there doesn't seem to be any "Checked" option.
With a "Select" I believe I can just assign "Value" to have my initial value; as read previously from a database (in the example its from the bean "account.") I believd this works ok.
<tr>
<td width="49%">Security Question</td>
<td width="43%">
<html:select property="securityQuestion" value="<%=account.getSecurityQuestionType() %>">
<html
ptions collection="securityquestions" property="questionText" />
</html:select>
</td>
</tr>
The problem is with Radio buttons. From everything I've read, I either that have to :
a) Set the form field value to whatever is desired and it will show up correctly. But my problem with this is that I don't see how to set it initially based on a session/request bean. I tried looking at the form "reset" method, checking for "" as an initial value and then setting it to the desired session bean value. But, my reset method wasn't being called by default. I obviously can't use my Perform Action method.
b) I've seen some servlet code that spits out real html. I'd like to solve this using Struts taglib.
<tr>
<td width="49%">Type of Account:</td>
<td width="43%">
<logic:iterate id="t" name="accounttypeset" type="java.lang.String">
<html:radio property="accountType" value="<%=t %>"/>
<%=t %>
</logic:iterate>
</td>
</tr>
Any thoughts out there?
I'm still a bit green in the Java/Stuts/JSP world but I've done a fair bit of hunting.
Thanks,
Howard