struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Hill" <andrew.david.h...@gridnode.com>
Subject RE: LookupDispatchAction onchange
Date Tue, 10 Dec 2002 14:54:13 GMT
Should be possible.
You may need to do something like appending a parameter to your forms action
url with a bit of javascript to simulate whats submitted by a button. Can't
remember the details for LookupDispatchAction since I havent used it, but
heres some js that will play with your forms action and append a parameter
named 'method' with value defined by useMethod.
Adapt as required. (nb: its modified from a similar script (which works with
DispatchAction rather than LookupDispatchAction) of mine for the purposes of
this reply and thus untested!)

<snip>
function submitBlah(useMethod)
{
    document.forms[0].action =
appendParameter(document.forms[0].action,'method',useMethod);
    document.forms[0].submit();
  }
}

function appendParameter(url, parameter, value)
{
  var delimeter = url.indexOf('?') == -1 ? '?' : '&';
  return url + delimeter + parameter + '=' + value;
}
</snip>

Having said all that I should point out that you might be able achieve a
similar effect using an appropriate hidden field too. Much simpler (though
doesnt work too well with multipart forms submitting to a DispatchAction).
If you try that be careful you dont submit 2 values for your property when a
button is clicked.

btw: Just looking at the javadocs for LDA. I see they use 'action' as the
name of their example parameter. Bad idea naming anything on a form
'action'. It will shadow the form.action property (which means above script
wont work for one thing). Same reason that naming a button 'submit' will
lead you into trouble when you later try to add a call to javascripts
form.submit() method...



-----Original Message-----
From: Cook, Graham [mailto:graham.cook@cgey.com]
Sent: Tuesday, December 10, 2002 22:27
To: 'struts-user@jakarta.apache.org'
Subject: LookupDispatchAction onchange


Is it possible to use an onchange event on a text input field to submit the
form to a LookupDispatchAction?

I have numerous buttons on the JSP page which submit the form to my
LookupDispatchAction, and work depending on what the value of the action is,
but i would like to also call my LookupDispatchAction from an onchange event
of a text field?

Anyone done this?


****************************************************************************
****************
" This message contains information that may be privileged or confidential
and
is the property of the Cap Gemini Ernst & Young Group. It is intended only
for
the person to whom it is addressed. If you are not the intended recipient,
you
are not authorized to read, print, retain, copy, disseminate, distribute, or
use
this message or any part thereof. If you receive this message in error,
please
notify the sender immediately and delete all copies of this message ".
****************************************************************************
****************


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