Helo

I will be grateful if you help me solve this one.

This is a typical action inside an application:

    @Jpf.Action(
        forwards = {
            @Jpf.Forward(name="success", action="mypage")
        },
        useFormBean = "myForm",
        validatableProperties = {
            @Jpf.ValidatableProperty(
                propertyName = "name",
                displayName = "Name",
                validateRequired = @Jpf.ValidateRequired(),
                validateMinLength = @Jpf.ValidateMinLength(chars = 5),
                validateMaxLength = @Jpf.ValidateMaxLength(chars = 32))
        },
validationErrorForward = @Jpf.Forward(name="fail", action="mypage")
    )
    public Forward myaction(Form form) {
        /* Some stuff gets done... */
        addActionError("name", "name.is.ok", new Object[] {});
        return new Forward("success");
    }

mypage is a simple action that just forwards the request to a tiles definition.

Now I want to make all POST redirected, following the Redirect After Post idea (http://www.theserverside.com/articles/article.tss? l=RedirectAfterPost). So I have changed the forwards like this:

@Jpf.Forward(name="success", action="mypage")
to
@Jpf.Forward(name="success", action="mypage", redirect=true)

and from
validationErrorForward = @Jpf.Forward(name="fail", action="mypage")
to
validationErrorForward = @Jpf.Forward(name="fail", action="mypage", redirect=true)

and i coded the beforeAction and afterAction methods in the Controller so i save all messages on the session (when i'm about to send the redirection) and retrieve them when i am going to show them.

This works for the "name.is.ok" message, which gets inserted on the action; but it does not work for the validation messages because the beforeAction and afterAction methods don't get executed when validation fails.

How can i keep the validation messages on the session so i can show them afterwards?

I was thinking about hacking the validate method in AnyBeanActionForm.java to put all ActionErrors on the session as well, but i think this is too intrusive. I am also looking at the ActionInterceptor and RequestInterceptor classes (i am about to run the samples).

Thanks in advance

Marcelo Morales

Reply via email to