You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Christoph Nenning <Ch...@lex-com.net> on 2013/09/13 15:08:35 UTC

TextProvider, Validation and ModelDriven

Dear List,


when an application uses a custom TextProvider it seems not to be used for 
validation errors. And if an Action is ModelDriven it behaves different 
again.

Here is a sample app for that:
https://github.com/wolpi/struts2-samples/tree/master/modeldriven-and-textprovider


This sample has these Objects on ValueStack:
- Model
- CustomTextProvider
- Action
- DefaultTextProvider

In hello.jsp three texts are shown:
- Just a normal text via <s:text>. That text is resolved via 
CustomTextProvider (as expected).
- A validation error of an action member. That text is resolved via the 
action itself, what I would not expect.
- A validation error of a model member. That text is tried to be resolved 
via DefaultTextProvider, what I would not expect either.


Am I doing something wrong here?


Regards,
Christoph

This Email was scanned by Sophos Anti Virus

Re: TextProvider, Validation and ModelDriven

Posted by Lukasz Lenart <lu...@apache.org>.
There is a bug in DelegatingValidatorContext#makeTextProvider method -
it should first try to use parent before creating new instance of
TextProvider (base on TextProviderFactory but without injecting
dependencies :\)


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

2013/9/16 Christoph Nenning <Ch...@lex-com.net>:
>> > when an application uses a custom TextProvider it seems not to be used
> for
>> > validation errors. And if an Action is ModelDriven it behaves
> different
>> > again.
>> >
>> > Here is a sample app for that:
>> > https://github.com/wolpi/struts2-samples/tree/master/modeldriven-
>> and-textprovider
>> >
>> >
>> > This sample has these Objects on ValueStack:
>> > - Model
>> > - CustomTextProvider
>> > - Action
>> > - DefaultTextProvider
>> >
>> > In hello.jsp three texts are shown:
>> > - Just a normal text via <s:text>. That text is resolved via
>> > CustomTextProvider (as expected).
>> > - A validation error of an action member. That text is resolved via
> the
>> > action itself, what I would not expect.
>> > - A validation error of a model member. That text is tried to be
> resolved
>> > via DefaultTextProvider, what I would not expect either.
>> >
>> >
>> > Am I doing something wrong here?
>>
>> Have you tried to use the extension point: struts.xworkTextProvider ?
>>
>> http://struts.apache.org/development/2.x/docs/plugins.html#Plugins-
>> ExtensionPoints
>>
>>
>
> that changed things, but it is still not used for ModelDriven validation
> errors.
>
>
> Here is what I have done:
> - Registered CustomTextProvider in struts.xml:
>         <bean name="customTextProvider"
>                 scope="default"
>                 type="com.opensymphony.xwork2.TextProvider"
>                 class=
> "struts2.samples.modeldrivenandtextprovider.actions.CustomTextProvider" />
>
>         <constant name="struts.xworkTextProvider"
>                 value="customTextProvider" />
> - Removed it from ValueStack
> - Removed TextProvider methods from action
> (see git history)
>
>
>
> This gave:
> - CustomTextProvider is used for <s:text>
> - CustomTextProvider is used for validaton errors of action members
> - CustomTextProvider is not used for validaton errors of model members
>
>
>
> Regards,
> Christoph
>
> This Email was scanned by Sophos Anti Virus

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


Re: TextProvider, Validation and ModelDriven

Posted by Christoph Nenning <Ch...@lex-com.net>.
> > when an application uses a custom TextProvider it seems not to be used 
for
> > validation errors. And if an Action is ModelDriven it behaves 
different
> > again.
> >
> > Here is a sample app for that:
> > https://github.com/wolpi/struts2-samples/tree/master/modeldriven-
> and-textprovider
> >
> >
> > This sample has these Objects on ValueStack:
> > - Model
> > - CustomTextProvider
> > - Action
> > - DefaultTextProvider
> >
> > In hello.jsp three texts are shown:
> > - Just a normal text via <s:text>. That text is resolved via
> > CustomTextProvider (as expected).
> > - A validation error of an action member. That text is resolved via 
the
> > action itself, what I would not expect.
> > - A validation error of a model member. That text is tried to be 
resolved
> > via DefaultTextProvider, what I would not expect either.
> >
> >
> > Am I doing something wrong here?
> 
> Have you tried to use the extension point: struts.xworkTextProvider ?
> 
> http://struts.apache.org/development/2.x/docs/plugins.html#Plugins-
> ExtensionPoints
> 
> 

that changed things, but it is still not used for ModelDriven validation 
errors.


Here is what I have done:
- Registered CustomTextProvider in struts.xml:
        <bean name="customTextProvider"
                scope="default"
                type="com.opensymphony.xwork2.TextProvider" 
                class=
"struts2.samples.modeldrivenandtextprovider.actions.CustomTextProvider" /> 

        <constant name="struts.xworkTextProvider"
                value="customTextProvider" />
- Removed it from ValueStack
- Removed TextProvider methods from action
(see git history)



This gave:
- CustomTextProvider is used for <s:text>
- CustomTextProvider is used for validaton errors of action members
- CustomTextProvider is not used for validaton errors of model members



Regards,
Christoph

This Email was scanned by Sophos Anti Virus

Re: TextProvider, Validation and ModelDriven

Posted by Lukasz Lenart <lu...@apache.org>.
2013/9/13 Christoph Nenning <Ch...@lex-com.net>:
> when an application uses a custom TextProvider it seems not to be used for
> validation errors. And if an Action is ModelDriven it behaves different
> again.
>
> Here is a sample app for that:
> https://github.com/wolpi/struts2-samples/tree/master/modeldriven-and-textprovider
>
>
> This sample has these Objects on ValueStack:
> - Model
> - CustomTextProvider
> - Action
> - DefaultTextProvider
>
> In hello.jsp three texts are shown:
> - Just a normal text via <s:text>. That text is resolved via
> CustomTextProvider (as expected).
> - A validation error of an action member. That text is resolved via the
> action itself, what I would not expect.
> - A validation error of a model member. That text is tried to be resolved
> via DefaultTextProvider, what I would not expect either.
>
>
> Am I doing something wrong here?

Have you tried to use the extension point: struts.xworkTextProvider ?

http://struts.apache.org/development/2.x/docs/plugins.html#Plugins-ExtensionPoints


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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