I'd recommend doing some investigation into the form submission life
cycle, especially in the context of a loop. Try putting some trace
statements in your code so you can see when your various methods are
getting called.

If you are using the default formState of the loop then the values are
actually persisted in a field of your form. When the form is submitted
the loop runs again calling the setter on the value used in the loop.
This is how your code worked without @Persist on your list, your code
rebuilt the list from the data stored on the browser.

When you switched to a page property for the value of the loop then
tapestry is still setting the value for each iteration, but it's not
stuffed back into the list.

Also by default the submit button is deferred so that it occurs at the
end of the form submission, but before validate so I would expect your
reordering code to occur after your list was regenerated.

I generally keep an experiments project around so that I can build
small examples to validate my assumptions. I highly recommend this
practice!

Josh

On Mon, Mar 7, 2011 at 4:35 AM, Stephan Windmüller
<stephan.windmuel...@tu-dortmund.de> wrote:
> On 04.03.2011 19:47, Josh Canfield wrote:
>
>>> But when I change the data in the submit event like
>>> "onSelectedFromMoveUpButton". the sorting is overwritten by the form
>>> submission values.
>> How is it getting overwritten? How are you doing the ordering? What
>> you've described could work, here is a really simple example:
>
> Thanks for the small example, I figured out what caused the problem. I
> did not use @Property for the value, instead I wrote my own getter and
> setter:
>
> -----
>
> public void setValue(String value) {
>    if (list.size() < counter + 1) {
>        list.add(value);
>    } else {
>        list.set(counter, value);
>    }
> }
>
> public String getValue() {
>    return list.get(counter);
> }
>
> -----
>
> After I replaced this with the @Property annotation, the sorting code
> works. But now I have to persist all values in the session, flash
> persistence is not enough anymore.
>
> What exactly is the difference between @Property and self-made getters
> and setters?
>
> - Stephan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to