I would say having three properties for the three buttons would be a cleaner
solution.  Relying on JavaScript anywhere you don't have to is asking for
trouble, IMO.

-----Original Message-----
From: Sobkowski, Andrej [mailto:[EMAIL PROTECTED]] 
Sent: Friday, November 02, 2001 3:49 PM
To: 'Struts Users Mailing List'
Subject: RE: Problem with multilingual submit button with request paramete
rs


Why don't you separate the value displayed from the action sent using a
Javascript method:

<script language="javascript">
function submitWithAction(action) {
  document.yourFormName.action.value=action;
}
</script>

<input type="hidden" name="action"> (this can be generated with
<html:hidden>)
<html:submit onclick="submitWithAction('Create');">
  <bean:message key="create" />
</html:submit>
<html:submit onclick="submitWithAction('Search');">
  <bean:message key="search" />
</html:submit>

Your buttons will be multi-language and the value of your hidden "action"
parameter will be a constant that you can reuse (and that is not tied to a
language).

Just my 2 cents...

Andrej
-----Original Message-----
From: Mark Gordon [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 02, 2001 4:51 PM
To: Struts Users Mailing List
Subject: Re: Problem with multilingual submit button with request
parameters


If you have three submit buttons for the same form only the submit 
button that is pressed will be sent as a parameter... i think.

so you could check for the existence of the parameter to find out what 
button was pressed.  The parameter name will not be localized just the 
value... and who cares what the value is because you only care if it exists.



Christian Rosner wrote:

> Hello struts experts,
> 
> I can't get a submit button to work which uses a <bean:message> for a
> localized button text _and_ a request parameter at the same time. I have
> browsed the mail archive, but haven't found a solution for this. Maybe one
> of you can tell me the way to achieve my goal:
> 
> A form on my page contains several submit buttons, which trigger different
> actions (like 'Create', 'Search' and 'Cancel'). To circumvent the problem
of
> a single action target in a form I did add a request parameter to each
> submit button (as suggested earlier in this mailing list):
> 
>   <html:submit property="action" value="search">
>     Search
>   </html:submit>
> 
> Because my application has to support different languages (like English
and
> German), I also use the <bean:message> tag to set the button text
according
> the Locale setting in the session:
> 
>   <html:submit>
>     <bean:message key="searchbutton"/>
>   </html:submit>
> 
> Each of the above code samples works well, like it's described in the
> documentation and as I expected it.
> 
> But if I try to combine both techniques to get a multilingual submit
button
> with a request parameter, like in:
> 
>   <html:submit property="action" value="search">
>     <bean:message key="searchbutton"/>
>   </html:submit>
> 
> it does not work: Instead of my desired result - a button with a (german)
> label 'Suchen', which submits a request parameter 'action=search' - I do
get
> a button labeled 'search' (with a lowercase 's'). The 'value' attribute
> seems to be used used twice _with a different meaning_.
> 
> The Struts <html> taglib guide says under 'Common Form Tag Attributes':
> 
> "value : Value of the label to be used with this element. This value will
> also be submitted as the value of the specified request parameter."
> 
> As far as I understand this sentence, it says that the 'value' attribute
is
> used twice for different purposes: For the label of the button and for the
> request parameter value.
> 
> Have I done something wrong or misunderstood something? Or is this a
slight
> design flaw in the i18n support (using the same attribute twice)? Does
> someone know a solution or workaround for this problem?
> 
> Regards
> 
> Christian Rosner
> Software Architect
> 
> 
> 
> --
> 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]>

Reply via email to