You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "C.F. Scheidecker Antunes" <na...@antunes.eti.br> on 2005/08/29 23:11:51 UTC

check radiobutton option based on value posted to the session 2

Hello all,

I have a radiobutton group called categID. Once the form is submited it 
goes to the following form bean:

*<form-bean* name="catForm" type="org.apache.struts.action.DynaActionForm"*>*
    	*<form-property* name="categID" type="java.lang.String"*/>*
    *</form-bean>*


That is the catForm has an attribute called categID with the value posted.
This is a DynaActionForm that resides on the session scope.

Once the form is submited I need to show the radio group again on the 
next page with the one selected already checked.
How can I check this DynaActionForm from the session on the JSP and see 
if the corresponding radiobutton is to be checked or not?

My JSP is as follows:

<logic:iterate id="row" name="rowCatSet" property="rows">      <tr>
        <td width="6%" bgcolor="#FFFFCC"><input name="cat_ID" 
type="radio" value="<bean:write name="row" property="catID"/>"></td>
        <td bgcolor="#FFFFCC"><span class="style32"><bean:write 
name="row" property="Title"/></span></td>
    </tr>
</logic:iterate>

The problem is that I am already iterating a bean to fill up the value 
of the radiobuttons. If I am to use the <html:radio/> tag
then I would need a way to have the bean row catID property value inside 
the tag. How can I accomplish it?

Thanks,

C.F.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: check radiobutton option based on value posted to the session 2

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "C.F. Scheidecker Antunes" <na...@antunes.eti.br>

> Once the form is submited I need to show the radio group again on the next
> page with the one selected already checked.
> How can I check this DynaActionForm from the session on the JSP and see if
> the corresponding radiobutton is to be checked or not?

You shouldn't have to... if you use the Struts tags, the framework will
automatically render the correct radio button as "on".  Is the second page
using the same session-scoped form bean?

> <logic:iterate id="row" name="rowCatSet" property="rows">
>    <input name="cat_ID" type="radio" value="<bean:write name="row"
> property="catID"/>">
>    <bean:write name="row" property="Title"/>
> </logic:iterate>
>
> The problem is that I am already iterating a bean to fill up the value of
> the radiobuttons. If I am to use the <html:radio/> tag
> then I would need a way to have the bean row catID property value inside
> the tag. How can I accomplish it?

I'd do it with Struts-EL and JSTL... I can only find a multibox example at 
the moment:

    <c:forEach items="${accountMap}" var="item" >
       <html-el:multibox property="accounts" value="${item.key}"/>
       <c:out value="${item.key}"/>
    </c:forEach>

I haven't used it, but the docs say there is an 'idName' parameter for 
<html:radio> that might be useful.  As usual, I can't quite work out what 
value you should use for the attribute:  "When the idName attribute is 
present, the value attribute is used as the name of the property on the 
idName bean that will return the value of the radio tag for this iteration."

   http://struts.apache.org/userGuide/struts-html.html#radio

-- 
Wendy Smoak



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org