My requirement (not necessarily on text, but on select fields) is to force the jsp page to recalculate. Yes, this can all be done with javascript and hidden fields, but hiding and redisplaying with javascript is a pain and more logic that I care to put into a jsp.
Edgar -----Original Message----- From: Alvarado, Juan (c) [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 10, 2002 11:05 AM To: 'Struts Users Mailing List' Subject: RE: LookupDispatchAction onchange The LookupDispatchAction was designed with the intention of not having to use javascript to work with multiple submit buttons in one form. Since what you need is a submit from an onChange event in a text field which is a somewhat not often seen operation (at least from my experiences), you have no choice but to do the javascript in this case. Just our of curiosity, what requirement in your application do you have that needs the form to be submitted when a text field changes??? -----Original Message----- From: Cook, Graham [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 10, 2002 10:50 AM To: 'Struts Users Mailing List' Subject: RE: LookupDispatchAction onchange Thanks Andrew & Juan, thats very helpful. Its is a shame that I have to use JavaScript to achieve a submit from a text field. The other buttons on the screen use the <html:submit> tag, <html:submit property="doaction"> <bean:message key="button.savedetails"/> </html:submit> obviously theres no Javascript there, shame there isnt some way of doing this with a tag rather than having javascript code to do the submit. Thanks you for your help. -----Original Message----- From: Alvarado, Juan (c) [mailto:[EMAIL PROTECTED]] Sent: 10 December 2002 15:25 To: 'Struts Users Mailing List' Subject: RE: LookupDispatchAction onchange If I remember correctly the LookupDispatchAction does a reverse lookup on your resource bundle in order to determine which method to call in the class. Example: if you have a key in your ApplicationResources.properties called: textfield.changed=submit form then you would obviously need something like the following in the getKeyMethodMap: map.put("textfield.changed", "textFieldChangedMethod"); So when your text field changes, you will need to submit the parameter you configured for your LookupDispatchAction in struts-config.xml with the a value of 'submit form' What the action should do is do a reverse lookup on the ApplicationResources file and look for a value of 'submit form'. 'submit form' is associated with the key textfield.changed and it will cause the textFieldChangedMethod to be called in your class. Also, make sure you follow Andrew's suggestion about not using 'action' as the parameter name. This has the potential to cause your form to behave in a very weird manner. It caused me lots of headaches in the past until I figured out it was the parameter name I used was 'action'. If you need any more help on this let me know. Take care -----Original Message----- From: Andrew Hill [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 10, 2002 9:54 AM To: Struts Users Mailing List Subject: RE: LookupDispatchAction onchange 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:[EMAIL PROTECTED]] Sent: Tuesday, December 10, 2002 22:27 To: '[EMAIL PROTECTED]' 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:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>