I'm assuming you mean in the Containing Page? I tried switching it to onActivate instead of beginRender and in this case the afterRender method throws a NoSuchElementException when trying to pop the Object from the Environment, code as below:

//@BeginRender
    public void onActivate(){
        debug("Loaded ViewProductTab and SubPageId = " + this.id);
        env.push(PageId.class, id);
    }

    @AfterRender
    public void  popPageId(){
        this.id = env.pop(PageId.class);
    }


After considering Robert's suggestions with onPrepareForSubmit, I was able to hack a solution, at least it feels hackish. I found out that when trying to push the @Environmental PageId in the SubPage back into the Environment, it is already lost. However, the onPrepare method it still exists, so I can assign it to a @Persist field in the page and then push that back into the environment at onPrepareForSubmit method. This seems a bit cheap to me, but its simple and it works.

Honestly, this is confusing because documentation says that onPrepareForSubmit gets fired before onPrepare does? Id is available in onPrepare but not onPrepareForSubmit after a form submission. Code below:

@Environmental
    private PageId id;

    @Persist
    private PageId heldId;

    @Inject
    private Environment env;

public void onPrepare(){
        prod = (Product) pdao.read(id.getId());
        heldId = id;
debug("In onPrepare of DetailsTab in partner package. Loaded Product ::"+prod+":: from DB");
    }

void onPrepareForSubmit(){
        debug("\n\n\n In onPrepareForSubmit \n\n\n");
        env.push(PageId.class, heldId); //push back
        debug("\n\n\n pushed PageId onto env \n\n\n");
    }

-Rich


On 08/20/2010 05:44 PM, Thiago H. de Paula Figueiredo wrote:
On Fri, 20 Aug 2010 18:26:46 -0300, Rich M <rich...@moremagic.com> wrote:

Spoke a little too soon. One minor thing remains in some of the sub-subPages related to the Environmental stuff. Passing the PageId Object from the containing page to the sub-page through the environment works out okay, but when I submit forms on any of the sub-pages I get an exception stating the PageId object isn't in the environment.

Have you tried adding the pageId to the Environment on onActivate() instead of beginRender()?



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

Reply via email to