On Thu, 21 Nov 2002, Andy Kriger wrote:
> Date: Thu, 21 Nov 2002 18:43:30 -0500 > From: Andy Kriger <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]> > To: Struts Users Mailing List <[EMAIL PROTECTED]> > Subject: how do i set a checkbox as checked w/o referring to a bean? > > I want to have a checkbox use the HTML checked attribute. I want to do this > without referring to a bean or a property or a value, separate from the > Struts architecture (except that I still want to have Struts fill in my form > values). Is it possible? > Not without using a form bean. > I have tried many things. In the form object, I set the field's default > value to "true", but this meant that the field was always checked - if the > form was submitted with the box unchecked and there was an error, the box > would be checked again when the user returned to the form. > > I cannot figure out how to have a box selected the 1st time the page loads > and then use the user's setting after that (without getting tangled up in > the form object). The recommended practice is to have an action pre-populate the form bean with the values to be displayed, then forward to the page that displays the form (and will therefore use the form bean that already exists). The submit from the form will typically go to a different action that performs the appropriate business logic. The struts-example webapp that ships with Struts uses this technique, if you want a working example. If you don't want to use form beans, then you will not find <html:form>, and the input field tags nested in it, to be of much use. > > Any help? > > thx > andy > Craig -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

