|
Oracle UIX API Reference Release 2.1.22.0.0 B12196-01 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--oracle.cabo.servlet.AbstractPageBroker
AbstractPageBroker provides a default implementation of the PageBroker interface. It supports explicit registration of per-page PageDescriptions, each of which encapsulates an event handler and a renderer, as well as the specification of default and login pages.
AbstractPageBroker uses the following servlet configuration parameters:
oracle.cabo.servlet.event.PageFlowEngine
: The class name
of the PageFlowEngine (defaults to the TrivialPageFlowEngine)
oracle.cabo.servlet.defaultPage
: The name of the
default page
oracle.cabo.servlet.errorPage
: The name of the
error page
oracle.cabo.servlet.loginPage
: The name of the
login page
oracle.cabo.servlet.loggedInKey
: A key to check
for being logged in (see below)
oracle.cabo.servlet.io.FileUploadManager
: The class
name of the FileUploadManager
By default, if a login page has been set, the user will be required
to login before accessing any other page. This behavior can be
changed by attaching a new PageFlowEngine. For example, clients can
subclass the default engine, TrivialPageFlowEngine, and override
needsLogin()
. In addition, if
"oracle.cabo.servlet.loggedInKey" has been set in the Servlet
configuration parameters, then the user will be considered logged
in if the HttpSession parameter with this key is non-null.
doUploadFile()
method once for each contained file.
The parameters in the multipart request and the parameters
embedded in the URL's query string will be assembled into a single
PageEvent.
Some clients may not want file uploading handled at this level; all
this processing happens before the PageBroker
is
called at all. There are three ways to turn off this automatic handling.
MultipartFormHandler
to manually process the request. With this approach, any parameters
not directly encoded into the HTML form's "action" URL will
not be available until the multipart request is processed.
AbstractPageBroker.shouldHandleUploadFile()
to
return false. A PageEvent
will still be built
if there is an "event" query parameter, but otherwise the event
will be null
.
FileUploadManager
to manage processing
of multipart form items during file upload.
PageFlowEngine
,
MultipartFormHandler
Field Summary | |
static java.lang.String |
EVENT_ERROR_KEY
Key used to store on the ServletRequest any Throwable or Exception produced by an EventHandler. |
Constructor Summary | |
AbstractPageBroker()
Creates an AbstractPageBroker. |
Method Summary | |
PageEvent |
decodeMultipartRequest(BajaContext context,
Page page)
Handle a multipart request. |
void |
destroy()
Destroys the page broker, freeing any state as needed. |
protected java.lang.String |
doUploadFile(BajaContext context,
Page page,
MultipartFormItem item)
Handler for uploading a file. |
Page |
getDefaultPage()
Returns the default page. |
Page |
getErrorPage()
Returns the error page. |
protected Page |
getErrorPage(BajaContext context,
java.lang.Throwable error)
Called by renderError() to convert an error into a Page for rendering. |
static java.lang.Throwable |
getEventError(BajaContext context)
Returns the Throwable that was thrown from an EventHandler in the current request. |
protected EventHandler |
getEventHandler(BajaContext context,
Page page,
PageEvent event)
Returns the event handler that should be used for the specified page and page event. |
FileUploadManager |
getFileUploadManager()
Returns the FileUploadManager used to process multipart requests on this broker. |
protected PageDescription |
getPageDescription(BajaContext context,
Page page)
Called to retrive a page description. |
PageFlowEngine |
getPageFlowEngine()
Returns the PageFlowEngine used to process event results on this broker. |
protected PageRenderer |
getPageRenderer(BajaContext context,
Page page)
Returns the renderer that should be used for the specified page. |
java.lang.Object |
getService(BajaContext context,
java.lang.Class serviceClass,
java.lang.Object serviceSelector)
Returns a object that provides some global service. |
javax.servlet.Servlet |
getServlet()
Returns the servlet this page broker is attached to. |
Page |
handleRequest(BajaContext context,
Page page,
PageEvent event)
Process a request for a single page, returning the new page to display. |
void |
init(javax.servlet.Servlet servlet,
javax.servlet.ServletConfig config)
Initializes the page broker. |
protected boolean |
isCacheable(BajaContext context,
Page page,
java.lang.Throwable error,
PageEvent event)
Called to determine if the page about to be rendered is cacheable. |
boolean |
isEmbedded()
Returns whether UIX Controller (Baja) is being used in "embedded" mode. |
void |
registerGlobalEventHandler(java.lang.String eventName,
EventHandler handler)
Registers an event handler for use on all pages. |
void |
registerPageDescription(java.lang.String pageName,
PageDescription description)
Registers a page description. |
void |
registerPageDescription(java.lang.String pageName,
PageRenderer renderer,
EventHandler eventHandler)
Registers a page description. |
void |
renderError(BajaContext context,
java.lang.Throwable error)
Renders an error. |
void |
renderPage(BajaContext context,
Page page)
Renders a page. |
void |
requestEnded(BajaContext context)
Callback at the very end of a request. |
void |
requestStarted(BajaContext context)
Called at the very beginning of a request. |
void |
resetGlobalEventHandlers()
Unregisters all global event handlers. |
void |
resetPageDescriptions()
Unregisters all page descriptions. |
void |
setDefaultPage(Page page)
Sets the default page. |
void |
setEmbedded(boolean embedded)
Sets whether the UIX Controller (Baja) is being used in "embedded" mode. |
void |
setErrorPage(Page page)
Sets the error page. |
void |
setFileUploadManager(FileUploadManager fileUpload)
Sets the FileUploadManager used to process multipart requests on this broker. |
void |
setPageFlowEngine(PageFlowEngine pageFlow)
Sets the PageFlowEngine used to process event results on this broker. |
protected void |
setResponseHeaders(BajaContext context,
Page page,
java.lang.Throwable error,
PageEvent event)
Sets response headers on the page. |
protected boolean |
shouldHandleUploadFile(BajaContext context,
Page page)
Returns true if a current multipart request will be handled automatically by the PageBroker. |
void |
unregisterGlobalEventHandler(java.lang.String eventName)
Unregisters an event handler for use on all pages. |
void |
unregisterPageDescription(java.lang.String pageName)
Unregisters a page description. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String EVENT_ERROR_KEY
getEventError(oracle.cabo.servlet.BajaContext)
Constructor Detail |
public AbstractPageBroker()
Method Detail |
public javax.servlet.Servlet getServlet()
public Page getDefaultPage()
public void setDefaultPage(Page page)
public static java.lang.Throwable getEventError(BajaContext context)
EVENT_ERROR_KEY
public Page getErrorPage()
public void setErrorPage(Page page)
public PageFlowEngine getPageFlowEngine()
public void setPageFlowEngine(PageFlowEngine pageFlow)
public FileUploadManager getFileUploadManager()
public void setFileUploadManager(FileUploadManager fileUpload)
public boolean isEmbedded()
setEmbedded(boolean)
public void setEmbedded(boolean embedded)
public void registerPageDescription(java.lang.String pageName, PageDescription description)
pageName
- the name of the pagedescription
- a PageDescription implementationpublic void registerPageDescription(java.lang.String pageName, PageRenderer renderer, EventHandler eventHandler)
pageName
- the name of the pagerenderer
- a PageRenderer for the pageeventHandler
- an event handlerpublic void unregisterPageDescription(java.lang.String pageName)
pageName
- the name of the pagepublic void resetPageDescriptions()
public void registerGlobalEventHandler(java.lang.String eventName, EventHandler handler)
eventName
- the name of the eventhandler
- an event handler for that pagepublic void unregisterGlobalEventHandler(java.lang.String eventName)
eventName
- the name of the eventpublic void resetGlobalEventHandlers()
public void requestStarted(BajaContext context) throws javax.servlet.ServletException
requestStarted
in interface PageBroker
context
- the BajaContextpublic void requestEnded(BajaContext context) throws javax.servlet.ServletException
requestEnded
in interface PageBroker
context
- the BajaContextpublic Page handleRequest(BajaContext context, Page page, PageEvent event) throws PageEventException
handleRequest
in interface PageBroker
context
- the BajaContextpage
- the page the client is requestingevent
- the event on that page, or null if the client
is just requesting a page displayPageEventException
- if the processing of the event failspublic PageEvent decodeMultipartRequest(BajaContext context, Page page) throws java.io.IOException, javax.servlet.ServletException
decodeMultipartRequest
in interface PageBroker
context
- the BajaContextpage
- the page the client is requestingMultipartFormHandler
public void renderPage(BajaContext context, Page page) throws java.io.IOException, javax.servlet.ServletException
renderPage
in interface PageBroker
context
- the BajaContextpage
- the page returned from handleRequestpublic void renderError(BajaContext context, java.lang.Throwable error) throws java.io.IOException, javax.servlet.ServletException
renderError
in interface PageBroker
context
- the BajaContexterror
- a Throwablepublic java.lang.Object getService(BajaContext context, java.lang.Class serviceClass, java.lang.Object serviceSelector)
BajaContext.getService()
will call
this PageBroker method for any services it doesn't serve itself.
Clients can override this method to return any such service.
AbstractPageBroker supports:
PageDescription
: selector must be a Page object
getService
in interface PageBroker
context
- the BajaContextserviceClass
- a class object that the returned object
must be an instance ofserviceSelector
- a selector object, if one is neededpublic void init(javax.servlet.Servlet servlet, javax.servlet.ServletConfig config) throws javax.servlet.ServletException
super.init(servlet, config)
if they override this method.init
in interface PageBroker
public void destroy()
super.destroy()
if they
override this method.destroy
in interface PageBroker
protected void setResponseHeaders(BajaContext context, Page page, java.lang.Throwable error, PageEvent event)
Cache-Control
", "Pragma
", and
"Expires
" HTTP headers.
context
- the BajaContextpage
- the page that will be displayed - i.e., the Page
object returned from the EventHandler, or null
if an exception was thrownerror
- the exception thrown by the EventHandler, if anyevent
- the event that was passed to that handlerprotected boolean isCacheable(BajaContext context, Page page, java.lang.Throwable error, PageEvent event)
context
- the BajaContextpage
- the page that will be displayed - i.e., the Page
object returned from the EventHandler, or null
if an exception was thrownerror
- the exception thrown by the EventHandler, if anyevent
- the event that was passed to that handlerprotected Page getErrorPage(BajaContext context, java.lang.Throwable error)
setErrorPage()
.protected PageDescription getPageDescription(BajaContext context, Page page)
protected EventHandler getEventHandler(BajaContext context, Page page, PageEvent event)
event
- maybe null to indicate that no event was fired. In this case
a null event handler (if registered) for the page is returned before
returning any handlers registered by page name alone.protected PageRenderer getPageRenderer(BajaContext context, Page page)
protected boolean shouldHandleUploadFile(BajaContext context, Page page)
protected java.lang.String doUploadFile(BajaContext context, Page page, MultipartFormItem item) throws java.io.IOException
context
- the BajaContext for this requestpage
- the page the file is being uploaded from;
this page object has not yet been validated for login
or any other handlingitem
- a MultipartFormItem that can be used to
retrieve the file
|
Oracle UIX API Reference Release 2.1.22.0.0 B12196-01 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |