You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Paolo DonĂ  <pa...@gmail.com> on 2005/11/10 12:04:28 UTC

Previous page?

Hi guys,
Is there a way in T4 to know which page called the current rendering page?
I'd like to implement a generic "back" button..

Paolo

Re: Previous page?

Posted by Paolo DonĂ  <pa...@gmail.com>.
Thanks Barry, I did something similar this way (you should understand the
xdoclet annotations..)
Imagine this page flow: SomePage -> PageWithBack -> SomePage (accessed
through the 'back' link)

/**
* @tapestry.page-specification
* @tapestry.direct-link id="linkToPageWithBack"
listener="listener:doGoToPageWithBack"
*/
public abstract class SomePage extends BasePage {

/** @tapestry.inject-page object="PageWithBack " */
public abstract PageWithBack getPageWithBack();

public IPage doGoToPageWithBack(){
PageWithBack nextPage = getPageWithBack();
nextPage.setBackPage("SomePage");
return nextPage;
}
}


/**
* @tapestry.page-specification
* @tapestry.direct-link id="linkBack" listener="listener:doGoBack"
*/
public abstract class PageWithBack extends BasePage {

/** @tapestry.property persist="client:page" */
public abstract String getBackPage();
public abstract void setBackPage(String prop);

public IPage doGoBack(){
IPage backPage = getRequestCycle().getPage(getBackPage());
return backPage;
}
}

It works, but the bad thing is that I have to specify the '
nextPage.setBackPage("SomePage");' code for every "XXXXPage" pointing to
PageWithBack.

I'm trying to find a way to make PageWithBack aware of the previous page
without changing every page which points to it.
It seems that your solutions has the same issue as mine.

Another question... do you see benefits using your ICallback approach
compared to my getRequestCycle().getPage(getBackPage()) one?

Paolo

On 11/10/05, Barry Books <tr...@gmail.com> wrote:
>
> In my page class I have this
>
> public void setCallback(ICallback c) {
> this.callback = c;
> }
> public ICallback getCallback() {
> return this.callback;
> }
>
> public void doCallback(IRequestCycle cycle) {
> if ( getCallback() != null ) {
> getCallback().performCallback(cycle);
> }
> }
>
> In the page you want to return to do this
>
> page.setCallback( new PageCallback(this));
> > cycle.activate(page);
>
>
> Now calling doCallback will return to that page
>
>
>

Re: Previous page?

Posted by Barry Books <tr...@gmail.com>.
In my page class I have this

public void setCallback(ICallback c) {
this.callback = c;
}
public ICallback getCallback() {
return this.callback;
}

public void doCallback(IRequestCycle cycle) {
if ( getCallback() != null ) {
getCallback().performCallback(cycle);
}
}

In the page you want to return to do this

page.setCallback( new PageCallback(this));
> cycle.activate(page);


Now calling doCallback will return to that page