public class RequestCycle extends Object implements IRequestCycle, IEventSink
RequestCycle
consists of two steps:
IRequestHandler
execution the handler can schedule another IRequestHandler
to run after it is done, or replace all IRequestHandler
s on stack with another
IRequestHandler
.scheduleRequestHandlerAfterCurrent(IRequestHandler)
,
replaceAllRequestHandlers(IRequestHandler)
Constructor and Description |
---|
RequestCycle(RequestCycleContext context)
Construct.
|
Modifier and Type | Method and Description |
---|---|
void |
detach()
Detaches
RequestCycle state. |
<T extends IRequestHandler> |
find(Class<T> type)
Finds a IRequestHandler which is either the currently executing handler or is scheduled to be
executed.
|
static RequestCycle |
get()
Returns request cycle associated with current thread.
|
IRequestHandler |
getActiveRequestHandler() |
protected int |
getExceptionRetryCount() |
RequestCycleListenerCollection |
getListeners() |
<T> T |
getMetaData(MetaDataKey<T> key)
Gets metadata for this request cycle using the given key.
|
Response |
getOriginalResponse()
Get the original response the request was created with.
|
Request |
getRequest() |
IRequestHandler |
getRequestHandlerScheduledAfterCurrent() |
Response |
getResponse()
Get the active response at the request cycle.
|
long |
getStartTime() |
UrlRenderer |
getUrlRenderer()
Returns
UrlRenderer for this RequestCycle . |
protected IRequestHandler |
handleException(Exception e)
Return
IRequestHandler for the given exception. |
<C extends Page> |
mapUrlFor(Class<C> pageClass,
PageParameters parameters)
Returns a bookmarkable URL that references a given page class using a given set of page
parameters.
|
Url |
mapUrlFor(IRequestHandler handler)
Returns URL for the request handler or
null if the handler couldn't have been
encoded. |
Url |
mapUrlFor(ResourceReference reference,
PageParameters params)
Returns a
Url for the resource reference |
protected UrlRenderer |
newUrlRenderer() |
protected void |
onBeginRequest()
Called when the request cycle object is beginning its response
|
void |
onDetach()
Called after request processing is complete, usually takes care of detaching state
|
protected void |
onEndRequest()
Called when the request cycle object has finished its response
|
void |
onEvent(IEvent<?> event)
Called when an event is sent to this sink
|
boolean |
processRequest()
Processes the request.
|
boolean |
processRequestAndDetach()
Convenience method that processes the request and detaches the
RequestCycle . |
void |
replaceAllRequestHandlers(IRequestHandler handler) |
protected IRequestHandler |
resolveRequestHandler()
Resolves current request to a
IRequestHandler . |
void |
scheduleRequestHandlerAfterCurrent(IRequestHandler handler)
Schedule the request handler to be executed after the current one.
|
<T> RequestCycle |
setMetaData(MetaDataKey<T> key,
T object)
Sets the metadata for this request cycle using the given key.
|
void |
setRequest(Request request)
INTERNAL This method is for internal Wicket use.
|
Response |
setResponse(Response response)
|
void |
setResponsePage(Class<? extends IRequestablePage> pageClass)
Convenience method for setting next page to be rendered.
|
void |
setResponsePage(Class<? extends IRequestablePage> pageClass,
PageParameters parameters)
Convenience method for setting next page to be rendered.
|
void |
setResponsePage(Class<? extends IRequestablePage> pageClass,
PageParameters parameters,
RenderPageRequestHandler.RedirectPolicy redirectPolicy)
Convenience method for setting next page to be rendered.
|
void |
setResponsePage(Class<? extends IRequestablePage> pageClass,
RenderPageRequestHandler.RedirectPolicy redirectPolicy)
Convenience method for setting next page to be rendered.
|
void |
setResponsePage(IRequestablePage page)
Convenience method for setting next page to be rendered.
|
<C extends Page> |
urlFor(Class<C> pageClass,
PageParameters parameters)
Returns a rendered bookmarkable URL that references a given page class using a given set of
page parameters.
|
CharSequence |
urlFor(IRequestHandler handler)
Returns the rendered URL for the request handler or
null if the handler couldn't
have been rendered. |
CharSequence |
urlFor(ResourceReference reference,
PageParameters params)
Returns a rendered
Url for the resource reference |
public RequestCycle(RequestCycleContext context)
context
- public static RequestCycle get()
null
if no request cycle is associated with
current thread.protected UrlRenderer newUrlRenderer()
public Response getOriginalResponse()
public final UrlRenderer getUrlRenderer()
UrlRenderer
for this RequestCycle
.getUrlRenderer
in interface IRequestCycle
protected IRequestHandler resolveRequestHandler()
IRequestHandler
.protected int getExceptionRetryCount()
public boolean processRequestAndDetach()
RequestCycle
.true
if the request resolved to a Wicket request, false
otherwise.public boolean processRequest()
true
if the request resolved to a Wicket request, false
otherwise.protected IRequestHandler handleException(Exception e)
IRequestHandler
for the given exception.e
- exception to handleIRequestCycleListener.onException(RequestCycle, Exception)
,
IExceptionMapper.map(Exception)
public Request getRequest()
getRequest
in interface IRequestCycle
public void setRequest(Request request)
request
- public final <T> RequestCycle setMetaData(MetaDataKey<T> key, T object)
MetaDataKey
.T
- key
- The singleton key for the metadataobject
- The metadata objectIllegalArgumentException
MetaDataKey
public final <T> T getMetaData(MetaDataKey<T> key)
T
- The type of the metadatakey
- The key for the dataMetaDataKey
public Url mapUrlFor(IRequestHandler handler)
null
if the handler couldn't have been
encoded.
Note: The produced URL is relative to the filter path. Application code most probably need URL relative to the currently used page, for this use urlFor(org.apache.wicket.request.IRequestHandler)
handler
- the request handler
for which to create a callback urlnull
public Url mapUrlFor(ResourceReference reference, PageParameters params)
Url
for the resource reference
Note: The produced URL is relative to the filter path. Application code most probably need URL relative to the currently used page, for this use urlFor(org.apache.wicket.request.resource.ResourceReference, org.apache.wicket.request.mapper.parameter.PageParameters)
reference
- resource referenceparams
- parameters for the resource or null
if noneUrl
for the referencepublic final <C extends Page> Url mapUrlFor(Class<C> pageClass, PageParameters parameters)
Note: The produced URL is relative to the filter path. Application code most probably need URL relative to the currently used page, for this use urlFor(Class, org.apache.wicket.request.mapper.parameter.PageParameters)
C
- The type of the pagepageClass
- Class of pageparameters
- Parameters to page or null
if nonepublic final CharSequence urlFor(ResourceReference reference, PageParameters params)
Url
for the resource referencereference
- resource referenceparams
- parameters for the resource or null
if noneUrl
for the referencepublic final <C extends Page> CharSequence urlFor(Class<C> pageClass, PageParameters parameters)
C
- pageClass
- Class of pageparameters
- Parameters to page or null
if nonepublic CharSequence urlFor(IRequestHandler handler)
null
if the handler couldn't
have been rendered.
The resulting URL will be relative to current page.
handler
- null
public final void detach()
RequestCycle
state. Called after request processing is completepublic void onDetach()
public void setResponsePage(IRequestablePage page)
page
- public void setResponsePage(Class<? extends IRequestablePage> pageClass)
pageClass
- The class of the page to renderpublic void setResponsePage(Class<? extends IRequestablePage> pageClass, RenderPageRequestHandler.RedirectPolicy redirectPolicy)
pageClass
- The class of the page to renderredirectPolicy
- The policy to use when deciding whether to redirect or notpublic void setResponsePage(Class<? extends IRequestablePage> pageClass, PageParameters parameters)
pageClass
- The class of the page to renderparameters
- The query parameters for the page to be renderedpublic void setResponsePage(Class<? extends IRequestablePage> pageClass, PageParameters parameters, RenderPageRequestHandler.RedirectPolicy redirectPolicy)
pageClass
- The class of the page to renderparameters
- The query parameters for the page to be renderedredirectPolicy
- The policy to use when deciding whether to redirect or notpublic final long getStartTime()
public void onEvent(IEvent<?> event)
onEvent
in interface IEventSink
protected void onBeginRequest()
protected void onEndRequest()
public RequestCycleListenerCollection getListeners()
public Response getResponse()
getResponse
in interface IRequestCycle
public Response setResponse(Response response)
Response
with new Response
instance. The original response
is always restored after the IRequestHandler.respond(IRequestCycle)
method is
finished.setResponse
in interface IRequestCycle
public void scheduleRequestHandlerAfterCurrent(IRequestHandler handler)
scheduleRequestHandlerAfterCurrent
in interface IRequestCycle
public IRequestHandler getActiveRequestHandler()
RequestHandlerExecutor.getActive()
public IRequestHandler getRequestHandlerScheduledAfterCurrent()
RequestHandlerExecutor.next()
public void replaceAllRequestHandlers(IRequestHandler handler)
handler
- RequestHandlerExecutor.replaceAll(IRequestHandler)
public <T extends IRequestHandler> Optional<T> find(Class<T> type)
Optional.empty()
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.