Kirk,
From: "Cameron Braid" <[EMAIL PROTECTED]>
I am not an expert on WW, though the normal way to deal with 'missing'
http data is to set a default value for the property and it can be
overridden by the request parameter...
i.e. if you set
protected boolean newsletter = false;
instead of true, then WW will call the setNewsletter(true) when the
checkbox is checked.
But the problem is I want the default to be true. I guess I
could have a hidden input value that set it to false so that
there is always at least one "newsletter" parameter passed to
the action, though it seems sort of hackish to me since it
has dependencies on the HTML form.
Is there a way to get the original parameter map? I looked at
the code for ActionSupport and it doesn't look like the map gets
saved. I suppose I could get the HttpServletRequest and look for
the parameter in there but it ties the action to the servlet API.
Is there a way to deal with this in a more generic fashion?
You could use Javascript to set another hidden variable like so:
Keep a hidden variable named "newletter" in the form:
<input type="hidden" name="newletter" value="true">
Attach some javascript to the checkbox that will set the value of the hidden
variable:
<input type="checkbox" onclick="handleClick(this,'newletter');">
<script language="JavaScript" type="text/javascript">
function handleClick(el,type) {
if (el.checked == 'true') {
el.form.elements[type].value = 'true';
}
else {
el.form.elements[type].value = 'false';
}
}
</script>
That way, the 'newletter' parameter will always be set correctly and should be
picked up and set by WW. The disadvantage to doing this is some people don't use
JavaScript which might mess up your form.
Hope that helps,
--Bill
-------------------------------------------------------
This SF.NET email is sponsored by: Order your Holiday Geek Presents Now!
Green Lasers, Hip Geek T-Shirts, Remote Control Tanks, Caffeinated Soap,
MP3 Players, XBox Games, Flying Saucers, WebCams, Smart Putty.
T H I N K G E E K . C O M http://www.thinkgeek.com/sf/
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork