struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Łukasz Lenart <lukasz.len...@googlemail.com>
Subject Re: conversion error repopulation not working
Date Thu, 31 May 2012 12:57:26 GMT
2012/5/31 J. Garcia <jogaco.en@gmail.com>:
> The short-circuiting option sounds good. There could even be a specially
> dedicated getText() (or alternative method name) for this scenario, which
> should be rather frequent in l10n apps.

Not the best solution, but works:

<s:textfield key="user.born" value="%{getFormatted('format.number',
'user.born', {user.born})}" />

and in ExampleAction (or any other base action class):

    public String getFormatted(String key, String defaultValue, List<?> args) {
        TextProviderFactory tpf = new TextProviderFactory();
        if (container != null) {
            container.inject(tpf);
        }
        TextProvider tp = tpf.createInstance(getClass(), this);
        if (getFieldErrors().isEmpty()) {
            return tp.getText(key, args);
        } else {
            return
ActionContext.getContext().getValueStack().findString(defaultValue);
        }
    }


Regards
-- 
Łukasz
mobile +48 606 323 122 http://www.lenart.org.pl/
Warszawa JUG conference - Confitura http://confitura.pl/

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


Mime
View raw message