I should have distinguished between session-scoped and request-scoped forms. It 
is true that implementing reset would be redundant in a request-scoped form.

Erik


-----Original Message-----
From: Wendy Smoak <[EMAIL PROTECTED]>
Sent: Aug 3, 2005 5:28 PM
To: Struts Users Mailing List <user@struts.apache.org>
Subject: Re: checkbox initially checked?

From: "Chris Decker" <[EMAIL PROTECTED]>

> New to struts so sorry for the simple questions.
> I have a html: checkbox struts tag and I want to have the checkbox
> checked initially similar to the checked attribute in a traditional
>  INPUT statement.
> Can you do this?  I've looked everywhere!

If it's a dynamic form, you can set a default value in struts-config.xml:

<form-bean      name="contactForm"
                  type="edu.example.ContactForm">
      <form-property name="onHoldFlag"
                               type="java.lang.Boolean" initial="true"/>
  </form-bean>

Otherwise, the place to do this is in your Action, before you forward to the
JSP.  You only need to set the default the first time the form is displayed.
Exactly where and how depends on how you've written the app-- do you have a
'setup' action that's separate from the one that handles form submission?

The reset method is not the place to set defaults.  In fact, you will need
to set that checkbox to false/off in the form's reset method.  If you don't,
you will find that there is no way for the user to to un-check it.

A couple of checkbox links from the FAQ:
http://struts.apache.org/faqs/newbie.html#checkbox
http://struts.apache.org/faqs/newbie.html#reset

-- 
Wendy Smoak


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to