You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jerry Jalenak <Je...@LABONE.com> on 2003/10/29 17:44:02 UTC

[OT - JavaScript] Setting value on a

Been screwing around with this all morning, and can't seem to find an
answer.....

I've got two radio buttons on a form.  If the user clicks the second radio
button, I need to force the value of a following <html:select/> to a
specific value, and disable the select.  So, using JavaScript, on my radio
button I fire an onclick event that run a real simple javascript function.
In this function I've tried using 

	document.formName.selectVar.value = <default value>	// is
accepted, but the <default value> isn't passed to my form bean
	document.formName.selectVar.option[0].selected = true	//  ditto
	document.formName.selectVar.option[0].value = <default value>
// ditto
	document.formName.selectVar.option[0].isSelected = true		//
ditto

JavaScript seems to accept all of these formats, but the setter method in my
form bean for 'selectVar' is never getting called.  This is going to be a
'Doh!' moment, but how do I do this?

TIA!

Jerry Jalenak
Development Manager, Web Publishing
LabOne, Inc.
10101 Renner Blvd.
Lenexa, KS  66219
(913) 577-1496

jerry.jalenak@labone.com


This transmission (and any information attached to it) may be confidential and
is intended solely for the use of the individual or entity to which it is
addressed. If you are not the intended recipient or the person responsible for
delivering the transmission to the intended recipient, be advised that you
have received this transmission in error and that any use, dissemination,
forwarding, printing, or copying of this information is strictly prohibited.
If you have received this transmission in error, please immediately notify
LabOne at the following email address: securityincidentreporting@labone.com


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


RE: [OT - JavaScript] Setting value on a

Posted by James Mitchell <jm...@apache.org>.
Not sure, but this may be what you need: (change to your liking)


<form name="frm" action="somewhere.go" method="GET">

<script LANGUAGE="JavaScript">
function forceSelect(form, val, bDisabled){
	selectCtl = form.elements["something"];
	selectCtl.selectedIndex=val;
	selectCtl.disabled=bDisabled;
}

</script>
<br>
<input type="radio" name="myRadio" value="val1"
onClick="forceSelect(this.form, 0, false)">Val 1<br>
<input type="radio" name="myRadio" value="val2"
onClick="forceSelect(this.form, 1, true)">Val 2<br>

 <select name="something">
  <option value="">- Select One -</option>
  <option value="value1">value1</option>
  <option value="value2">value2</option>
  <option value="value3">value3</option>
 </select>
<input type="submit" name="submit" value="Submit">

</form>






--
James Mitchell
Software Engineer / Struts Evangelist
http://www.struts-atlanta.org
678.910.8017 (c)
770.822.3359 (h)
AIM:jmitchtx




> -----Original Message-----
> From: Jerry Jalenak [mailto:Jerry.Jalenak@LABONE.com] 
> Sent: Wednesday, October 29, 2003 11:44 AM
> To: 'struts-user@jakarta.apache.org'
> Subject: [OT - JavaScript] Setting value on a <html:select/>
> 
> 
> Been screwing around with this all morning, and can't seem to find an
> answer.....
> 
> I've got two radio buttons on a form.  If the user clicks the 
> second radio
> button, I need to force the value of a following <html:select/> to a
> specific value, and disable the select.  So, using 
> JavaScript, on my radio
> button I fire an onclick event that run a real simple 
> javascript function.
> In this function I've tried using 
> 
> 	document.formName.selectVar.value = <default value>	// is
> accepted, but the <default value> isn't passed to my form bean
> 	document.formName.selectVar.option[0].selected = true	
> //  ditto
> 	document.formName.selectVar.option[0].value = <default value>
> // ditto
> 	document.formName.selectVar.option[0].isSelected = true	
> 	//
> ditto
> 
> JavaScript seems to accept all of these formats, but the 
> setter method in my
> form bean for 'selectVar' is never getting called.  This is 
> going to be a
> 'Doh!' moment, but how do I do this?
> 
> TIA!
> 
> Jerry Jalenak
> Development Manager, Web Publishing
> LabOne, Inc.
> 10101 Renner Blvd.
> Lenexa, KS  66219
> (913) 577-1496
> 
> jerry.jalenak@labone.com
> 
> 
> This transmission (and any information attached to it) may be 
> confidential and
> is intended solely for the use of the individual or entity to 
> which it is
> addressed. If you are not the intended recipient or the 
> person responsible for
> delivering the transmission to the intended recipient, be 
> advised that you
> have received this transmission in error and that any use, 
> dissemination,
> forwarding, printing, or copying of this information is 
> strictly prohibited.
> If you have received this transmission in error, please 
> immediately notify
> LabOne at the following email address: 
> securityincidentreporting@labone.com
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


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


