On Fri, Feb 13, 2009 at 6:03 AM, Inge Solvoll <inge.tapes...@gmail.com> wrote:
> In Jumpstart, the example tells me to put the initializing code for the loop
> source collection and its PrimaryKeyEncoder in the onPrepare event handler.
> Is this the recommended best practice? Are there other nice approaches to
> this?

I guess I use event handler methods to set up page class fields a lot
less than the average . . . I basically only use the prepare event
from the Form component.
For your problem, I would have a getPrimaryKeyEncoder() with lazy
initialization:

@Retain
private PrimaryKeyEncoder primaryKeyEncoder;

public PrimaryKeyEncoder getPrimaryKeyEncoder() {
    if (primaryKeyEncoder == null) {
        primaryKeyEncoder = .... // create or get our primary key encoder here
    }
    return primaryKeyEncoder;
}

Sometimes I feel Tapestry 5 is so easy that people often start trying
a complex solution before the easy one. :)

-- 
Thiago

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

Reply via email to