problem in radio button

hi e1,

I am sorry,i didn't find appropiate foum for struts so i pasted my post here

I am using struts and have radio button on jsp page with <html:radio>

Since struts radio tag does not have attribute selected,so i am facing problem in making default radio button as selected.

I google searched and found it was possible with the help of action form but didnot understand how cm.

Also I am not using ActionForm but DynaAction.

thanks....

Thanks....

[504 byte] By [harrriiiia] at [2007-11-27 7:53:33]
# 1

[nobr]Please,check out the following snippet that illustrates the basic usage of the radio tag:

<html:form action="/register"/>

Male: <html:radio property="gender" value="male"/><br>

Female: <html:radio property="gender" value="female"/><br>

<html:submit/>

</html:form>

This tag will look up the Form Bean associated with the Action specified by the form tag抯 action attribute and then call the getter method for the field specified by this tag抯 property attribute. If the field抯 value matches the value specified with the value attribute, the radio button will be selected.

say in your DynaActionForm you have a property called "gender" of type =java.lang.String

if your previous action has something like

((DynaActionForm)form).set("gender","male");

then in the present page you would see the radio button male to be selected by default.

Hope that might help :)

REGARDS,

RaHuL[/nobr]

RahulSharnaa at 2007-7-12 19:34:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
sorry sirit didn't workone thing which confused me tht what is previous action u specified in your reply.Did u mean the ActionForward method of action class which the action is referring to Thanks for your time
harrriiiia at 2007-7-12 19:34:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

yeah i was refering to the method inside the Action Class which has redirected you to the current page.

for example

public ActionForward execute(ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response)

throws Exception {

-

-

((DynaActionForm)form).set("gender","male");

-

-

return new ActionForward(<CURRENT_JSP_PAGE>);

}

RahulSharnaa at 2007-7-12 19:34:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Thank you very much sir for helping to solve itU will be counting you share of dukes soon
harrriiiia at 2007-7-12 19:34:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...