If you're doing validation differently based on the
action then trying to do validation based on the model
doesn't seem like a good idea: you're not trying to
validate the model the same way for every action.

--- lbastil <[EMAIL PROTECTED]> wrote:

> 
> Could someone please state whether I have error in
> reasoning here or not?
> 
> ... even a "I would think its not possible with
> build in features yet" would
> help me.
> 
> Thank you a lot,
> Basti
> 
> 
> lbastil wrote:
> > 
> > OK, sorry, I may have to describe it a little more
> in detail or I did not
> > understand the whole point ...
> > 
> > Yes, lets assume I have:
> > 
> > <action name="meth1" 
> >         class="foo.FooClass" 
> >         method="method1" .../>
> > <action name="meth2"
> >         class="foo.FooClass"
> >         method="method2" .../>
> >         
> > FooClass-meth1-validation.xml
> >   First set of validations
> >   
> > FooClass-meth2-validation.xml
> >   Second set of validations
> > 
> > Action class FooClass is modeldriven, so something
> like
> > 
> > Public ModelClass getModel() ...
> > 
> > In result I want to check different attributes of
> ModelClass.
> > 
> > But in both validation files on action level
> > (FooClass-meth1-validation.xml,
> FooClass-meth2-validation.xml)
> > I had to specify the same, something like:
> > ...
> >    <field name="model">
> >        <field-validator type="visitor">
> >           false
> >           <message></message>
> >        </field-validator>
> >     </field>
> > ...
> > 
> > when I read documentation correctly, on model
> level I would then create
> > another validation xml file like:
> > ModelClass-validation.xml
> > 
> > Here the validations on attribute level have to be
> done, but here it is
> > not possible to distinguish between the action
> methods meth1 and meth2,
> > or?
> > 
> > Thank you again,
> > Basti
> > 
> > 
> > 
> > 
> > newton.dave wrote:
> >> 
> >> You said you wanted different validation for
> different
> >> methods in an action, yes?
> >> 
> >> <action name="meth1" 
> >>         class="foo.FooClass" 
> >>         method="method1" .../>
> >> <action name="meth2"
> >>         class="foo.FooClass"
> >>         method="method2" .../>
> >>         
> >> FooClass-meth1-validation.xml
> >>   First set of validations
> >>   
> >> FooClass-meth2-validation.xml
> >>   Second set of validations
> >> 
> >> Perhaps I'm misunderstanding what you want to do.
> >> 
> >> Regarding annotations, AFAIK you can set the
> >> "validateAnnotatedMethodOnly" attribute on the
> >> validation interceptor [1] and annotate methods
> in
> >> your action class as normal. Haven't done that
> myself,
> >> so I don't know if it works or not.
> >> 
> >> d.
> >> 
> >> [1]
> >>
>
http://struts.apache.org/2.x/docs/validations-annotation.html
> >> 
> >> --- lbastil <[EMAIL PROTECTED]> wrote:
> >> 
> >>> 
> >>> Hm, but as I have model driven action,
> >>> for both methods (even if I want to validate
> >>> different attributes later on)
> >>> the first I have to use is VisitorFieldValidator
> >>> with appendPrefix=false for
> >>> the model attribute of the action class.
> >>> 
> >>> So at this level there is no difference, thats
> why I
> >>> cannot see how it
> >>> should help.
> >>> 
> >>> Could you explain your suggestion a little more
> in
> >>> detail?
> >>> Would it be realizable with annotation approach
> too?
> >>> 
> >>> Thank you very much in advance,
> >>> Basti
> >>> 
> >>> 
> >>> 
> >>> newton.dave wrote:
> >>> > 
> >>> > Create two validation XML files, one for each
> >>> method.
> >>> > You can differentiate between them in a couple
> >>> > different ways, the easiest may be to just
> create
> >>> two
> >>> > action mappings, one for each method.
> >>> > 
> >>> > d.
> >>> > 
> >>> > --- lbastil <[EMAIL PROTECTED]> wrote:
> >>> > 
> >>> >> 
> >>> >> Is there any way with the build in
> declarative
> >>> >> validation possibilities in
> >>> >> struts 2 (annotations, xml)
> >>> >> to do something like conditional validation
> in
> >>> the
> >>> >> following sense:
> >>> >> 
> >>> >> in the action class I have a model class,
> where
> >>> on
> >>> >> action method one i want
> >>> >> to validate
> >>> >> a special subset of model attributes and on
> >>> action
> >>> >> method two another subset
> >>> >> of attributes?
> >>> >> 
> >>> >> (note the model in action is used
> "modeldriven")
> >>> >> 
> >>> >> Thank you for any idea,
> >>> >> Basti
> >>> >> -- 
> >>> >> View this message in context:
> >>> >>
> >>> >
> >>>
> >>
>
http://www.nabble.com/-s2--conditional-validation-tf4843582.html#a13857280
> >>> >> Sent from the Struts - User mailing list
> archive
> >>> at
> >>> >> Nabble.com.
> >>> >> 
> >>> >> 
> >>> >>
> >>> >
> >>>
> >>
>
---------------------------------------------------------------------
> >>> >> To unsubscribe, e-mail:
> >>> >> [EMAIL PROTECTED]
> >>> >> For additional commands, e-mail:
> >>> >> [EMAIL PROTECTED]
> >>> >> 
> >>> >> 
> >>> > 
> >>> > 
> >>> >
> >>>
> >>
>
---------------------------------------------------------------------
> 
=== message truncated ===


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to