Re: How do I make a checkbox initially checked?

2007-07-08 Thread Fred Toth

Hi,

Yes, it works fine if I use prepare() and create my own object. However, 
my understanding
from the docs was that struts would create my object for me, based on 
hitting a null pointer.

But that does not seem to be the case.

Also, if I use the value=true method, then my box is checked always, 
regardless of user input.


Thanks,

Fred

Nuwan Chandrasoma wrote:

Hi,

If you want the check box to be checked initially you can use the tag 
like this:


s:checkbox name=user.sendEmail value=true/

are you calling the prepare method to initialized you backing object?, 
according to my understanding the backing object will not be created 
and initiallized if you havent done in the prepare method, the form 
well be render on the page and when you click the submit buttion. a 
backing objected will be created and the values entered on the form 
will be set the object.


Thanks,

Nuwan.




- Original Message - From: Fred Toth [EMAIL PROTECTED]
To: Struts Users Mailing List user@struts.apache.org
Sent: Saturday, July 07, 2007 9:11 PM
Subject: How do I make a checkbox initially checked?



Hi again,

I'm working on a form where a particular checkbox should be initially
checked when the form first comes up.

None of the options in s:checkbox seem to support this.

I tried to have my backing object initialized with the particular 
Boolean set
to true, but struts doesn't seem to actually create my object 
(counter to the docs),

until submission time.

If I have:

s:checkbox name=user.sendEmail/

The docs say that if user doesn't exist (which is the case on initial 
display of the form),
OGNL will get a null value, and struts will create a user object. 
This doesn't seem

to be happening.

Is there a way to do this using the UI tags?

Thanks,

Fred


-
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]





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



How do I make a checkbox initially checked?

2007-07-07 Thread Fred Toth

Hi again,

I'm working on a form where a particular checkbox should be initially
checked when the form first comes up.

None of the options in s:checkbox seem to support this.

I tried to have my backing object initialized with the particular 
Boolean set
to true, but struts doesn't seem to actually create my object (counter 
to the docs),

until submission time.

If I have:

s:checkbox name=user.sendEmail/

The docs say that if user doesn't exist (which is the case on initial 
display of the form),
OGNL will get a null value, and struts will create a user object. This 
doesn't seem

to be happening.

Is there a way to do this using the UI tags?

Thanks,

Fred


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



Re: How do I make a checkbox initially checked?

2007-07-07 Thread Nuwan Chandrasoma

Hi,

If you want the check box to be checked initially you can use the tag like 
this:


s:checkbox name=user.sendEmail value=true/

are you calling the prepare method to initialized you backing object?, 
according to my understanding the backing object will not be created and 
initiallized if you havent done in the prepare method, the form well be 
render on the page and when you click the submit buttion. a backing objected 
will be created and the values entered on the form will be set the object.


Thanks,

Nuwan.




- Original Message - 
From: Fred Toth [EMAIL PROTECTED]

To: Struts Users Mailing List user@struts.apache.org
Sent: Saturday, July 07, 2007 9:11 PM
Subject: How do I make a checkbox initially checked?



Hi again,

I'm working on a form where a particular checkbox should be initially
checked when the form first comes up.

None of the options in s:checkbox seem to support this.

I tried to have my backing object initialized with the particular Boolean 
set
to true, but struts doesn't seem to actually create my object (counter to 
the docs),

until submission time.

If I have:

s:checkbox name=user.sendEmail/

The docs say that if user doesn't exist (which is the case on initial 
display of the form),
OGNL will get a null value, and struts will create a user object. This 
doesn't seem

to be happening.

Is there a way to do this using the UI tags?

Thanks,

Fred


-
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]



Re: checkbox initially checked?

2005-08-04 Thread Swapnil Patil
Hi ,
As Wendy has mentioned-

Otherwise, the place to do this is in your Action, before you forward to the
JSP.

I am interested in populating Form before loading jsp page so that I can 
assign values to HTML comtrols.
HOw to do that?

On 8/4/05, Wendy Smoak [EMAIL PROTECTED] wrote:
 
 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]
 



Re: checkbox initially checked?

2005-08-04 Thread Dave Newton

Swapnil Patil wrote:


Otherwise, the place to do this is in your Action, before you forward to the
JSP.

I am interested in populating Form before loading jsp page so that I can 
assign values to HTML comtrols.

HOw to do that?
 


In your Action, before you forward to the JSP???

Wow, that was spooky... it's alsmot as though you answered your own 
question before you even asked it.


I wish I could do that.

Dave



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



RE: checkbox initially checked?

2005-08-04 Thread Chris Decker
Thanks it worked!  Actually had List of Objects I was forwarding.  And in my 
action class I just did the following as I was building the list 

Object.setSelected(true);

Where the Object class had a boolean called selected. 

 

-Original Message-
From: Dave Newton [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 04, 2005 12:11 PM
To: Struts Users Mailing List
Subject: Re: checkbox initially checked?

Swapnil Patil wrote:

Otherwise, the place to do this is in your Action, before you forward 
to the JSP.

I am interested in populating Form before loading jsp page so that I 
can assign values to HTML comtrols.
HOw to do that?
  

In your Action, before you forward to the JSP???

Wow, that was spooky... it's alsmot as though you answered your own question 
before you even asked it.

I wish I could do that.

Dave



-
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]



Html: checkbox initially checked?

2005-08-03 Thread Chris Decker
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!
Chris Decker



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



Re: Html: checkbox initially checked?

2005-08-03 Thread erikweber
If memory serves me, the way to do this is in your ActionForm's reset method. 
This is where default values are specified when the form is initialized or 
reinitialized.

Erik


-Original Message-
From: Chris Decker [EMAIL PROTECTED]
Sent: Aug 3, 2005 4:58 PM
To: Struts Users Mailing List user@struts.apache.org
Subject: Html: checkbox initially checked?

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!
Chris Decker



-
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]



Re: checkbox initially checked?

2005-08-03 Thread Wendy Smoak

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]



Re: checkbox initially checked?

2005-08-03 Thread erikweber
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]