Class RequestCycleSettings
- java.lang.Object
-
- org.apache.wicket.settings.RequestCycleSettings
-
public class RequestCycleSettings extends Object
Class for request related settingsbufferResponse (defaults to true) - True if the application should buffer responses. This does require some additional memory, but helps keep exception displays accurate because the whole rendering process completes before the page is sent to the user, thus aRequestCycleSettingsing the possibility of a partially rendered page.
renderStrategy - Sets in what way the render part of a request is handled. Basically, there are two different options:
- Direct, IRequestCycleSettings.RenderStrategy.ONE_PASS_RENDER. Everything is handled in one physical request. This is efficient, and is the best option if you want to do sophisticated clustering. It does not however, shield you from what is commonly known as the Double submit problem
- Using a redirect. This follows the pattern as described at the
serverside and that is commonly known as Redirect after post. Wicket takes it one step
further to do any rendering after a redirect, so that not only form submits are shielded from the
double submit problem, but also the IRequestListener handlers (that could be e.g. a link that
deletes a row). With this pattern, you have two options to choose from:
- IRequestCycleSettings.RenderStrategy.REDIRECT_TO_RENDER. This option first handles the 'action' part of the request, which is either page construction (bookmarkable pages or the home page) or calling a IRequestListener handler, such as Link.onClick. When that part is done, a redirect is issued to the render part, which does all the rendering of the page and its components. Be aware that this may mean, depending on whether you access any models in the action part of the request, that attachment and detachment of some models is done twice for a request.
- IRequestCycleSettings.RenderStrategy.REDIRECT_TO_BUFFER. This option handles both the action- and the render part of the request in one physical request, but instead of streaming the result to the browser directly, it is kept in memory, and a redirect is issued to get this buffered result (after which it is immediately removed). This option currently is the default render strategy, as it shields you from the double submit problem, while being more efficient and less error prone regarding to detachable models.
More documentation is available about each setting in the setter method for the property.
- Author:
- Jonathan Locke, Chris Turner, Eelco Hillenius, Juergen Donnerstag, Johan Compagner, Igor Vaynberg (ivaynberg), Martijn Dashorst, James Carman
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RequestCycleSettings.RenderStrategy
Enum type for different render strategies
-
Constructor Summary
Constructors Constructor Description RequestCycleSettings()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RequestCycleSettings
addResponseFilter(IResponseFilter responseFilter)
Adds a response filter to the list.boolean
getBufferResponse()
Decides whether to buffer the response's headers until the end of the request processing.int
getExceptionRetryCount()
boolean
getGatherExtendedBrowserInfo()
Gets whether Wicket should try to get extensive client info by redirecting toa page that polls for client capabilities
.RequestCycleSettings.RenderStrategy
getRenderStrategy()
Gets in what way the render part of a request is handled.List<IResponseFilter>
getResponseFilters()
String
getResponseRequestEncoding()
In order to do proper form parameter encoding it is important that the response and the subsequent request stipulate a common character encoding.Duration
getTimeout()
Gets the time that a request will by default be waiting for the previous request to be handled before giving up.RequestCycleSettings
setBufferResponse(boolean bufferResponse)
Sets a flag whether the application should buffer the response's headers until the end of the request processing.RequestCycleSettings
setExceptionRetryCount(int retries)
Sets how many attempts Wicket will make to render the exception request handler before giving up.RequestCycleSettings
setGatherExtendedBrowserInfo(boolean gatherExtendedBrowserInfo)
Sets whether Wicket should try to get extensive client info by redirecting toa page that polls for client capabilities
.RequestCycleSettings
setRenderStrategy(RequestCycleSettings.RenderStrategy renderStrategy)
Sets in what way the render part of a request is handled.RequestCycleSettings
setResponseRequestEncoding(String encoding)
In order to do proper form parameter decoding it is important that the response and the following request have the same encoding.RequestCycleSettings
setTimeout(Duration timeout)
Sets the time that a request will by default be waiting for the previous request to be handled before giving up.
-
-
-
Constructor Detail
-
RequestCycleSettings
public RequestCycleSettings()
-
-
Method Detail
-
addResponseFilter
public RequestCycleSettings addResponseFilter(IResponseFilter responseFilter)
Adds a response filter to the list. Filters are evaluated in the order they have been added.- Parameters:
responseFilter
- TheIResponseFilter
that is added- Returns:
this
object for chaining
-
getBufferResponse
public boolean getBufferResponse()
Decides whether to buffer the response's headers until the end of the request processing. The buffering is needed if the application makes use ofComponent.setResponsePage(org.apache.wicket.request.component.IRequestablePage)
orResetResponseException
- Returns:
true
if the application should buffer the response's headers.
-
getGatherExtendedBrowserInfo
public boolean getGatherExtendedBrowserInfo()
Gets whether Wicket should try to get extensive client info by redirecting toa page that polls for client capabilities
. This method is used by the default implementation ofSession.getClientInfo()
, so if that method is overridden, there is no guarantee this method will be taken into account.- Returns:
- Whether to gather extensive client info
-
getRenderStrategy
public RequestCycleSettings.RenderStrategy getRenderStrategy()
Gets in what way the render part of a request is handled.- Returns:
- the render strategy
-
getResponseFilters
public List<IResponseFilter> getResponseFilters()
- Returns:
- an unmodifiable list of added response filters, null if none
-
getResponseRequestEncoding
public String getResponseRequestEncoding()
In order to do proper form parameter encoding it is important that the response and the subsequent request stipulate a common character encoding. possible form encodings and their problems: wicket now uses multipart/form-data for it's forms.- Returns:
- The request and response encoding
-
getTimeout
public Duration getTimeout()
Gets the time that a request will by default be waiting for the previous request to be handled before giving up.- Returns:
- The time out
-
setBufferResponse
public RequestCycleSettings setBufferResponse(boolean bufferResponse)
Sets a flag whether the application should buffer the response's headers until the end of the request processing. The buffering is needed if the application makes use ofComponent.setResponsePage(org.apache.wicket.request.component.IRequestablePage)
orResetResponseException
- Parameters:
bufferResponse
-true
if the application should buffer response's headers.- Returns:
this
object for chaining
-
setGatherExtendedBrowserInfo
public RequestCycleSettings setGatherExtendedBrowserInfo(boolean gatherExtendedBrowserInfo)
Sets whether Wicket should try to get extensive client info by redirecting toa page that polls for client capabilities
. This method is used by the default implementation ofSession.getClientInfo()
, so if that method is overridden, there is no guarantee this method will be taken into account.WARNING: though this facility should work transparently in most cases, it is recommended that you trigger the roundtrip to get the browser info somewhere where it hurts the least. The roundtrip will be triggered the first time you call
Session.getClientInfo()
for a session, and after the roundtrip a new request with the same info (url, post parameters) is handled. So rather than calling this in the middle of an implementation of a form submit method, which would result in the code of that method before the call toSession.getClientInfo()
to be executed twice, you best callSession.getClientInfo()
e.g. in a page constructor or somewhere else where you didn't do a lot of processing first.- Parameters:
gatherExtendedBrowserInfo
- Whether to gather extensive client info- Returns:
this
object for chaining
-
setRenderStrategy
public RequestCycleSettings setRenderStrategy(RequestCycleSettings.RenderStrategy renderStrategy)
Sets in what way the render part of a request is handled. Basically, there are two different options:- Direct, ApplicationSettings.ONE_PASS_RENDER. Everything is handled in one physical request. This is efficient, and is the best option if you want to do sophisticated clustering. It does not however, shield you from what is commonly known as the Double submit problem
- Using a redirect. This follows the pattern as described at
the serverside and that is commonly known as Redirect after post. Wicket takes it one
step further to do any rendering after a redirect, so that not only form submits are shielded
from the double submit problem, but also the IRequestListener handlers (that could be e.g. a
link that deletes a row). With this pattern, you have two options to choose from:
- ApplicationSettings.REDIRECT_TO_RENDER. This option first handles the 'action' part of the request, which is either page construction (bookmarkable pages or the home page) or calling a IRequestListener handler, such as Link.onClick. When that part is done, a redirect is issued to the render part, which does all the rendering of the page and its components. Be aware that this may mean, depending on whether you access any models in the action part of the request, that attachment and detachment of some models is done twice for a request.
- ApplicationSettings.REDIRECT_TO_BUFFER. This option handles both the action- and the render part of the request in one physical request, but instead of streaming the result to the browser directly, it is kept in memory, and a redirect is issue to get this buffered result (after which it is immediately removed). This option currently is the default render strategy, as it shields you from the double submit problem, while being more efficient and less error prone regarding to detachable models.
- Parameters:
renderStrategy
- the render strategy that should be used by default.- Returns:
this
object for chaining
-
setResponseRequestEncoding
public RequestCycleSettings setResponseRequestEncoding(String encoding)
In order to do proper form parameter decoding it is important that the response and the following request have the same encoding. see http://www.crazysquirrel.com/computing/general/form-encoding.jspx for additional information. Default encoding: UTF-8- Parameters:
encoding
- The request and response encoding to be used.- Returns:
this
object for chaining
-
setTimeout
public RequestCycleSettings setTimeout(Duration timeout)
Sets the time that a request will by default be waiting for the previous request to be handled before giving up.- Parameters:
timeout
-- Returns:
this
object for chaining
-
setExceptionRetryCount
public RequestCycleSettings setExceptionRetryCount(int retries)
Sets how many attempts Wicket will make to render the exception request handler before giving up.- Parameters:
retries
- the number of attempts- Returns:
this
object for chaining
-
getExceptionRetryCount
public int getExceptionRetryCount()
- Returns:
- How many times will Wicket attempt to render the exception request handler before giving up.
-
-