struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Reumann <strut...@reumann.net>
Subject Re: LookupDispatchAction (Bug?)
Date Tue, 15 Mar 2005 19:30:42 GMT
Tim Christopher wrote the following on 3/15/2005 1:46 PM:

> I have the following code within a jsp:
> 
> <html:submit property="dispatch">
>     <bean:message key="button.update"/>
> </html:submit>
> 
> When the user clicks on the 'Update' button it goes off and updates
> the record as you would expect.
> 
> The problem I'm having is that every time the user presses the 'enter
> key' to submit the form it results in an error:
> 
> Request[/secure/admin/programmeAction] does not contain handler
> parameter named 'dispatch'.  This may be caused by whitespace in the
> label text.

First off are you sure that's your only submit button on the form? If 
you have more than one button, I believe enter will use the first one it 
comes to.

Assuming that the update button is the only button, I vaguely 
remembering running into an issue like this once before. The way I ended 
up fixing this is I now like to use Javascript to set my dispatch 
property. By default I have a default one set up on the page:

<input type="hidden" name="dispatch" value="update"/>

(You could even make this a form bean property if you want and have it 
set up in your action so it could be more dynamic:
<html:hidden property="dispatch"/>  assuming you have a dispatch 
property in your form bean and set it to a default value somewhere)

Then if you have other buttons on the page that need to change the 
dispatch value I just use javascript:

<html:submit 
onclick="document.yourForm.dispatch.value='someMethod'"><fmt:message 
key='button.fooBar'/></html:submit>

(Above would be more clean if you use a resuable javascript method to 
set the dispatch property)

-- 
Rick

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


Mime
View raw message