Are you returning a ForwardResolution to another action, or directly to a JSP?
Field repopulation with the default PopulationStrategy should get the values
from request params. If you are not getting them back, then something is
messing with them… A redirect, a changed param name… Another thing to check,
ValidationMethods happen after @Validate annotations, so they’re not been
called if you are using @Validate(“required=true”)…
I’ve just made a little test app, and works ok (I’ve stripped some plumbing
code, though):
index.jsp
<s:form beanclass="my.action.PostAction">
a: <s:text name="a" /> <s:errors field="a" /> <br/>
b: <s:text name="b" /> <s:errors field="b" /> <br/>
<s:submit name="execute">Send</s:submit>
</s:form>
IndexAction
public class IndexAction implements ActionBean {
@DefaultHandler
public Resolution execute() {
return new ForwardResolution("/WEB-INF/jsp/index.jsp");
}
}
PostAction
public class PostAction implements ActionBean, ValidationErrorHandler {
@Validate(required=true)
private String a;
@Validate(required=true)
private String b;
@DefaultHandler
public Resolution execute() {
System.out.println(a + “ “ + b);
return new RedirectResolution(IndexAction.class);
}
@Override
public Resolution handleValidationErrors(ValidationErrors errors) throws
Exception {
return new ForwardResolution(IndexAction.class);
}
}
Hope it helps!
_____
De: [email protected] [mailto:[email protected]]
Enviado el: jueves, 26 de marzo de 2009 9:25
Para: Stripes Users List
Asunto: [Stripes-users] Vedr.: Re: Validation vs. updating model
Héctor López <[email protected]> skrev den 25-03-2009 11:38:13:
> It depends on lots of things: what PopulationStrategy are you using,
Haven't set any, so I guess I'm using the default?
> how does your JSP look like,
Just a plain JSP with a stripes-form tag that refers to an action bean.
> whether you are using a custom error
> handler or the sourcePage parameter is being used,
Both. I have some validation annotations and also implement
ValidationErrorHandler. I also have a method marked
@ValidationMethod(when=ValidationState.ALWAYS) for the event in question.
> whether you are
> using a redirect in between or not… Can you show us some of your code?
The resolution returned is of class ForwardResolution.
I could send some code, but it's really rather huge and has quite a few
dependencies.
> Something like the following works as you expect:
*SNIP*
Except that you example only has one field, which is not enough to exhibit the
problem where one field is valid and another is not.
I'll try to dig into a TRACE log to see if any hint is to be found there.
Thanks,
-dennis
------------------------------------------------------------------------------
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users