|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.tapestry.engine.RequestCycle
public class RequestCycle
Provides the logic for processing a single request cycle. Provides access to
the engine and the RequestContext.
| Constructor Summary | |
|---|---|
RequestCycle(IEngine engine,
RequestContext requestContext,
IEngineService service,
IMonitor monitor)
Standard constructor used to render a response page. |
|
| Method Summary | |
|---|---|
void |
activate(IPage page)
Sets the active page for the request. |
void |
activate(String name)
A convienience for invoking IRequestCycle.activate(IPage). |
void |
cleanup()
Called at the end of the request cycle (i.e., after all responses have been sent back to the client), to release all pages loaded during the request cycle. |
void |
commitPageChanges()
Invokes IPageRecorder.commit() on each page recorder loaded
during the request cycle (even recorders marked for discard). |
void |
discardPage(String name)
Finds the page and its page recorder, creating the page recorder if necessary. |
String |
encodeURL(String URL)
Passes the String through HttpServletResponse.encodeURL(java.lang.String), which
ensures that the session id is encoded in the URL (if necessary). |
Object |
getAttribute(String name)
Retrieves a previously stored attribute, returning null if not found. |
IEngine |
getEngine()
Returns the engine which is processing this request cycle. |
IMonitor |
getMonitor()
|
String |
getNextActionId()
Returns the next action id. |
IPage |
getPage()
Identifies the active page, the page which will ultimately render the response. |
IPage |
getPage(String name)
Gets the page from the engines's IPageSource. |
protected IPageRecorder |
getPageRecorder(String name)
Returns the page recorder for the named page. |
RequestContext |
getRequestContext()
|
IEngineService |
getService()
Returns the service which initiated this request cycle. |
Object[] |
getServiceParameters()
Returns parameters previously stored by IRequestCycle.setServiceParameters(Object[]). |
boolean |
isRewinding()
Returns true if the context is being used to rewind a prior state of the page. |
boolean |
isRewound(IComponent component)
Checks to see if the current action id matches the target action id. |
void |
observeChange(ObservedChangeEvent event)
For pages without a page recorder,
we're the change observer. |
void |
removeAttribute(String name)
Removes a previously stored attribute, if one with the given name exists. |
void |
renderPage(IMarkupWriter writer)
Renders the page by invoking IPage.renderPage(IMarkupWriter, IRequestCycle). |
void |
rewindForm(IForm form,
String targetActionId)
Rewinds an individual form by invoking IForm.rewind(IMarkupWriter, IRequestCycle). |
void |
rewindPage(String targetActionId,
IComponent targetComponent)
Rewinds the page by invoking IPage.renderPage(IMarkupWriter, IRequestCycle). |
void |
setAttribute(String name,
Object value)
Allows a temporary object to be stored in the request cycle, which allows otherwise unrelated objects to communicate. |
void |
setPage(IPage value)
Sets the page to be rendered. |
void |
setPage(String name)
Sets the page to be rendered. |
void |
setServiceParameters(Object[] serviceParameters)
Invoked by a service to store an array of application-specific parameters. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public RequestCycle(IEngine engine,
RequestContext requestContext,
IEngineService service,
IMonitor monitor)
| Method Detail |
|---|
public void cleanup()
cleanup in interface IRequestCyclepublic IEngineService getService()
IRequestCycle
getService in interface IRequestCyclepublic String encodeURL(String URL)
IRequestCycleHttpServletResponse.encodeURL(java.lang.String), which
ensures that the session id is encoded in the URL (if necessary).
encodeURL in interface IRequestCyclepublic IEngine getEngine()
IRequestCycle
getEngine in interface IRequestCyclepublic Object getAttribute(String name)
IRequestCycle
getAttribute in interface IRequestCyclepublic IMonitor getMonitor()
getMonitor in interface IRequestCyclepublic String getNextActionId()
IRequestCycle
getNextActionId in interface IRequestCyclepublic IPage getPage()
IRequestCycle
getPage in interface IRequestCyclepublic IPage getPage(String name)
IPageSource.
getPage in interface IRequestCycleIEngine.getPageSource()protected IPageRecorder getPageRecorder(String name)
IEngine.getPageRecorder(String, IRequestCycle) is
invoked to get the recorder, if it exists.
public RequestContext getRequestContext()
getRequestContext in interface IRequestCyclepublic boolean isRewinding()
IRequestCycle
isRewinding in interface IRequestCycle
public boolean isRewound(IComponent component)
throws StaleLinkException
IRequestCycleIf theres a match on action id, then the component
is compared against the target component. If there's a mismatch
then a StaleLinkException is thrown.
isRewound in interface IRequestCycleStaleLinkExceptionpublic void removeAttribute(String name)
IRequestCycle
removeAttribute in interface IRequestCyclepublic void renderPage(IMarkupWriter writer)
IPage.renderPage(IMarkupWriter, IRequestCycle).
This clears all attributes.
renderPage in interface IRequestCycle
public void rewindForm(IForm form,
String targetActionId)
IForm.rewind(IMarkupWriter, IRequestCycle).
The process is expected to end with a RenderRewoundException.
If the entire page is renderred without this exception being thrown, it means
that the target action id was not valid, and a
ApplicationRuntimeException
is thrown.
This clears all attributes.
rewindForm in interface IRequestCycle
public void rewindPage(String targetActionId,
IComponent targetComponent)
IPage.renderPage(IMarkupWriter, IRequestCycle).
The process is expected to end with a RenderRewoundException.
If the entire page is renderred without this exception being thrown, it means
that the target action id was not valid, and a
ApplicationRuntimeException
is thrown.
This clears all attributes.
rewindPage in interface IRequestCycleIAction
public void setAttribute(String name,
Object value)
IRequestCycleHttpServletRequest.setAttribute(),
except that values can be changed and removed as well.
This is used by components to locate each other. A component, such
as Body, will write itself under a well-known name
into the request cycle, and components it wraps can locate it by that name.
setAttribute in interface IRequestCyclepublic void setPage(IPage value)
IRequestCycle
setPage in interface IRequestCyclepublic void setPage(String name)
IRequestCycle
setPage in interface IRequestCyclepublic void commitPageChanges()
IPageRecorder.commit() on each page recorder loaded
during the request cycle (even recorders marked for discard).
commitPageChanges in interface IRequestCycleIPageRecorder.commit()public void observeChange(ObservedChangeEvent event)
page recorder,
we're the change observer.
If such a page actually emits a change, then
we'll obtain a new page recorder from the
engine, set the recorder
as the page's change observer, and forward the event
to the newly created recorder. In addition, the
new page recorder is remembered so that it will
be committed by commitPageChanges().
observeChange in interface ChangeObserverpublic void discardPage(String name)
This may make the application stateful even if the page recorder does not yet exist.
The page recorder will be discarded at the end of the current request cycle.
discardPage in interface IRequestCyclepublic Object[] getServiceParameters()
IRequestCycleIRequestCycle.setServiceParameters(Object[]).
Through release 2.1, the return type was String[]. This is an incompatible change in 2.2.
getServiceParameters in interface IRequestCyclepublic void setServiceParameters(Object[] serviceParameters)
IRequestCycleservice to store an array of application-specific parameters.
These can later be retrieved (typically, by an application-specific listener method)
by invoking IRequestCycle.getServiceParameters().
Through release 2.1, parameters was of type String[]. This is an incompatible change in 2.2.
setServiceParameters in interface IRequestCycleDirectServicepublic void activate(String name)
IRequestCycleIRequestCycle.activate(IPage). Invokes
IRequestCycle.getPage(String) to get an instance of the named page.
activate in interface IRequestCyclepublic void activate(IPage page)
IRequestCycleservice. Frequently,
the active page is changed (from a listener method) to choose
an alternate page to render the response).
IPage.validate(IRequestCycle) is invoked on the
page to be activated. PageRedirectException is caught
and the page specified in the exception will be the
active page instead (that is, a page may "pass the baton" to another
page using the exception). The new page is also validated. This
continues until a page does not throw PageRedirectException.
Validation loops can occur, where page A redirects to page B and then page B
redirects back to page A (possibly with intermediate steps). This is detected and results
in an ApplicationRuntimeException.
activate in interface IRequestCyclepublic String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||