I do something similar to this, but instead of a page I store an Object,
generally a Link:

@Persist
Object returnTo;

So that I can store a page or a link depending on what the calling page
requires. If you generate a link using _resources.createPageLink and don't
provide the last context parameter tapestry will call your page's
onPassivate handler to get the context.

For login I'm using the onActivate pattern. I store a link using the passed
context so that I come right back to where I was:
    @OnEvent("activate")
    public Object onEditorPageActivate(Object[] context) {
        if (!_loginDataExists) {
            Link link = _resources.createPageLink(_resources.getPageName(),
false, context);
            _log.debug("Redirect to login page... " + link);
            _loginPage.setSuccessPage(link);
            return _loginPage;
        }

        return null;
    }
For pages returning after some activity, say an edit form returning to the
list I use an action link so I can set up the next page, here is the
handler:

    public Object onEdit(Long videoId) {
        VideoPick video = _videoDAO.findById(videoId, false);
        if ( video != null ) {
            _editVideoPage.setVideo(video);
            // no context to createPageLink adds current page context to
link
            Link link = _resources.createPageLink(_resources.getPageName(),
false);
            _editVideoPage.setNextPage(link);
            return _editVideoPage;
        }
        // Need to set an error...
        return null;
    }

Hope that helps,
Josh


On Dec 4, 2007 6:27 AM, Joachim Van der Auwera <[EMAIL PROTECTED]> wrote:

> I have situation where I have a page in my application which can be
> reached from many different pages. When a certain link is indicated, I
> want the user to move back to the previous page. The problem is that
> this class has no idea (cannot know) what the possible return pages are.
>
> I thought about using a mechanism like the following, on the originator
> pages, include an actionlink component with the following code
>
> ---- OriginatorPage
>
> @InjectPage
> private DestinationPage destination;
>
> Object onActionFromLink()
> {
>    // initialize
>    destinationPage.setReturnPage( this );
>    return destination;
> }
> -----
>
> On the destination page, I would have another actionlink to get back to
> the originator page.
>
> ----- DestinationPage
>
> @Persist
> private Object returnPage;
>
> public void setReturnPage( Object o ) { returnPage = o; }
>
> Object onActionFromLinkback()
> {
>    return page;
> }
>
> -----
>
> Unfortunately this does not work, presumably because the originator page
> is detached.
>
> Is there some way serialize/deserialize a page so that I can be used?
>
> It would be possible to add two methods which store/restore all the
> persisted fields, but I still need to be able to attach/inject a page of
> which the page name is not known in advance.
>
> Any suggestions?
>
> Thanks for the help,
> Joachim
>
> --
> Joachim Van der Auwera
> PROGS bvba, progs.be
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

Reply via email to