struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Childers" <jchild...@hotels.com>
Subject RE: HTML Checkbox...
Date Tue, 14 Jan 2003 22:31:37 GMT
Check the archives. This is another one of those questions that gets asked (and answered) frequently.

http://nagoya.apache.org/eyebrowse/SearchList?listName=struts-user@jakarta.apache.org

Or try the JGuru Struts FAQ:

http://www.jguru.com/faq/printablefaq.jsp?topic=Struts

The short answer is: You're trying to set this in the wrong place. IMO, you should be setting
the default value of your form items in your ActionForm, not the JSP tag.

Ex:

public class YourForm extends ActionForm {
	private String someCheckBox = "true";	// This sets the default value

	// getters and setters for same; will get called after form submission

	public void reset() {
		someCheckBox = "false";			// Need this here to handle submission of unchecked boxes
	}
}

In your JSP:

<html:form action="someAction"> <!-- This Action, of course, uses YourForm -->
	<html:checkbox property="someCheckBox" /> <!-- Will be checked since you set it
to true in your ActionForm -->
</html:form>

-= J

> -----Original Message-----
> From: John Bateman [mailto:jbateman@tinyntubby.com]
> Sent: Tuesday, January 14, 2003 3:51 PM
> To: Struts Users Mailing List
> Subject: HTML Checkbox...
> 
> Hi
> 
> I read the docs but I can't seem to find a way to render this button 
> 'checked' when I try and display it.
> 
> I've tried:
> 
> <html:checkbox name="something" value="true"/>
> <html:checkbox name="something" value="yes"/>
> <html:checkbox name="something" value="YES"/>
> 
> And neither of them work.
> 
> Thanks
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: 
> <mailto:struts-user-help@jakarta.apache.org>
> 
> 

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message