> > > > The editPageMap was initialised during pageBeginRender(): > > > > @InjectPage("EditItem") > > public abstract EditItemPage getEditItemPage(); > > > > public void pageBeginRender(PageEvent event) { > > editPageMap = new HashMap<Class, EditItemPage>(); > > > > editPageMap.put(Item.class, getEditItemPage()); > > Why don't you just use page names as map values instead of page > instances? Caching pages in any way is not a good idea... After the > doEdit is invoked you wold use the name to instatiate the page needed. > > If type maps to one page, you'are probably instantiating many > pages now > on every pageBeginRender call (twice for a request during > render/rewind) which is IMHO very ineffecitve. Moreover you will use > only one page from all of this superfluously instantiated ones > eventually, am I right?
Oh, absolutely - I'm a Tapestry noob, and I am playing around with things to find what works and what doesn't. This approach (page injection with annotations) was mentioned in the tutorials, so it's really the only one I was aware of. Initially, I lazy-initialized the HashMap if not null which would make performance less of a problem (but probably still lead to problems with cached page instances, I now understand), but I removed that during the course of simplifying the code to figure out what went wrong. Thanks for the tip about page names! I will look into how to do that, it sounds like the way to go. My other point is probably still relevant, though: it seems as if the following code shows a problem: @InjectPage("EditItem") public abstract EditItemPage getEditItemPage(); public void pageBeginRender(PageEvent event) { IPage invalidInstance = getEditItemPage(); // <---- BAD } public void listenerMethod() { IPage validInstance = getEditItemPage(); // <---- GOOD } That really feels a little weird to me as a programmer. I suppose that it will never be useful to return an invalid instance, so what I was wondering is if it would be at all possible for the getEditItemPage() method to throw an exception or return null if it is called at an inappropriate time in the render cycle? That would make it easier for a programmer to catch his mistake. Thanks, Petter --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]