Pre-populating html:select from request object

Posted by Leon King <le...@mci.com>.
I'm trying to pass data between different struts forms.  Below I've tried to
pre-populate a select statement from data stored in the request but I get a
compilation error (" Attribute outageEndDateFromMonth has no value " ).

<html:select property="outageEndDateFromMonth" value="<%=
request.getAttribute("outageEndDateFromMonth") %>" >
        <html:options collection="monthList" property="value"
labelProperty="label" />
</html:select>


Any suggestions on how this can be achieved?

Thanks

Leon


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


Exception handling 100% declarative

Posted by Jim Kennedy <ji...@gigaheads.com>.
I would like to be able to customize the output when an exception is thrown with minimal or no extra overridden classes.  My struts config (1.1) config file looks like this:

....

<global-exceptions>
<exception 
    key="error.persistence.create" 
    type="javax.ejb.CreateException" 
    path="/tmpl_main.jsp?page=/error/syserror.jsp"></exception>
<exception 
    key="error.http.methodnotsupported" 
    type="javax.mail.MethodNotSupportedException" 
    path="/tmpl_main.jsp?page=/error/syserror.jsp"></exception> 
<exception 
    key="error.naming.namenotfound" 
    type="javax.naming.NamingException" 
    path="/tmpl_main.jsp?page=/error/syserror.jsp"></exception>
<exception 
    key="error.servlet.illegalparameter" 
    type="com.je.servlet.IllegalParamsException" 
    path="/tmpl_main.jsp?page=/error/syserror.jsp"></exception>
</global-exceptions>


The properties file looks like this:

errors.header=The following system errors occurred:<ul>
errors.footer=</ul>
error.persistence.create=An error occurred attempting to create a database record
error.http.methodnotsupported=This type of request is not supported for this URL
error.naming.namenotfound=Lookup failed with naming service
error.servlet.illegalparameter=A required field or parameter is missing for the request


The syserror.jsp file is simply:

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<TABLE border="0" cellpadding="5">
<TR>
<TD><html:errors bundle="systemerrorbundle" /></TD>
</TR>
<TR>
<TD></TD>
</TR>
</TABLE>

The above does work.  But I only get the properties file message printed.  I would like to do something like this:

error.servlet.illegalparameter=A required field or parameter is missing for the request {0}

so that I can dynamically generate a message specific to the error.  In this case I want to display whatever field is identified by the exception. So if the exception is thrown like:

throw new IllegalParamsException("fieldXYZ is missing");

I would like to see "A required field or parameter is missing for the request 'fieldXYZ is missing' "
Can I do this 100% in a declaritive manner?  Or how can I pull this off.

thanks

Re: [OT - JavaScript] Setting value on a

Posted by Melissa L Kelley <st...@stuology.net>.
On Wed, 29 Oct 2003, Jerry Jalenak wrote:

> I've got two radio buttons on a form.  If the user clicks the second radio
> button, I need to force the value of a following <html:select/> to a
> specific value, and disable the select.  So, using JavaScript, on my radio
> button I fire an onclick event that run a real simple javascript function.
> In this function I've tried using

[...]

When you say "disable the select", are you using the disabled attribute
for the select tag to accomplish this? If so, then the value of that form
element will not be sent with the HTTP request. If you want them to not
change it, set it to readonly instead of disabled.


> 'Doh!' moment, but how do I do this?
>
> TIA!
>
> Jerry Jalenak



------------------------------
Melissa L Kelley
stu.strutsusers@stuology.net
www.stuology.net
------------------------------



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