struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Mitchell" <jmitc...@telocity.com>
Subject RE: Internationalization and <html:submit
Date Fri, 19 Apr 2002 20:59:43 GMT
I can think of 4 ways I might approach this:

1. Have you thought about using different actions to determine which button
was pushed?

Example:
<html:form action="/terms/accept">
  <html:submit>
    <bean:message key="terms.accept"/>
  </html:submit>
</html:form>
<html:form action="/terms/cancel">
  <html:cancel>
    <bean:message key="terms.decline"/>
  </html:cancel>
</html:form>

Then you would execute whatever you needed in the individual action classes.
*the only problem with this is that it draws your button vertical and not
side by side (that's html limit, not struts)

2. What about using the i18n format for submit and then checking within the
action class (similar to your action code but getting the correct i18n
string to test.

(within the jsp)
<html:form action="/terms">
  <html:submit>
    <bean:message key="terms.accept"/>
  </html:submit>
  <html:cancel>
    <bean:message key="terms.decline"/>
  </html:submit>
</html:form>


3. JavaScript - Use JavaScript to set a hidden html field that you name
"action" to "Accept" or "Decline", then submit the form.  (don't use
property="action" in your html:submit) This way, you can validate with:
(code from your original email)
> if (action.equals("Accept")){
> 	returnPage = "accept";
> }
> else{
>       returnPage = "cancel";
> }


4. Hack - by default the way the html:cancel is used, if the user chooses to
click the cancel button, then struts will *not* populate the actionform (if
any) associated with an action.  So you could create a dummy form with a
hard-coded value and use html:hidden with that value to test for once you
are in the action class.
<sorry:noSamples/>

Good Luck!
JM

<logic:equal value="finished" property="workday">
  <logic:iterate id="frostyMug" name="beer" property="Mugs">
    <beer:drink name="frostyMug"/>
  </logic:iterate>
</logic:equal>







> -----Original Message-----
> From: Diego Parrilla [mailto:diego.parrilla@olecenter.com]
> Sent: Friday, April 19, 2002 10:31 AM
> To: Struts Users Mailing List
> Subject: Internationalization and <html:submit
>
>
> Hi,
>
> we are developing an application that uses the i18n capabilities
> of Struts,
> and we have found a problem trying to use this capability with the
> <html:submit ...>.
>
> For instance, if we use in our JSP pages:
>
> <html:submit property="action" value="Accept">
> <html:submit property="action" value="Cancel">
>
> then in our code we will do like this:
>
> if (action.equals("Accept")){
> 	returnPage = "accept";
> }
> else{
>       returnPage = "cancel";
> }
>
> but if we want to translate the value of the buttons the another languages
> let's say:
>
> <html:submit property="action" value="Aceptar">
> <html:submit property="action" value="Cancelar">
>
> How can we make the presentation of the value, and the value passed to the
> property 'action' not coupled. I would like to put into the 'action'
> property always the content in English, but the view in the JSP page in
> different languages depending on the localization of the user?
>
> Is this possible in Struts?
>
> Regards
> Diego
>
> XpertOnline Technical Manager
> e-mail: diego.parrilla@olecenter.com
> Adecco OleCenter
> C/Severo Ochoa, 55
> Parque Empresarial Casablanca II
> 28100 Alcobendas
> Madrid - Spain
> Telf: +34 91 484 77 08
>
>
>
> --
> 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