You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by girishkamat <gi...@gmail.com> on 2009/07/29 12:35:02 UTC

Re: Stuts 2 and Custom TextProvider

Hi,

  I know its been a almost an year since this thread was born. I joined
nabble just today :)

  I came across the same issue yesterday. I had my message keys defined in
my Action-validation.xml.
  I tried overloading this method in my action

  public String getText(String textName, String defaultValue)

  and it worked to perfection. The validation messages were localized
appropriately.
  FYI, i am using struts-2.0.11
  
Thanks,
Girish


ayavorskiy wrote:
> 
> Hi,
> Is there a way to substitute default, bundle-based TextProvider in Struts
> 2 with a custom one?
> 
> We have a very custom message resolution needs with our Struts 2 based
> application. Per other posts and explanation from "Struts In Action",
> overriding of all getText methods in the base Action class does the trick
> for 90% of what we need. However, there is an issue around "Visitor
> validator" that apparently goes through a different path for error string
> resolution and does not call getText() methods on the action.
> 
> Apparently, when model-driven Action design is used and <my
> model>-validation.xml is stored next to the model class, error messages
> (<message key="..." ../>) defined in validation XML get routed to the
> default TextProvider.
> 
> Is there a way to plug in a custom Text Provider, system-wide? The
> TextProviderFactory makes it seem like custom provider is "injectable"
> (see below), but I have not been able to get it to ever "inject" anything.
> Seems like it always creates a new instance of TextProviderSupport()
> behind the scenes.
> 
> Any help is much appreciated!!!
> 
>   private TextProvider textProvider;
> 
>     @Inject
>     public void setTextProvider(TextProvider textProvider) {
>         this.textProvider = textProvider;
>     }
> 
>     protected TextProvider getTextProvider() {
>         if (this.textProvider == null) {
>             return new TextProviderSupport();
>         } else {
>             return textProvider;
>         }
>     }
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Stuts-2-and-Custom-TextProvider-tp18658000p24716605.html
Sent from the Struts - User mailing list archive at Nabble.com.


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