Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 13th, 2005, 01:24 AM
Authorized User
 
Join Date: May 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default check box default value in struts form

Hi,

How do i mention the default status of the check box as true in a
struts form am using <html:checkbox>

Thanks in advance
Sri
__________________
Try Try Try Until You Succeed
 
Old July 1st, 2005, 06:53 AM
Registered User
 
Join Date: Jul 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Satishhhh
Default

Hi,
  In the ActionForm, create a boolean property for the checkbox and assign it as ture in the form reset method.

Thanks
Satish
 
Old January 15th, 2006, 11:08 PM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Satish,

Your proposed design does not work for checkboxes. Checkbox values are only submitted from the browser to the server if they are enabled. Therefore if the reset() method sets the form value to true, and the client unchecks the checkbox before submitting, there is no mechanism to set the form value to false.

I am mentioning this because I want to do the same thing as the original poster in my application. Originally I tried the solution you proposed here (though through my own hacking), and then I ran into the problem I just discussed. I'm not sure what the actual solution is yet.

Jon Emerson
http://slashdot.org/~panaceaa
 
Old January 15th, 2006, 11:13 PM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey... so the solution I'm going with is to just set the booleans to true in my Action if the request is not a form submission (e.g. an initial hit to the form). I wish there was a more declarative way of doing it, though ...

By the way, Struts, The Complete Reference by James Holmes (for Struts 1.2) confirms that checkbox values must be set to false in the reset() method.

Jon Emerson
http://slashdot.org/~panaceaa





Similar Threads
Thread Thread Starter Forum Replies Last Post
Struts 2 default language acgreen Struts 2 March 24th, 2008 08:07 AM
struts-html: checkbox default checked RatanKumar Struts 1 November 5th, 2007 05:49 AM
Zoom Box Default Settings SerranoG Access VBA 0 June 22nd, 2006 01:39 PM
Yes/No Check Box -- fills in "no" without default Quixote Access VBA 4 February 21st, 2005 06:25 PM
how to default confirm box to NO in javascript. An Javascript 1 June 8th, 2003 07:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.