package net.xoetrope.builder;
import net.xoetrope.xui.XPage;
import net.xoetrope.xui.XPageManager;
import net.xoetrope.xui.XProjectManager;
/**
* NavigationHelper extends XPage by adding a few simple methods to assist in
* navigating from page to page. The previous and next methods assume that
* the names of the next and previous pages have been added as attributes
* to the page.
* <p>Copyright: Copyright (c) Xoetrope Ltd., 2002-2003</p>
* License: see license.txt
*/
public class NavigationHelper extends XPage
{
protected XPageManager pageManager;
public NavigationHelper()
{
pageManager = XProjectManager.getPageManager();
}
/**
* Navigate to the page referenced by the 'home' attribute
*/
public void homePage()
{
if ( wasMouseClicked() )
navigateToPage( "home" );
}
/**
* Navigate to the previous page in the page display history
*/
public void prevPage()
{
if ( wasMouseClicked() )
XProjectManager.getPageManager().showPrevious();
}
/**
* Navigate to the page referenced by the 'next' attribute
*/
public void nextPage()
{
if ( wasMouseClicked() )
navigateToPage( "next" );
}
/**
* Lookup the key/attribute and navigate to that page.
*/
protected void navigateToPage( String key )
{
String dest = (String)getAttribute( key );
if ( dest != null )
XProjectManager.getPageManager().showPage( dest );
}
}
|