Hi Joel.
What you put in that onValidateForm is going to be important. :)
@Persist("flash") persists a value in the session until (and only until) it has been re-accessed (once). At that point, it is yanked from the session. So if you're reading your List<String> values in the onValidateForm, you're going to wind up with issues.
It turns out that you can work around this by simply doing:
values=values;

Your IDE will probably complain about this being a noop... but it isn't, since this code will be instrumented at runtime.

Cheers,

Robert

On Apr 3, 2008, at 4/36:34 AM , Joel Wiegman wrote:
Sure... An example is below.  The "values" field disappears from the
screen if validation fails.

//JAVA
public class MyClass {

        //(assume getters and setters exist)
        @Persist("flash")
        List<String> values;

        public void onPrepare() {
                //populate values with stuff
        }

        public void onValidateForm() {
                //possibly some form validation here
        }

}

//TML

<t:form>

//other fields with validation rules would be here

<div t:type="loop" source="values" value="selectedValue">
        ${selectedValue}
</div>

<t:form>

-----Original Message-----
From: Ted Steen [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 02, 2008 6:10 PM
To: Tapestry users
Subject: Re: T5.0.11: @Persist("flash") values are not retained if
validation fails

Could you give a simple example of the problem?

2008/4/2, Joel Wiegman <[EMAIL PROTECTED]>:
As an addendum, I shouldn't say "any field".  The culprit is a List
that  gets iterated over in the TML.


-----Original Message-----
From: Joel Wiegman [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 02, 2008 2:20 PM
To: Tapestry users
Subject: T5.0.11: @Persist("flash") values are not retained if
validation fails

All,

I've noticed that if validation fails on my page, any field annotated

with @Persist("flash") is not retained when the response is rendered.

Per the documentation for @Persist("flash"), this doesn't appear to
be  expected behavior.

Should I put this in JIRA?

Joel

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


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




--
/ted

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


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


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

Reply via email to