Petter Måhlén wrote:
> Hi again,
> 
> It struck me that maybe the problem was related to how the page was invoked,
> and it turned out to be right:
> 
> 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?

>
> public IPage doEdit(int id) {
>    System.out.println("doEdit(" + id + ")");
>               
>    Entity entity = getEntityLister().getEntity(id);
>               
>    EditItemPage page = editPageMap.get(entity.getClass());
>
>    page.setEntity(entity);
>               
>    return page;
> }

Another question is - do you need a map? Cannot the getEditItemPage()
take the entity type as a parameter and make a page discovery based on that?

public IPage doEdit(int id) {
    Entity entity = getEntityLister().getEntity(id);
                
    EditItemPage page = getEditPage(entity.getClass());

    page.setEntity(entity);
                
    return page;
 }


regards,
Bernard

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

Reply via email to