|
||||||||||
| 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.
| Field Summary | |
|---|---|
protected ResponseBuilder |
_responseBuilder
|
| Constructor Summary | |
|---|---|
RequestCycle()
Alternate constructor used only for testing purposes. |
|
RequestCycle(IEngine engine,
QueryParameterMap parameters,
String serviceName,
RequestCycleEnvironment environment)
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 |
disableFocus()
Sets client side form focus off globally for all forms in this request cycle. |
void |
discardPage(String name)
As of 4.0, just a synonym for forgetPage(String). |
String |
encodeIdState()
Encodes the current state of all allocated component ids (using IdAllocator)
to a String value that can be embedded in URLs or forms. |
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). |
void |
forgetPage(String pageName)
Forgets any stored changes to the specified page. |
String |
getAbsoluteURL(String partialURL)
Converts a partial URL into an absolute URL. |
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. |
Infrastructure |
getInfrastructure()
Returns the central Infrastructure object used to
manage the processing of the request. |
Object[] |
getListenerParameters()
Returns parameters previously stored by IRequestCycle.setListenerParameters(Object[]). |
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. |
String |
getParameter(String name)
Returns a query parameter value, or null if not provided in the request. |
String[] |
getParameters(String name)
Returns all query parameter values for the given name. |
ResponseBuilder |
getResponseBuilder()
Entry point for getting the response builder used to build this response. |
IEngineService |
getService()
Returns the service which initiated this request cycle. |
String |
getUniqueId(String baseId)
Returns the provided string, possibly modified (with an appended suffix) to make it unique. |
void |
initializeIdState(String encodedSeed)
Used in conjunction with IRequestCycle.encodeIdState() to re-initialize the internal id allocation state
of a request during a form rewind. |
boolean |
isFocusDisabled()
Check for global focus being disabled. |
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. |
String |
peekUniqueId(String baseId)
Returns what will be the next unique id generated based on the given input, but doesn't store the result. |
void |
removeAttribute(String name)
Removes a previously stored attribute, if one with the given name exists. |
void |
renderPage(ResponseBuilder builder)
Renders the page by invoking IPage.renderPage(ResponseBuilder, IRequestCycle). |
boolean |
renderStackEmpty()
Tests if the render component chain is empty, meaning no components have been loaded onto the stack yet. |
Iterator |
renderStackIterator()
Creates a traversable iterator for moving through the stack. |
IRender |
renderStackPeek()
Looks at the object at the top of the render stack without removing the IRender from the stack. |
IRender |
renderStackPop()
Removes the IRender at the top of the stack, if any. |
IRender |
renderStackPush(IRender render)
Pushes the specified render onto the current render stack. |
int |
renderStackSearch(IRender render)
Returns the 1-based position where an object is on this stack. |
void |
rewindForm(IForm form)
Rewinds an individual form by invoking IForm.rewind(IMarkupWriter, IRequestCycle). |
void |
sendRedirect(String URL)
Sends a redirect to the client web browser. |
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 |
setListenerParameters(Object[] parameters)
Invoked by a service to store an array of application-specific
parameters. |
void |
setResponseBuilder(ResponseBuilder builder)
Sets the ResponseBuilder to use for this response, don't
try setting this unless you're very sure you know what you are doing as
this isn't the only way that it is used. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected ResponseBuilder _responseBuilder
| Constructor Detail |
|---|
public RequestCycle(IEngine engine,
QueryParameterMap parameters,
String serviceName,
RequestCycleEnvironment environment)
engine - the current request's engineparameters - query parameters (possibly the result of ServiceEncoders decoding path
information)serviceName - the name of engine serviceenvironment - additional invariant services and objects needed by each RequestCycle instancepublic RequestCycle()
| 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 IRequestCycleURL - The url to encode.
public IEngine getEngine()
IRequestCycle
getEngine in interface IRequestCyclepublic Object getAttribute(String name)
IRequestCycle
getAttribute in interface IRequestCyclename - The name of the attribute to retrieve.
public IPage getPage()
IRequestCycle
getPage in interface IRequestCyclepublic IPage getPage(String name)
IPageSource.
getPage in interface IRequestCyclename - The page to get a reference to.
IPageSource.getPage(IRequestCycle, String)protected IPageRecorder getPageRecorder(String name)
public void setResponseBuilder(ResponseBuilder builder)
IRequestCycleResponseBuilder to use for this response, don't
try setting this unless you're very sure you know what you are doing as
this isn't the only way that it is used. (ie replacing this builder won't
necessarily override another builder being used already)
setResponseBuilder in interface IRequestCyclebuilder - The response builder that may be used by components
to help with delegate/sub component rendering.public ResponseBuilder getResponseBuilder()
IRequestCycle
getResponseBuilder in interface IRequestCyclepublic boolean renderStackEmpty()
renderStackEmpty in interface IRequestCyclepublic IRender renderStackPeek()
IRender from the stack.
renderStackPeek in interface IRequestCyclepublic IRender renderStackPop()
IRender at the top of the stack, if any.
renderStackPop in interface IRequestCycleIRender, if any.public IRender renderStackPush(IRender render)
renderStackPush in interface IRequestCyclerender - The IRender object being pushed.
IRender.public int renderStackSearch(IRender render)
renderStackSearch in interface IRequestCyclerender - The IRender being searched for.
public Iterator renderStackIterator()
renderStackIterator in interface IRequestCyclepublic boolean isRewinding()
IRequestCycle
isRewinding in interface IRequestCyclepublic boolean isRewound(IComponent component)
IRequestCycle
If theres a match on action id, then the component is compared against the target component.
If there's a mismatch then a StaleLinkExceptionis thrown.
isRewound in interface IRequestCyclecomponent - The component to check.
public void removeAttribute(String name)
IRequestCycle
removeAttribute in interface IRequestCyclename - The key name of the attribute to remove.public void renderPage(ResponseBuilder builder)
IPage.renderPage(ResponseBuilder, IRequestCycle). This
clears all attributes.
renderPage in interface IRequestCyclebuilder - Renders the currently active page using the specified builder.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 IRequestCycleform - The form to rewind.public void disableFocus()
disableFocus in interface IRequestCyclepublic boolean isFocusDisabled()
isFocusDisabled in interface IRequestCycle
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.
Attributes are cleared at the end of each render or rewind phase.
setAttribute in interface IRequestCyclename - Key name of the attribute to store.value - Value of the attribute.public 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 discardPage(String name)
forgetPage(String).
public Object[] getListenerParameters()
IRequestCycleIRequestCycle.setListenerParameters(Object[]).
getListenerParameters in interface IRequestCyclepublic void setListenerParameters(Object[] parameters)
IRequestCycleservice 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 IRequestCycleparameters - The parameters to set which will be available as method parameters
to any listeners invoked in this request.DirectServicepublic void activate(String name)
IRequestCycleIRequestCycle.activate(IPage). Invokes IRequestCycle.getPage(String)to
get an instance of the named page.
activate in interface IRequestCyclename - The name of the page to activate.public 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.
PageRedirectExceptionis 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 IRequestCyclepage - The page to activate.public String getParameter(String name)
IRequestCycle
getParameter in interface IRequestCyclename - The name of the request parameter to retrieve.
public String[] getParameters(String name)
IRequestCycle
getParameters in interface IRequestCyclename - The name of the parameters to retrieve.
public String toString()
toString in class Objectpublic String getAbsoluteURL(String partialURL)
IRequestCyclerequest.
getAbsoluteURL in interface IRequestCyclepartialURL - The url to modify into an absolute url.
public void forgetPage(String pageName)
IRequestCycle
forgetPage in interface IRequestCyclepageName - The name of the page instance to throw all persistent properties away for.public Infrastructure getInfrastructure()
IRequestCycleInfrastructure object used to
manage the processing of the request.
getInfrastructure in interface IRequestCycleInfrastructure object associated with this request.public String getUniqueId(String baseId)
IRequestCycle
getUniqueId in interface IRequestCyclebaseId - the base id from which to generate the unique string.
public String peekUniqueId(String baseId)
IRequestCycle
peekUniqueId in interface IRequestCyclebaseId - the base id from which to generate the unique string.
public void sendRedirect(String URL)
IRequestCycleRedirectException, but may change in a later release.
sendRedirect in interface IRequestCycleURL - The url to send a client redirect for.public String encodeIdState()
IRequestCycleIdAllocator)
to a String value that can be embedded in URLs or forms.
This method is used primarily by the Form component to encode the state
of the current ids allocated so as to maintain consistent state during rewind - especially in cases where
multiple form components are rendered in a page.
encodeIdState in interface IRequestCycleIRequestCycle.initializeIdState(String).public void initializeIdState(String encodedSeed)
IRequestCycleIRequestCycle.encodeIdState() to re-initialize the internal id allocation state
of a request during a form rewind.
initializeIdState in interface IRequestCycleencodedSeed - The value returned from a previous invocation of IRequestCycle.encodeIdState() .
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||