Oracle UIX API Reference
Release 2.1.22.0.0
B12196-01

oracle.cabo.servlet.event
Class TrivialPageFlowEngine

java.lang.Object
  |
  +--oracle.cabo.servlet.event.BasePageFlowEngine
        |
        +--oracle.cabo.servlet.event.TrivialPageFlowEngine
All Implemented Interfaces:
PageFlowEngine

public class TrivialPageFlowEngine
extends BasePageFlowEngine

Trivial (and default) implementation of PageFlowEngine used by AbstractPageBroker.

This page flow implementation requires EventHandler implementations to return the result page in the event result. If the "result" object in the EventResult isn't a Page object, DefaultPageFlowEngine will use it as a Page name.

Login page support

TrivalPageFlowEngine also contains support for a login page. All Page requests are checked to see if the user is logged in. If not, the user is automatically redirected to the login page. When the user logs in successfully, he's automatically redirected to the page he originally requested.

You can set the login page using setLoginPage(), or by use of a Servlet configuration parameter (see below).

The default way this engine decides if a user is logged in is to look for in the HttpSession at a developer-specified key; if there's any non-null value stored there, the user is assumed to be logged in. You can choose the HttpSession key with setLoggedInKey() or a Servlet configuration parameter. You can also choose a custom different strategy for checking if the user is logged in by subclassing and overriding isLoggedIn().

It's also possible to mark that some pages don't need login by subclassing and overriding needsLogin(), or by explicitly calling addNoLoginPage().

Servlet configuration

TrivialPageFlowEngine uses the following servlet configuration parameters:


Field Summary
static java.lang.Object FORWARD_TO_LOGIN_RESULT
          EventResult key indicating that the user should be redirected to the login page.
 
Fields inherited from class oracle.cabo.servlet.event.BasePageFlowEngine
FORWARD_EVENT_PROPERTY, FORWARD_PAGE_PROPERTY
 
Constructor Summary
TrivialPageFlowEngine()
          Creates a TrivialPageFlowEngine.
 
Method Summary
 void addNoLoginPage(java.lang.String name)
          Marks that a page does not require login.
protected  EventResult checkPageAccess(BajaContext context, Page page, PageEvent event)
          Verifies that the current page can be accessed.
 java.lang.String getLoggedInKey()
          Returns the HttpSession key used to detect if the user has logged in.
 Page getLoginPage()
          Returns the login page.
protected  Page getPage(BajaContext context, Page sourcePage, PageEvent event, EventResult eventResult)
          Given the result of an event, determine which Page should be rendered.
 void init(javax.servlet.Servlet servlet, javax.servlet.ServletConfig config)
          Initializes the page flow engine.
protected  boolean isLoggedIn(BajaContext context, Page page)
          Returns true if the user is already logged in (for the purposes of the provided page).
protected  boolean needsLogin(BajaContext context, Page page)
          Returns true if the specified page cannot be accessed without logging in first.
 void setLoggedInKey(java.lang.String key)
          Sets the HttpSession key used to detect if the user has logged in.
 void setLoginPage(Page login)
          Sets the login page.
 
Methods inherited from class oracle.cabo.servlet.event.BasePageFlowEngine
destroy, handleRequest, processForwardRequest, setForwardRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORWARD_TO_LOGIN_RESULT

public static final java.lang.Object FORWARD_TO_LOGIN_RESULT
EventResult key indicating that the user should be redirected to the login page.
Constructor Detail

TrivialPageFlowEngine

public TrivialPageFlowEngine()
Creates a TrivialPageFlowEngine.
Method Detail

addNoLoginPage

public void addNoLoginPage(java.lang.String name)
Marks that a page does not require login.

init

public void init(javax.servlet.Servlet servlet,
                 javax.servlet.ServletConfig config)
Initializes the page flow engine. Developers should not call this method; PageBroker will call it automatically.
Overrides:
init in class BasePageFlowEngine

getLoginPage

public Page getLoginPage()
Returns the login page. This page will be displayed if the user tries to access a Page for which needsLogin() returns true, and isLoggedIn() returns false.
See Also:
isLoggedIn(oracle.cabo.servlet.BajaContext, oracle.cabo.servlet.Page), needsLogin(oracle.cabo.servlet.BajaContext, oracle.cabo.servlet.Page)

setLoginPage

public void setLoginPage(Page login)
Sets the login page. This page will be displayed if the user tries to access a Page for which needsLogin() returns true, and isLoggedIn() returns false.
See Also:
isLoggedIn(oracle.cabo.servlet.BajaContext, oracle.cabo.servlet.Page), needsLogin(oracle.cabo.servlet.BajaContext, oracle.cabo.servlet.Page)

getLoggedInKey

public java.lang.String getLoggedInKey()
Returns the HttpSession key used to detect if the user has logged in. Clients that need a different mechanism to indicate logging in must override isLoggedIn().
See Also:
isLoggedIn(oracle.cabo.servlet.BajaContext, oracle.cabo.servlet.Page)

setLoggedInKey

public void setLoggedInKey(java.lang.String key)
Sets the HttpSession key used to detect if the user has logged in. Clients that need a different mechanism to indicate logging in must override isLoggedIn().
See Also:
isLoggedIn(oracle.cabo.servlet.BajaContext, oracle.cabo.servlet.Page)

checkPageAccess

protected EventResult checkPageAccess(BajaContext context,
                                      Page page,
                                      PageEvent event)
Verifies that the current page can be accessed. If it can, the method must return null.
Overrides:
checkPageAccess in class BasePageFlowEngine

getPage

protected Page getPage(BajaContext context,
                       Page sourcePage,
                       PageEvent event,
                       EventResult eventResult)
                throws PageEventException
Description copied from class: BasePageFlowEngine
Given the result of an event, determine which Page should be rendered. It is assumed that the sourcePage is considered acceptable - that is, checkPageAccess() would accept it. It is also assumed that the page returned is also acceptable.

Overrides:
getPage in class BasePageFlowEngine
Following copied from class: oracle.cabo.servlet.event.BasePageFlowEngine
Parameters:
context - the current BajaContext
sourcePage - the page on which the event was processed
event - the event just processed
result - the result of that event

isLoggedIn

protected boolean isLoggedIn(BajaContext context,
                             Page page)
Returns true if the user is already logged in (for the purposes of the provided page). If "oracle.cabo.servlet.loggedInKey" has been set, returns true if the HttpSession object contains a non-null entry for that key. Otherwise, returns false.

needsLogin

protected boolean needsLogin(BajaContext context,
                             Page page)
Returns true if the specified page cannot be accessed without logging in first. Default implementation always returns true if a login page has been set and this page isn't the login page (and hasn't been marked as a no-login page), and false otherwise.

Oracle UIX API Reference
Release 2.1.22.0.0
B12196-01

Copyright © 2002,2003, Oracle. All Rights Reserved.