Posted by st...@gmail.com.
Ted --
I think the method name "validation naming" would be more intuitive.
Thanks,
Scott
On 4/5/07, Ted Husted <hu...@apache.org> wrote:
>
> The WebWork "bang" notation for calling methods doesn't support
> per-method validations.
>
> However, the Struts-style wildcards do support per-method validations.
> Validations can be specified just as if the method name had been
> hardcoded in the configuration. The syntax is
> "ActionClass-actionName-validation.xml. In the case of a create method
> of a Course class that was invoked with the name Course!create.action,
> the validation configuration would be
> Course-Course!create-validation.xml.
>
> Note that it is the action name not the method name. (Though, I often
> wonder if the method name would make more sense.)
>
> The MailReader application for Struts 2 uses wildcards as well as
> per-method validation.
>
> HTH, Ted
> <http://www.husted.com/ted/blog/>
>
>
> On 4/5/07, stanlick@gmail.com <st...@gmail.com> wrote:
> > Ted --
> >
> > This is a great explanation! Can you add to this how Validator naming
> works
> > with respect to wildcard methods? For instance:
> >
> > CourseAction
> > list()
> > create()
> >
> > Course-validation.xml
> > and supposedly support for something like Course-create-validation.xml
> >
> > I think I remember reading something about this support at some point?
> >
> > Thanks,
> > Scott
> >
> >
> > On 4/5/07, Ted Husted <hu...@apache.org> wrote:
> > >
> > > How the link is generated isn't relevant. Once the response hits the
> > > browser, everything is in HTML, and the framework is no longer
> > > involved. When the client clicks the link, it sends back a GET for the
> > > resource. If the action resource has been configured for validation,
> > > then validation fires. By now, the framework doesn't know what
> > > creature manufactured the GET request. A request is a request is a
> > > request. Whether a form was used is also not relevant (or even known).
> > > A form can submit by GET too.
> > >
> > > When an Action class has a validator, the methods that are excluded
> > > from validation can be specified as part of the Interceptor stack.
> > >
> > > <interceptor-ref name="validation">
> > > <param
> > > name="excludeMethods">input,back,cancel,browse</param>
> > > </interceptor-ref>
> > >
> > > The usual suspects to exclude are input, back, cancel, and browse, but
> > > any method names could be configured.
> > >
> > > I haven't been watching the annotation work, but I expect that
> > > @skipvalidation is a special case of the general exclusions that can
> > > be made for certain method names. If that idiom works in the case,
> > > then I would consider using it, since the annotation support is bound
> > > to be extended, and might one day may be considered the default
> > > approach.
> > >
> > > HTH, Ted
> > > <http://www.husted.com/ted/blog/>
> > >
> > > On 4/5/07, stanlick@gmail.com <st...@gmail.com> wrote:
> > > > Thanks Ted. Let us suppose for a moment there are no parameters
> passed
> > > with
> > > > the URL. Is there an S2 pulley or chain I can tug on to bypass the
> > > > validation? Maybe this is not a case where I should be using a S2
> > > tag? It
> > > > strikes me as odd that a hyperlink not related to the form would be
> > > > intercepted by the form validator. I recently discovered the Java
> > > > annotation @SkipValidation and now wonder if there might be an
> > > attribute,
> > > > flag, switch, bit of XML, or interceptor stack I could massage to
> avoid
> > > this
> > > > unwanted feature.
> > > >
> > > > You know, this extreme flexibility reminds me of a Dilbert I saw a
> few
> > > years
> > > > back illustrating the boneless chicken ranch. Seriously, S2 seems
> to
> > > offer
> > > > an unbounded combination of techniques for about anything you need
> to
> > > do.
> > > > Granted, I think a framework should be flexible, but as I read these
> > > > threads, I am more confused about the most recent "best S2
> technique" I
> > > used
> > > > yesterday!
> > > >
> > > > Scott
> > > >
> > > > On 4/5/07, Ted Husted <hu...@apache.org> wrote:
> > > > >
> > > > > A hyperlink is a get, and if coded correctly a get shouldn't have
> side
> > > > > effects, and so at first blush validation might seem redundant.
> > > > > Although, the struts controller doesn't distinguish between get
> and
> > > > > post. If there is a validator associated with the course action,
> then
> > > > > it would be called regardless of whether the request is coded as a
> > > > > hyperlink or form. I note that the link takes a parameter, and if
> the
> > > > > parameter is required to consummate the get, then validation would
> > > > > seem appropriate.
> > > > >
> > > > > HTH, Ted
> > > > > <http://www.husted.com/ted/blog/>
> > > > >
> > > > > On 4/4/07, stanlick@gmail.com <st...@gmail.com> wrote:
> > > > > > Should the Action class validator be getting called when a
> hyperlink
> > > is
> > > > > > clicked? This is the behavior I am experiencing. My hyperlink
> is
> > > coded
> > > > > as
> > > > > > follows:
> > > > > >
> > > > > > <s:url id="url" action="course!remove">
> > > > > > <s:param name="course.id">
> > > > > > <s:property value="id" />
> > > > > > </s:param>
> > > > > > </s:url>
> > > > > >
> > > > > > The hyperlink is outside the form tags!
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> >
> > --
> > Scott
> > stanlick@gmail.com
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Scott
stanlick@gmail.com
Re: Action Validator ans
Posted by Ted Husted <hu...@apache.org>.
The WebWork "bang" notation for calling methods doesn't support
per-method validations.
However, the Struts-style wildcards do support per-method validations.
Validations can be specified just as if the method name had been
hardcoded in the configuration. The syntax is
"ActionClass-actionName-validation.xml. In the case of a create method
of a Course class that was invoked with the name Course!create.action,
the validation configuration would be
Course-Course!create-validation.xml.
Note that it is the action name not the method name. (Though, I often
wonder if the method name would make more sense.)
The MailReader application for Struts 2 uses wildcards as well as
per-method validation.
HTH, Ted
<http://www.husted.com/ted/blog/>
On 4/5/07, stanlick@gmail.com <st...@gmail.com> wrote:
> Ted --
>
> This is a great explanation! Can you add to this how Validator naming works
> with respect to wildcard methods? For instance:
>
> CourseAction
> list()
> create()
>
> Course-validation.xml
> and supposedly support for something like Course-create-validation.xml
>
> I think I remember reading something about this support at some point?
>
> Thanks,
> Scott
>
>
> On 4/5/07, Ted Husted <hu...@apache.org> wrote:
> >
> > How the link is generated isn't relevant. Once the response hits the
> > browser, everything is in HTML, and the framework is no longer
> > involved. When the client clicks the link, it sends back a GET for the
> > resource. If the action resource has been configured for validation,
> > then validation fires. By now, the framework doesn't know what
> > creature manufactured the GET request. A request is a request is a
> > request. Whether a form was used is also not relevant (or even known).
> > A form can submit by GET too.
> >
> > When an Action class has a validator, the methods that are excluded
> > from validation can be specified as part of the Interceptor stack.
> >
> > <interceptor-ref name="validation">
> > <param
> > name="excludeMethods">input,back,cancel,browse</param>
> > </interceptor-ref>
> >
> > The usual suspects to exclude are input, back, cancel, and browse, but
> > any method names could be configured.
> >
> > I haven't been watching the annotation work, but I expect that
> > @skipvalidation is a special case of the general exclusions that can
> > be made for certain method names. If that idiom works in the case,
> > then I would consider using it, since the annotation support is bound
> > to be extended, and might one day may be considered the default
> > approach.
> >
> > HTH, Ted
> > <http://www.husted.com/ted/blog/>
> >
> > On 4/5/07, stanlick@gmail.com <st...@gmail.com> wrote:
> > > Thanks Ted. Let us suppose for a moment there are no parameters passed
> > with
> > > the URL. Is there an S2 pulley or chain I can tug on to bypass the
> > > validation? Maybe this is not a case where I should be using a S2
> > tag? It
> > > strikes me as odd that a hyperlink not related to the form would be
> > > intercepted by the form validator. I recently discovered the Java
> > > annotation @SkipValidation and now wonder if there might be an
> > attribute,
> > > flag, switch, bit of XML, or interceptor stack I could massage to avoid
> > this
> > > unwanted feature.
> > >
> > > You know, this extreme flexibility reminds me of a Dilbert I saw a few
> > years
> > > back illustrating the boneless chicken ranch. Seriously, S2 seems to
> > offer
> > > an unbounded combination of techniques for about anything you need to
> > do.
> > > Granted, I think a framework should be flexible, but as I read these
> > > threads, I am more confused about the most recent "best S2 technique" I
> > used
> > > yesterday!
> > >
> > > Scott
> > >
> > > On 4/5/07, Ted Husted <hu...@apache.org> wrote:
> > > >
> > > > A hyperlink is a get, and if coded correctly a get shouldn't have side
> > > > effects, and so at first blush validation might seem redundant.
> > > > Although, the struts controller doesn't distinguish between get and
> > > > post. If there is a validator associated with the course action, then
> > > > it would be called regardless of whether the request is coded as a
> > > > hyperlink or form. I note that the link takes a parameter, and if the
> > > > parameter is required to consummate the get, then validation would
> > > > seem appropriate.
> > > >
> > > > HTH, Ted
> > > > <http://www.husted.com/ted/blog/>
> > > >
> > > > On 4/4/07, stanlick@gmail.com <st...@gmail.com> wrote:
> > > > > Should the Action class validator be getting called when a hyperlink
> > is
> > > > > clicked? This is the behavior I am experiencing. My hyperlink is
> > coded
> > > > as
> > > > > follows:
> > > > >
> > > > > <s:url id="url" action="course!remove">
> > > > > <s:param name="course.id">
> > > > > <s:property value="id" />
> > > > > </s:param>
> > > > > </s:url>
> > > > >
> > > > > The hyperlink is outside the form tags!
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
> --
> Scott
> stanlick@gmail.com
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Action Validator ans
Posted by st...@gmail.com.
Ted --
This is a great explanation! Can you add to this how Validator naming works
with respect to wildcard methods? For instance:
CourseAction
list()
create()
Course-validation.xml
and supposedly support for something like Course-create-validation.xml
I think I remember reading something about this support at some point?
Thanks,
Scott
On 4/5/07, Ted Husted <hu...@apache.org> wrote:
>
> How the link is generated isn't relevant. Once the response hits the
> browser, everything is in HTML, and the framework is no longer
> involved. When the client clicks the link, it sends back a GET for the
> resource. If the action resource has been configured for validation,
> then validation fires. By now, the framework doesn't know what
> creature manufactured the GET request. A request is a request is a
> request. Whether a form was used is also not relevant (or even known).
> A form can submit by GET too.
>
> When an Action class has a validator, the methods that are excluded
> from validation can be specified as part of the Interceptor stack.
>
> <interceptor-ref name="validation">
> <param
> name="excludeMethods">input,back,cancel,browse</param>
> </interceptor-ref>
>
> The usual suspects to exclude are input, back, cancel, and browse, but
> any method names could be configured.
>
> I haven't been watching the annotation work, but I expect that
> @skipvalidation is a special case of the general exclusions that can
> be made for certain method names. If that idiom works in the case,
> then I would consider using it, since the annotation support is bound
> to be extended, and might one day may be considered the default
> approach.
>
> HTH, Ted
> <http://www.husted.com/ted/blog/>
>
> On 4/5/07, stanlick@gmail.com <st...@gmail.com> wrote:
> > Thanks Ted. Let us suppose for a moment there are no parameters passed
> with
> > the URL. Is there an S2 pulley or chain I can tug on to bypass the
> > validation? Maybe this is not a case where I should be using a S2
> tag? It
> > strikes me as odd that a hyperlink not related to the form would be
> > intercepted by the form validator. I recently discovered the Java
> > annotation @SkipValidation and now wonder if there might be an
> attribute,
> > flag, switch, bit of XML, or interceptor stack I could massage to avoid
> this
> > unwanted feature.
> >
> > You know, this extreme flexibility reminds me of a Dilbert I saw a few
> years
> > back illustrating the boneless chicken ranch. Seriously, S2 seems to
> offer
> > an unbounded combination of techniques for about anything you need to
> do.
> > Granted, I think a framework should be flexible, but as I read these
> > threads, I am more confused about the most recent "best S2 technique" I
> used
> > yesterday!
> >
> > Scott
> >
> > On 4/5/07, Ted Husted <hu...@apache.org> wrote:
> > >
> > > A hyperlink is a get, and if coded correctly a get shouldn't have side
> > > effects, and so at first blush validation might seem redundant.
> > > Although, the struts controller doesn't distinguish between get and
> > > post. If there is a validator associated with the course action, then
> > > it would be called regardless of whether the request is coded as a
> > > hyperlink or form. I note that the link takes a parameter, and if the
> > > parameter is required to consummate the get, then validation would
> > > seem appropriate.
> > >
> > > HTH, Ted
> > > <http://www.husted.com/ted/blog/>
> > >
> > > On 4/4/07, stanlick@gmail.com <st...@gmail.com> wrote:
> > > > Should the Action class validator be getting called when a hyperlink
> is
> > > > clicked? This is the behavior I am experiencing. My hyperlink is
> coded
> > > as
> > > > follows:
> > > >
> > > > <s:url id="url" action="course!remove">
> > > > <s:param name="course.id">
> > > > <s:property value="id" />
> > > > </s:param>
> > > > </s:url>
> > > >
> > > > The hyperlink is outside the form tags!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Scott
stanlick@gmail.com
Re: Action Validator ans
Posted by Ted Husted <hu...@apache.org>.
How the link is generated isn't relevant. Once the response hits the
browser, everything is in HTML, and the framework is no longer
involved. When the client clicks the link, it sends back a GET for the
resource. If the action resource has been configured for validation,
then validation fires. By now, the framework doesn't know what
creature manufactured the GET request. A request is a request is a
request. Whether a form was used is also not relevant (or even known).
A form can submit by GET too.
When an Action class has a validator, the methods that are excluded
from validation can be specified as part of the Interceptor stack.
<interceptor-ref name="validation">
<param
name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
The usual suspects to exclude are input, back, cancel, and browse, but
any method names could be configured.
I haven't been watching the annotation work, but I expect that
@skipvalidation is a special case of the general exclusions that can
be made for certain method names. If that idiom works in the case,
then I would consider using it, since the annotation support is bound
to be extended, and might one day may be considered the default
approach.
HTH, Ted
<http://www.husted.com/ted/blog/>
On 4/5/07, stanlick@gmail.com <st...@gmail.com> wrote:
> Thanks Ted. Let us suppose for a moment there are no parameters passed with
> the URL. Is there an S2 pulley or chain I can tug on to bypass the
> validation? Maybe this is not a case where I should be using a S2 tag? It
> strikes me as odd that a hyperlink not related to the form would be
> intercepted by the form validator. I recently discovered the Java
> annotation @SkipValidation and now wonder if there might be an attribute,
> flag, switch, bit of XML, or interceptor stack I could massage to avoid this
> unwanted feature.
>
> You know, this extreme flexibility reminds me of a Dilbert I saw a few years
> back illustrating the boneless chicken ranch. Seriously, S2 seems to offer
> an unbounded combination of techniques for about anything you need to do.
> Granted, I think a framework should be flexible, but as I read these
> threads, I am more confused about the most recent "best S2 technique" I used
> yesterday!
>
> Scott
>
> On 4/5/07, Ted Husted <hu...@apache.org> wrote:
> >
> > A hyperlink is a get, and if coded correctly a get shouldn't have side
> > effects, and so at first blush validation might seem redundant.
> > Although, the struts controller doesn't distinguish between get and
> > post. If there is a validator associated with the course action, then
> > it would be called regardless of whether the request is coded as a
> > hyperlink or form. I note that the link takes a parameter, and if the
> > parameter is required to consummate the get, then validation would
> > seem appropriate.
> >
> > HTH, Ted
> > <http://www.husted.com/ted/blog/>
> >
> > On 4/4/07, stanlick@gmail.com <st...@gmail.com> wrote:
> > > Should the Action class validator be getting called when a hyperlink is
> > > clicked? This is the behavior I am experiencing. My hyperlink is coded
> > as
> > > follows:
> > >
> > > <s:url id="url" action="course!remove">
> > > <s:param name="course.id">
> > > <s:property value="id" />
> > > </s:param>
> > > </s:url>
> > >
> > > The hyperlink is outside the form tags!
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Action Validator ans
Posted by Dave Newton <ne...@yahoo.com>.
--- stanlick@gmail.com wrote:
> Maybe you missed the part about *not* passing a
> parameter with the link url?
Maybe I was answering your *first* question?
> This link allows an item to be deleted and the
> parameter being passed is a read-only "hibernate id"
> that was loaded into the page during the request.
> There is no need for validating this sort of link.
Besides the issues with exposing such functionality as
a plain link (**bad** idea), I'll generally still
validate such things, because people can pass in
whatever they want, not just what *you* present them
as a link.
If I specifically *didn't* want to validate it for
some reason, I'd just create a different validation
config via file or, most likely, annotations.
> The immediate solution looks like replacing the S2
> tags which are seemingly at the heart of S2!
I'm not sure what the tags have to do with this
usecase? The tags don't have anything to do with the
validation functionality.
d.
____________________________________________________________________________________
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives.
http://tools.search.yahoo.com/toolbar/features/mail/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Action Validator ans
Posted by st...@gmail.com.
Maybe you missed the part about *not* passing a parameter with the link
url?
I am experimenting with a few ideas to minimize writing too many Action
classes by leveraging the wildcard method feature. This link allows an item
to be deleted and the parameter being passed is a read-only "hibernate id"
that was loaded into the page during the request. There is no need for
validating this sort of link. I suppose I can write another Action just for
this "method," but this is precisely what I am trying to avoid. Also, I'd
rather not override framework plumbing to solve this trivial scenario. The
immediate solution looks like replacing the S2 tags which are seemingly at
the heart of S2!
On 4/5/07, Dave Newton <ne...@yahoo.com> wrote:
>
> --- stanlick@gmail.com wrote:
> > It strikes me as odd that a hyperlink not related to
> > the form would be intercepted by the form validator.
>
>
> Meh; if an action is Validatable then it's
> Validatable, you know?
>
> I have to agree with Ted--if you're passing a
> parameter that's being used by the method, why
> *wouldn't* you want to validate it?
>
> That said, the validation interceptor is a subclass of
> MethodFilterInterceptor so you can configure it with
> an excludeMethods parameter as described on the
> validation interceptor wiki page:
>
> http://struts.apache.org/2.x/docs/validation-interceptor.html
>
> You could probably also create a
> class-method-validation.xml file that would do
> something different for just that method.
>
> d.
>
>
>
>
>
> ____________________________________________________________________________________
> Looking for earth-friendly autos?
> Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
> http://autos.yahoo.com/green_center/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Scott
stanlick@gmail.com
Re: Action Validator ans
Posted by Dave Newton <ne...@yahoo.com>.
--- stanlick@gmail.com wrote:
> It strikes me as odd that a hyperlink not related to
> the form would be intercepted by the form validator.
Meh; if an action is Validatable then it's
Validatable, you know?
I have to agree with Ted--if you're passing a
parameter that's being used by the method, why
*wouldn't* you want to validate it?
That said, the validation interceptor is a subclass of
MethodFilterInterceptor so you can configure it with
an excludeMethods parameter as described on the
validation interceptor wiki page:
http://struts.apache.org/2.x/docs/validation-interceptor.html
You could probably also create a
class-method-validation.xml file that would do
something different for just that method.
d.
____________________________________________________________________________________
Looking for earth-friendly autos?
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
http://autos.yahoo.com/green_center/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Action Validator ans
Posted by st...@gmail.com.
Thanks Ted. Let us suppose for a moment there are no parameters passed with
the URL. Is there an S2 pulley or chain I can tug on to bypass the
validation? Maybe this is not a case where I should be using a S2 tag? It
strikes me as odd that a hyperlink not related to the form would be
intercepted by the form validator. I recently discovered the Java
annotation @SkipValidation and now wonder if there might be an attribute,
flag, switch, bit of XML, or interceptor stack I could massage to avoid this
unwanted feature.
You know, this extreme flexibility reminds me of a Dilbert I saw a few years
back illustrating the boneless chicken ranch. Seriously, S2 seems to offer
an unbounded combination of techniques for about anything you need to do.
Granted, I think a framework should be flexible, but as I read these
threads, I am more confused about the most recent "best S2 technique" I used
yesterday!
Scott
On 4/5/07, Ted Husted <hu...@apache.org> wrote:
>
> A hyperlink is a get, and if coded correctly a get shouldn't have side
> effects, and so at first blush validation might seem redundant.
> Although, the struts controller doesn't distinguish between get and
> post. If there is a validator associated with the course action, then
> it would be called regardless of whether the request is coded as a
> hyperlink or form. I note that the link takes a parameter, and if the
> parameter is required to consummate the get, then validation would
> seem appropriate.
>
> HTH, Ted
> <http://www.husted.com/ted/blog/>
>
> On 4/4/07, stanlick@gmail.com <st...@gmail.com> wrote:
> > Should the Action class validator be getting called when a hyperlink is
> > clicked? This is the behavior I am experiencing. My hyperlink is coded
> as
> > follows:
> >
> > <s:url id="url" action="course!remove">
> > <s:param name="course.id">
> > <s:property value="id" />
> > </s:param>
> > </s:url>
> >
> > The hyperlink is outside the form tags!
> >
> > --
> > Scott
> > stanlick@gmail.com
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Scott
stanlick@gmail.com
Re: Action Validator ans
Posted by Ted Husted <hu...@apache.org>.
A hyperlink is a get, and if coded correctly a get shouldn't have side
effects, and so at first blush validation might seem redundant.
Although, the struts controller doesn't distinguish between get and
post. If there is a validator associated with the course action, then
it would be called regardless of whether the request is coded as a
hyperlink or form. I note that the link takes a parameter, and if the
parameter is required to consummate the get, then validation would
seem appropriate.
HTH, Ted
<http://www.husted.com/ted/blog/>
On 4/4/07, stanlick@gmail.com <st...@gmail.com> wrote:
> Should the Action class validator be getting called when a hyperlink is
> clicked? This is the behavior I am experiencing. My hyperlink is coded as
> follows:
>
> <s:url id="url" action="course!remove">
> <s:param name="course.id">
> <s:property value="id" />
> </s:param>
> </s:url>
>
> The hyperlink is outside the form tags!
>
> --
> Scott
> stanlick@gmail.com
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org