struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "J. Garcia (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (WW-3833) Repopulating Field upon conversion Error does not work when doing localization
Date Mon, 11 Jun 2012 07:41:43 GMT

     [ https://issues.apache.org/jira/browse/WW-3833?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

J. Garcia updated WW-3833:
--------------------------

    Attachment: struts-test.zip
    
> Repopulating Field upon conversion Error does not work when doing localization
> ------------------------------------------------------------------------------
>
>                 Key: WW-3833
>                 URL: https://issues.apache.org/jira/browse/WW-3833
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.3.3, 2.3.4
>            Reporter: J. Garcia
>             Fix For: 2.3.5
>
>         Attachments: struts-test.zip
>
>
> In the documentation, there is a way to repopulate a field with the original user input
when there is a conversion error:
> http://struts.apache.org/2.3.3/docs/conversion-validator.html
> However, this does not work if you try to apply l10n to user input: integers, dates,
real numbers.
> Current workaround:
> In jsp:
> <s:textfield key="user.born" value="%{getFormatted('format.number','user.born')}"
/>
> In BaseAction:
>     public String getFormatted(String key, String expr) {
>         Map<String, Object> conversionErrors = ActionContext.getContext().getConversionErrors();
>         if (conversionErrors.containsKey(expr)) {
>             String[] vals = (String[]) conversionErrors.get(expr);
>             return vals[0];
>         } else {
>             final ValueStack valueStack = ActionContext.getContext().getValueStack();
>             final Object val = valueStack.findValue(expr);
>             List<Object> valList = new ArrayList<Object>();
>             valList.add(val);
>             return getText(key, valList);
>         }
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message