|
|||||||||
| Home >> All >> org >> apache >> tapestry >> [ engine overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.tapestry.engine
Class RequestCycle

java.lang.Objectorg.apache.tapestry.engine.RequestCycle
- All Implemented Interfaces:
- org.apache.tapestry.event.ChangeObserver, org.apache.tapestry.IRequestCycle
- public class RequestCycle
- extends java.lang.Object
- implements org.apache.tapestry.IRequestCycle, org.apache.tapestry.event.ChangeObserver
- extends java.lang.Object
Provides the logic for processing a single request cycle. Provides access to the engine and the org.apache.tapestry.request.RequestContext.
| Field Summary | |
static com.cortexeb.tools.clover.d |
__CLOVER_102_0
|
private int |
_actionId
|
private java.util.Map |
_attributes
|
private org.apache.tapestry.IEngine |
_engine
|
private java.util.Map |
_loadedPages
A mapping of pages loaded during the current request cycle. |
private java.util.Map |
_loadedRecorders
A mapping of page recorders for the current request cycle. |
private IMonitor |
_monitor
|
private org.apache.tapestry.IPage |
_page
|
private org.apache.tapestry.request.RequestContext |
_requestContext
|
private javax.servlet.http.HttpServletResponse |
_response
|
private boolean |
_rewinding
|
private IEngineService |
_service
|
private java.lang.Object[] |
_serviceParameters
|
private int |
_targetActionId
|
private org.apache.tapestry.IComponent |
_targetComponent
|
private static org.apache.commons.logging.Log |
LOG
|
| Constructor Summary | |
RequestCycle(org.apache.tapestry.IEngine engine,
org.apache.tapestry.request.RequestContext requestContext,
IEngineService service,
IMonitor monitor)
Standard constructor used to render a response page. |
|
| Method Summary | |
void |
activate(org.apache.tapestry.IPage page)
Sets the active page for the request. |
void |
activate(java.lang.String name)
A convienience for invoking activate(IPage) 55 . |
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() 55 on each page recorder loaded
during the request cycle (even recorders marked for discard). |
private IPageRecorder |
createPageRecorder(java.lang.String name)
Gets the page recorder from the loadedRecorders cache, or from the engine (putting it into loadedRecorders). |
void |
discardPage(java.lang.String name)
Finds the page and its page recorder, creating the page recorder if necessary. |
java.lang.String |
encodeURL(java.lang.String URL)
Passes the String through HttpServletResponse.encodeURL(java.lang.String)> HttpServletResponse.encodeURL(java.lang.String) 55 , which
ensures that the session id is encoded in the URL (if necessary). |
java.lang.Object |
getAttribute(java.lang.String name)
Retrieves a previously stored attribute, returning null if not found. |
org.apache.tapestry.IEngine |
getEngine()
Returns the engine which is processing this request cycle. |
IMonitor |
getMonitor()
|
java.lang.String |
getNextActionId()
Returns the next action id. |
org.apache.tapestry.IPage |
getPage()
Identifies the active page, the page which will ultimately render the response. |
org.apache.tapestry.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. |
org.apache.tapestry.request.RequestContext |
getRequestContext()
|
IEngineService |
getService()
Returns the service which initiated this request cycle. |
java.lang.Object[] |
getServiceParameters()
Returns parameters previously stored by setServiceParameters(Object[]) 55 . |
boolean |
isRewinding()
Returns true if the context is being used to rewind a prior state of the page. |
boolean |
isRewound(org.apache.tapestry.IComponent component)
Checks to see if the current action id matches the target action id. |
void |
observeChange(org.apache.tapestry.event.ObservedChangeEvent event)
For pages without a page recorder, we're the change observer. |
void |
removeAttribute(java.lang.String name)
Removes a previously stored attribute, if one with the given name exists. |
void |
renderPage(org.apache.tapestry.IMarkupWriter writer)
Renders the page by invoking IPage.renderPage(IMarkupWriter, IRequestCycle)> IPage.renderPage(IMarkupWriter, IRequestCycle) 55 . |
void |
rewindForm(org.apache.tapestry.IForm form,
java.lang.String targetActionId)
Rewinds an individual form by invoking IForm.rewind(IMarkupWriter, IRequestCycle)> IForm.rewind(IMarkupWriter, IRequestCycle) 55 . |
void |
rewindPage(java.lang.String targetActionId,
org.apache.tapestry.IComponent targetComponent)
Rewinds the page by invoking IPage.renderPage(IMarkupWriter, IRequestCycle)> IPage.renderPage(IMarkupWriter, IRequestCycle) 55 . |
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 |
setPage(org.apache.tapestry.IPage value)
Sets the page to be rendered. |
void |
setPage(java.lang.String name)
Sets the page to be rendered. |
void |
setServiceParameters(java.lang.Object[] serviceParameters)
Invoked by a service to store an array of application-specific parameters. |
java.lang.String |
toString()
Convert this Object to a human-readable String. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
__CLOVER_102_0
public static com.cortexeb.tools.clover.d __CLOVER_102_0
LOG
private static final org.apache.commons.logging.Log LOG
_page
private org.apache.tapestry.IPage _page
_engine
private org.apache.tapestry.IEngine _engine
_service
private IEngineService _service
_requestContext
private org.apache.tapestry.request.RequestContext _requestContext
_monitor
private IMonitor _monitor
_response
private javax.servlet.http.HttpServletResponse _response
_loadedPages
private java.util.Map _loadedPages
- A mapping of pages loaded during the current request cycle.
Key is the page name, value is the org.apache.tapestry.IPage instance.
_loadedRecorders
private java.util.Map _loadedRecorders
- A mapping of page recorders for the current request cycle.
Key is the page name, value is the IPageRecorder instance.
_rewinding
private boolean _rewinding
_attributes
private java.util.Map _attributes
_actionId
private int _actionId
_targetActionId
private int _targetActionId
_targetComponent
private org.apache.tapestry.IComponent _targetComponent
_serviceParameters
private java.lang.Object[] _serviceParameters
- Since:
- 2.0.3
| Constructor Detail |
RequestCycle
public RequestCycle(org.apache.tapestry.IEngine engine, org.apache.tapestry.request.RequestContext requestContext, IEngineService service, IMonitor monitor)
- Standard constructor used to render a response page.
| Method Detail |
cleanup
public 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.
- Specified by:
cleanupin interfaceorg.apache.tapestry.IRequestCycle
getService
public IEngineService getService()
- Description copied from interface:
org.apache.tapestry.IRequestCycle - Returns the service which initiated this request cycle. This may return
null (very early during the request cycle) if the service has not
yet been determined.
- Specified by:
getServicein interfaceorg.apache.tapestry.IRequestCycle
encodeURL
public java.lang.String encodeURL(java.lang.String URL)
- Description copied from interface:
org.apache.tapestry.IRequestCycle - Passes the String through
HttpServletResponse.encodeURL(java.lang.String)>
HttpServletResponse.encodeURL(java.lang.String)55 , which ensures that the session id is encoded in the URL (if necessary).- Specified by:
encodeURLin interfaceorg.apache.tapestry.IRequestCycle
getEngine
public org.apache.tapestry.IEngine getEngine()
- Description copied from interface:
org.apache.tapestry.IRequestCycle - Returns the engine which is processing this request cycle.
- Specified by:
getEnginein interfaceorg.apache.tapestry.IRequestCycle
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
- Description copied from interface:
org.apache.tapestry.IRequestCycle - Retrieves a previously stored attribute, returning null
if not found. Attributes allow components to locate each other; primarily
they allow a wrapped component to locate a component which wraps it.
- Specified by:
getAttributein interfaceorg.apache.tapestry.IRequestCycle
getMonitor
public IMonitor getMonitor()
- Specified by:
getMonitorin interfaceorg.apache.tapestry.IRequestCycle
getNextActionId
public java.lang.String getNextActionId()
- Description copied from interface:
org.apache.tapestry.IRequestCycle - Returns the next action id. ActionLink ids are used to identify different actions on a
page (URLs that are related to dynamic page state).
- Specified by:
getNextActionIdin interfaceorg.apache.tapestry.IRequestCycle
getPage
public org.apache.tapestry.IPage getPage()
- Description copied from interface:
org.apache.tapestry.IRequestCycle - Identifies the active page, the page which will ultimately render the response.
- Specified by:
getPagein interfaceorg.apache.tapestry.IRequestCycle
getPage
public org.apache.tapestry.IPage getPage(java.lang.String name)
- Gets the page from the engines's IPageSource.
- Specified by:
getPagein interfaceorg.apache.tapestry.IRequestCycle
getPageRecorder
protected IPageRecorder getPageRecorder(java.lang.String name)
- Returns the page recorder for the named page. This may come
from the cycle's cache of page recorders or, if not yet encountered
in this request cycle, the IEngine.getPageRecorder(String, IRequestCycle)>
IEngine.getPageRecorder(String, IRequestCycle)55 is invoked to get the recorder, if it exists.
createPageRecorder
private IPageRecorder createPageRecorder(java.lang.String name)
- Gets the page recorder from the loadedRecorders cache, or from the engine
(putting it into loadedRecorders). If the recorder does not yet exist,
it is created.
- Since:
- 2.0.3
getRequestContext
public org.apache.tapestry.request.RequestContext getRequestContext()
- Specified by:
getRequestContextin interfaceorg.apache.tapestry.IRequestCycle
isRewinding
public boolean isRewinding()
- Description copied from interface:
org.apache.tapestry.IRequestCycle - Returns true if the context is being used to rewind a prior
state of the page. This is only true when there is a target
action id.
- Specified by:
isRewindingin interfaceorg.apache.tapestry.IRequestCycle
isRewound
public boolean isRewound(org.apache.tapestry.IComponent component) throws org.apache.tapestry.StaleLinkException
- Description copied from interface:
org.apache.tapestry.IRequestCycle - Checks to see if the current action id matches the target
action id. Returns true only if they match. Returns false if
there is no target action id (that is, during page rendering).
If theres a match on action id, then the component is compared against the target component. If there's a mismatch then a org.apache.tapestry.StaleLinkException is thrown.
- Specified by:
isRewoundin interfaceorg.apache.tapestry.IRequestCycle
removeAttribute
public void removeAttribute(java.lang.String name)
- Description copied from interface:
org.apache.tapestry.IRequestCycle - Removes a previously stored attribute, if one with the given name exists.
- Specified by:
removeAttributein interfaceorg.apache.tapestry.IRequestCycle
renderPage
public void renderPage(org.apache.tapestry.IMarkupWriter writer)
- Renders the page by invoking
IPage.renderPage(IMarkupWriter, IRequestCycle)>
IPage.renderPage(IMarkupWriter, IRequestCycle)55 . This clears all attributes.- Specified by:
renderPagein interfaceorg.apache.tapestry.IRequestCycle
rewindForm
public void rewindForm(org.apache.tapestry.IForm form, java.lang.String targetActionId)
- Rewinds an individual form by invoking
IForm.rewind(IMarkupWriter, IRequestCycle)>
IForm.rewind(IMarkupWriter, IRequestCycle)55 .The process is expected to end with a org.apache.tapestry.RenderRewoundException. If the entire page is renderred without this exception being thrown, it means that the target action id was not valid, and a org.apache.hivemind.ApplicationRuntimeException is thrown.
This clears all attributes.
- Specified by:
rewindFormin interfaceorg.apache.tapestry.IRequestCycle
- Since:
- 1.0.2
rewindPage
public void rewindPage(java.lang.String targetActionId, org.apache.tapestry.IComponent targetComponent)
- Rewinds the page by invoking
IPage.renderPage(IMarkupWriter, IRequestCycle)>
IPage.renderPage(IMarkupWriter, IRequestCycle)55 .The process is expected to end with a org.apache.tapestry.RenderRewoundException. If the entire page is renderred without this exception being thrown, it means that the target action id was not valid, and a org.apache.hivemind.ApplicationRuntimeException is thrown.
This clears all attributes.
- Specified by:
rewindPagein interfaceorg.apache.tapestry.IRequestCycle
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)
- Description copied from interface:
org.apache.tapestry.IRequestCycle - Allows a temporary object to be stored in the request cycle,
which allows otherwise unrelated objects to communicate. This
is similar to
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 org.apache.tapestry.html.Body, will write itself under a well-known name into the request cycle, and components it wraps can locate it by that name.
- Specified by:
setAttributein interfaceorg.apache.tapestry.IRequestCycle
setPage
public void setPage(org.apache.tapestry.IPage value)
- Description copied from interface:
org.apache.tapestry.IRequestCycle - Sets the page to be rendered. This is called by a component
during the rewind phase to specify an alternate page to render
during the response phase.
- Specified by:
setPagein interfaceorg.apache.tapestry.IRequestCycle
setPage
public void setPage(java.lang.String name)
- Description copied from interface:
org.apache.tapestry.IRequestCycle - Sets the page to be rendered. This is called by a component
during the rewind phase to specify an alternate page to render
during the response phase.
- Specified by:
setPagein interfaceorg.apache.tapestry.IRequestCycle
commitPageChanges
public void commitPageChanges()
- Invokes
IPageRecorder.commit()55 on each page recorder loaded during the request cycle (even recorders marked for discard).- Specified by:
commitPageChangesin interfaceorg.apache.tapestry.IRequestCycle
observeChange
public void observeChange(org.apache.tapestry.event.ObservedChangeEvent event)
- For pages without a 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()55 .- Specified by:
observeChangein interfaceorg.apache.tapestry.event.ChangeObserver
discardPage
public void discardPage(java.lang.String name)
- Finds the page and its page recorder, creating the page recorder if necessary.
The page recorder is marked for discard regardless of its current state.
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.
- Specified by:
discardPagein interfaceorg.apache.tapestry.IRequestCycle
- Since:
- 2.0.2
getServiceParameters
public java.lang.Object[] getServiceParameters()
- Description copied from interface:
org.apache.tapestry.IRequestCycle - Returns parameters previously stored by IRequestCycle.setServiceParameters(Object[])>
IRequestCycle.setServiceParameters(Object[])55 .Through release 2.1, the return type was String[]. This is an incompatible change in 2.2.
- Specified by:
getServiceParametersin interfaceorg.apache.tapestry.IRequestCycle
- Since:
- 2.0.3
setServiceParameters
public void setServiceParameters(java.lang.Object[] serviceParameters)
- Description copied from interface:
org.apache.tapestry.IRequestCycle - Invoked by a 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()>
IRequestCycle.getServiceParameters()55 .Through release 2.1, parameters was of type String[]. This is an incompatible change in 2.2.
- Specified by:
setServiceParametersin interfaceorg.apache.tapestry.IRequestCycle
- Since:
- 2.0.3
activate
public void activate(java.lang.String name)
- Description copied from interface:
org.apache.tapestry.IRequestCycle - A convienience for invoking IRequestCycle.activate(IPage)>
IRequestCycle.activate(IPage)55 . Invokes IRequestCycle.getPage(String)>IRequestCycle.getPage(String)55 to get an instance of the named page.- Specified by:
activatein interfaceorg.apache.tapestry.IRequestCycle
- Since:
- 3.0
activate
public void activate(org.apache.tapestry.IPage page)
- Description copied from interface:
org.apache.tapestry.IRequestCycle - Sets the active page for the request. The active page is the page
which will ultimately render the response. The activate page
is typically set by the service. Frequently,
the active page is changed (from a listener method) to choose
an alternate page to render the response).
IPage.validate(IRequestCycle)>
IPage.validate(IRequestCycle)55 is invoked on the page to be activated. org.apache.tapestry.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 org.apache.tapestry.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 org.apache.tapestry.ApplicationRuntimeException.
- Specified by:
activatein interfaceorg.apache.tapestry.IRequestCycle
- Since:
- 3.0
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object - Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string concatenation with this object. If the result is
null, string concatenation will instead use"null".The default implementation returns
getClass().getName() + "@" + Integer.toHexString(hashCode()).- Since:
- 3.0
|
|||||||||
| Home >> All >> org >> apache >> tapestry >> [ engine overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.apache.tapestry.engine.RequestCycle