public class RequestCycle extends java.lang.Object implements IRequestCycle
engine
and the RequestContext
.Constructor and Description |
---|
RequestCycle()
Alternate constructor used only for testing purposes.
|
RequestCycle(IEngine engine,
QueryParameterMap parameters,
java.lang.String serviceName,
IMonitor monitor,
RequestCycleEnvironment environment,
RequestContext context)
Standard constructor used to render a response page.
|
Modifier and Type | Method and Description |
---|---|
void |
activate(IPage page)
Sets the active page for the request.
|
void |
activate(java.lang.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(java.lang.String name)
As of 4.0, just a synonym for
forgetPage(String) . |
java.lang.String |
encodeURL(java.lang.String URL)
Passes the String through
HttpServletResponse.encodeURL(java.lang.String) , which ensures
that the session id is encoded in the URL (if necessary). |
void |
forgetPage(java.lang.String pageName)
Forgets any stored changes to the specified page.
|
java.lang.String |
getAbsoluteURL(java.lang.String partialURL)
Converts a partial URL into an absolute URL.
|
java.lang.Object |
getAttribute(java.lang.String name)
Retrieves a previously stored attribute, returning null if not found.
|
IEngine |
getEngine()
Returns the engine which is processing this request cycle.
|
Infrastructure |
getInfrastructure()
Returns the central
Infrastructure object used to
manage the processing of the request. |
java.lang.Object[] |
getListenerParameters()
Returns parameters previously stored by
IRequestCycle.setListenerParameters(Object[]) . |
IMonitor |
getMonitor() |
java.lang.String |
getNextActionId()
Deprecated.
|
IPage |
getPage()
Identifies the active page, the page which will ultimately render the response.
|
IPage |
getPage(java.lang.String name)
Gets the page from the engines's
IPageSource . |
protected IPageRecorder |
getPageRecorder(java.lang.String name)
Returns the page recorder for the named page.
|
java.lang.String |
getParameter(java.lang.String name)
Returns a query parameter value, or null if not provided in the request.
|
java.lang.String[] |
getParameters(java.lang.String name)
Returns all query parameter values for the given name.
|
RequestContext |
getRequestContext()
Returns the
RequestContext . |
IEngineService |
getService()
Returns the service which initiated this request cycle.
|
java.lang.Object[] |
getServiceParameters()
Returns parameters previously stored by
IRequestCycle.setServiceParameters(Object[]) . |
java.lang.String |
getUniqueId(java.lang.String baseId)
Returns the provided string, possibly modified (with an appended suffix) to make it unique.
|
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 |
removeAttribute(java.lang.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)
Rewinds an individual form by invoking
IForm.rewind(IMarkupWriter, IRequestCycle) . |
void |
rewindPage(java.lang.String targetActionId,
IComponent targetComponent)
Deprecated.
To be removed in 4.1 with no replacement.
|
void |
sendRedirect(java.lang.String URL)
Sends a redirect to the client web browser.
|
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Allows a temporary object to be stored in the request cycle, which allows otherwise unrelated
objects to communicate.
|
void |
setListenerParameters(java.lang.Object[] parameters)
Invoked by a
service to store an array of application-specific
parameters. |
void |
setServiceParameters(java.lang.Object[] serviceParameters)
Invoked by a
service to store an array of application-specific
parameters. |
java.lang.String |
toString() |
public RequestCycle(IEngine engine, QueryParameterMap parameters, java.lang.String serviceName, IMonitor monitor, RequestCycleEnvironment environment, RequestContext context)
engine
- the current request's engineparameters
- query parameters (possibly the result of ServiceEncoder
s decoding path
information)serviceName
- the name of engine servicemonitor
- informed of various events during the processing of the requestenvironment
- additional invariant services and objects needed by each RequestCycle instancecontext
- Part of (partial) compatibility with Tapestry 3.0public RequestCycle()
public void cleanup()
cleanup
in interface IRequestCycle
public IEngineService getService()
IRequestCycle
getService
in interface IRequestCycle
public java.lang.String encodeURL(java.lang.String URL)
IRequestCycle
HttpServletResponse.encodeURL(java.lang.String)
, which ensures
that the session id is encoded in the URL (if necessary).encodeURL
in interface IRequestCycle
public IEngine getEngine()
IRequestCycle
getEngine
in interface IRequestCycle
public java.lang.Object getAttribute(java.lang.String name)
IRequestCycle
getAttribute
in interface IRequestCycle
public IMonitor getMonitor()
getMonitor
in interface IRequestCycle
public java.lang.String getNextActionId()
IRequestCycle
getNextActionId
in interface IRequestCycle
IRequestCycle.getUniqueId(String)
public IPage getPage()
IRequestCycle
getPage
in interface IRequestCycle
public IPage getPage(java.lang.String name)
IPageSource
.getPage
in interface IRequestCycle
IPageSource.getPage(IRequestCycle, String, IMonitor)
protected IPageRecorder getPageRecorder(java.lang.String name)
public boolean isRewinding()
IRequestCycle
isRewinding
in interface IRequestCycle
public boolean isRewound(IComponent component) throws StaleLinkException
IRequestCycle
If 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 IRequestCycle
StaleLinkException
public void removeAttribute(java.lang.String name)
IRequestCycle
removeAttribute
in interface IRequestCycle
public void renderPage(IMarkupWriter writer)
IPage.renderPage(IMarkupWriter, IRequestCycle)
. This
clears all attributes.renderPage
in interface IRequestCycle
public void rewindForm(IForm form)
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(java.lang.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 IRequestCycle
IAction
,
ActionLink
public void setAttribute(java.lang.String name, java.lang.Object value)
IRequestCycle
HttpServletRequest.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.
Attributes are cleared at the end of each render or rewind phase.
setAttribute
in interface IRequestCycle
public void commitPageChanges()
IPageRecorder.commit()
on each page recorder loaded during the request cycle
(even recorders marked for discard).commitPageChanges
in interface IRequestCycle
IPageRecorder.commit()
public void discardPage(java.lang.String name)
forgetPage(String)
.discardPage
in interface IRequestCycle
public java.lang.Object[] getServiceParameters()
IRequestCycle
IRequestCycle.setServiceParameters(Object[])
.
Through release 2.1, the return type was String[]. This is an incompatible change in 2.2.
getServiceParameters
in interface IRequestCycle
public void setServiceParameters(java.lang.Object[] serviceParameters)
IRequestCycle
service
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 IRequestCycle
DirectService
public java.lang.Object[] getListenerParameters()
IRequestCycle
IRequestCycle.setListenerParameters(Object[])
.getListenerParameters
in interface IRequestCycle
public void setListenerParameters(java.lang.Object[] parameters)
IRequestCycle
service
to store an array of application-specific
parameters. These can later be retrieved (typically, by an application-specific listener
method) by invoking IRequestCycle.getListenerParameters()
.setListenerParameters
in interface IRequestCycle
DirectService
public void activate(java.lang.String name)
IRequestCycle
IRequestCycle.activate(IPage)
. Invokes IRequestCycle.getPage(String)
to
get an instance of the named page.activate
in interface IRequestCycle
public void activate(IPage page)
IRequestCycle
service
.
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 IRequestCycle
public java.lang.String getParameter(java.lang.String name)
IRequestCycle
getParameter
in interface IRequestCycle
public java.lang.String[] getParameters(java.lang.String name)
IRequestCycle
getParameters
in interface IRequestCycle
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getAbsoluteURL(java.lang.String partialURL)
IRequestCycle
request
.getAbsoluteURL
in interface IRequestCycle
public void forgetPage(java.lang.String pageName)
IRequestCycle
forgetPage
in interface IRequestCycle
public Infrastructure getInfrastructure()
IRequestCycle
Infrastructure
object used to
manage the processing of the request.getInfrastructure
in interface IRequestCycle
public RequestContext getRequestContext()
IRequestCycle
RequestContext
. This is provided to ease the upgrade from Tapestry 3.0.getRequestContext
in interface IRequestCycle
public java.lang.String getUniqueId(java.lang.String baseId)
IRequestCycle
getUniqueId
in interface IRequestCycle
baseId
- the base id from which to generate the unique string.public void sendRedirect(java.lang.String URL)
IRequestCycle
RedirectException
, but may change in a later release.sendRedirect
in interface IRequestCycle