You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Barry Volpe <st...@childrencare.com> on 2003/10/03 22:57:25 UTC

Initializing Form bean values in jsp

Hi,

I am trying to avoid duplicating the same form for the sake of two radio buttons.
I call (no actions) the following:

mypage.jsp?type=1;
or
mypage.jsp?type=2;

I can determine which parameter value is passed using:

<bean:parameter id="idType"
   name="type"
   value="type not found"/>

<bean:write name="idType"/>  The 1 or 2 is printed depending which jsp (above) is called.

You can view 1 as representing form 1 and 2 representing form 2.

Next I want to set the appropriate radio button based on this value.
I am using DynaValidatorForm in this case (initializing in the struts-config won't work).

I can get the Formbean in my jsp using:

<bean:struts id="myForm"
   formBean="myDynaForm"/>

NOW WHAT I DON'T KNOW HOW TO DO IS INITIALIZE THE 
"my radio" so it is displayed as selected.

<html-el:radio property="myradio" value="state1"/>  
<html-el:radio property="myradio" value="state2"/>  
 
AGAIN I AM NOT CALLING THE JSP FROM AN ACTION SO INITIALIZING THE
DYNAFORM BEAN IN STRUTS-CONFIG WILL NOT WORK.

IS THIS POSSILBE DO I HAVE THE "HOOKS" ABOVE TO DO THIS?

thanks,
Barry