Think is just a check on the logic.

for a page refresh

http://www/../edit/myEdit!save.action <http://www/edit/myEdit%21save.action>

will call the validator, whilst

http://www/../edit/myEdit.action <http://www/edit/myEdit%21save.action>

does not.

If its not a post why validate the form?

Guess its some where in ValidationInterceptor extends
MethodFilterInterceptor.


On 5 June 2018 at 11:40, Yasser Zamani <yasserzam...@apache.org> wrote:

>
>
> On 6/5/2018 2:30 PM, Greg Huber wrote:
> > I think the logic is OK, but the validator wants to validate the form on
> > the manual refresh (check for a post?), but the fields on the form have
> not
> > been added to the stack, ie all by form.beans are empty when the
> validator
> > runs.
> >
> > I have logic that checks for a refresh and will show an error message,
> but
> > it never gets to the check due to the validator running.
> >
> > ...I have a DMI validation interceptor that manipulates the location of
> the
> > xx.-validation.xml, if I test for a post I can bypass the validation and
> > then will show my error (don't really want to do it this way):
> >
> > protected String getValidationContext(ActionProxy proxy) {
> >         final ActionContext context = proxy.getInvocation()
> >                 .getInvocationContext();
> >         HttpServletRequest request = (HttpServletRequest) context
> >                 .get(ServletActionContext.HTTP_REQUEST);
> >         if (!"POST".equals(request.getMethod())) {
> >             return null;
> >         } else if (dmiEnabled && StringUtils.isNotEmpty(proxy.
> getMethod()))
> > {
> >             return proxy.getActionName() + "!" + proxy.getMethod();
> >         }
> >         return super.getValidationContext(proxy);
> >     }
> >
> > ie  http://www/../edit/myEdit!save.action
> > <http://www/edit/myEdit%21save.action> is not really a POST but a page
> > refresh, so I want to stop the validator running
>
> I would prefer an easier method; defining two actions instead. e.g.
> action get which displays an empty form and has no validation, and
> action save which gets posted data and has those validations. Then any
> refresh on action get doesn't cause neither problem or false validations.
>
> Regards.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
> For additional commands, e-mail: dev-h...@struts.apache.org
>
>

Reply via email to