On May 4, 2012, at 8:53 AM, Arno Haase wrote: >>> onPrepare() is called before data binding, but it is called >>> again after data binding. So simple initialization code in >>> onPrepare() would overwrite the form data with the default. >> >> This isn't correct. It's called once per request. And Tapestry >> uses redirect-after-post, so the form submission and the form >> rendering are never in the same request (unless you're doing the >> submission though AJAX). > > Thanks for pointing this out. > > But since I am using AJAX - does anyone have a recommendation for > where to put the initializations?
Good question. I never came up with a good solution, either, without having two events. One can do onActivate(), but if you are doing something slow, like reading values from a database, I wouldn't recommend it. This is because onActivate is called to construct the URL in any referencing page. As a result, my start page calls onActivate for like 30 pages and is very slow on startup. @SetupRender is another potential place, but I don't think it's called for AJAX, so I often just call it from my AJAX listener. Seems we really need an @OnInitGoesHere or something. :) Norman Franke Answering Service for Directors, Inc. www.myasd.com