Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * Licensed to the Apache Software Foundation (ASF) under one or more
    * contributor license agreements.  See the NOTICE file distributed with
    * this work for additional information regarding copyright ownership.
    * The ASF licenses this file to You under the Apache License, Version 2.0
    * (the "License"); you may not use this file except in compliance with
    * the License.  You may obtain a copy of the License at
    *
    *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.wicket;
  
  import java.util.Map;
  
  import org.slf4j.Logger;
Represents the processing of a request. It is responsible for instructing the request cycle processor to execute the various steps there are in the handling of a request (resolving the kind of work that needs to be done, handling of events and generating a response), and it holds the intended request target, which is an abstraction for e.g. the processing of a bookmarkable page.

The abstract urlFor() methods are implemented by subclasses of RequestCycle and return encoded page URLs. The URL returned depends on the kind of page being linked to. Pages broadly fall into two categories:

1. A page that does not yet exist in a user Session may be encoded as a URL that references the not-yet-created page by class name. A set of PageParameters can also be encoded into the URL, and these parameters will be passed to the page constructor if the page later needs to be instantiated.

Any page of this type is bookmarkable, and a hint to that effect is given to the user in the URL:

    /[Application]?bookmarkablePage=[classname]&[param]=[value] [...]

Bookmarkable pages must either implement a constructor that takes a PageParameters argument or a default constructor. If a Page has both constructors the constructor with the PageParameters argument will be used. Links to bookmarkable pages are created by calling the urlFor(Class, PageParameters) method, where Class is the page class and PageParameters are the parameters to encode into the URL.

2. Stateful pages (that have already been requested by a user) will be present in the user's Session and can be referenced securely with a session-relative number:

    /[Application]?wicket:interface=[pageMapName]:[pageId]: ...

Often, the reason to access an existing session page is due to some kind of "postback" (either a link click or a form submit) from a page (possibly accessed with the browser's back button or possibly not). A call to a registered listener is dispatched like so:

    /[Application]?wicket:interface=[pageMapName]:[pageId]:[componentPath]:[version]:[interfaceName]

For example:

    /[Application]?wicket:interface=:3:signInForm:submit::IFormSubmitListener

URLs for stateful pages (those that already exist in the session map) are created by calling the urlFor(Component, Class) method, where Component is the component being linked to and Class is the interface on the component to call.

For pages falling into the second category, listener interfaces cannot be invoked unless they have first been registered via the static registerSecureInterface() method. This method ensures basic security by restricting the set of interfaces that outsiders can call via GET and POST requests. Each listener interface has a single method which takes only a RequestCycle parameter. Currently, the following classes register the following kinds of listener interfaces:

ClassInterfacePurpose
FormIFormSubmitListenerHandle form submits
ImageIResourceListenerRespond to image resource requests
LinkILinkListenerRespond to link clicks
PageIRedirectListenerRespond to redirects

The redirectToInterceptPage() and continueToOriginalDestination() methods can be used to temporarily redirect a user to some page. This is mainly intended for use in signing in users who have bookmarked a page inside a site that requires the user be authenticated before they can access the page. When it is discovered that the user is not signed in, the user is redirected to the sign-in page with redirectToInterceptPage(). When the user has signed in, they are sent on their way with continueToOriginalDestination(). These methods could also be useful in "interstitial" advertising or other kinds of "intercepts".

Author(s):
Jonathan Locke
Eelco Hillenius
Igor Vaynberg (ivaynberg)
 
 public abstract class RequestCycle
 {
Thread-local that holds the current request cycle.
 
 	private static final ThreadLocal current = new ThreadLocal();

Cleaning up after responding to a request.
 
 	private static final int DETACH_REQUEST = 5;

Request cycle processing is done.
 
 	private static final int DONE = 6;

Log
 
 	private static final Logger log = LoggerFactory.getLogger(RequestCycle.class);

No processing has been done.
 
 	private static final int NOT_STARTED = 0;

Starting the actual request processing.
 
 	private static final int PREPARE_REQUEST = 1;

Dispatching and handling of events.
 
 	private static final int PROCESS_EVENTS = 3;

Resolving the org.apache.wicket.request.RequestParameters object to a request target.
 
 	private static final int RESOLVE_TARGET = 2;

Responding using the currently set IRequestTarget.
 
 	private static final int RESPOND = 4;

Gets request cycle for calling thread.

Returns:
Request cycle for calling thread
 
 	public static RequestCycle get()
 	{
 		return (RequestCycle).get();
 	}

Sets the request cycle for the calling thread. You typically DO NOT NEED to call this method, as the request cycle is set to current for you in the constructor. However, if you have a very special need to set it to something else, you can expose this method.

Parameters:
cycle The request cycle to set current
 
 	protected static void set(RequestCycle cycle)
 	{
 		.set(cycle);
 	}
 
 	private RequestCycle previousOne = null;

True if the request cycle should automatically clear feedback messages after processing. True by default.
 
 	private boolean automaticallyClearFeedbackMessages = true;

The current stage of event processing.
 
 	private int currentStep = ;
 
 	private boolean handlingException = false;

The original response the request cycle was created with.
 
 	private final Response originalResponse;

True if request should be redirected to the resulting page instead of just rendering it back to the user.
 
 	private boolean redirect;

holds the stack of set IRequestTarget, the last set op top.
 
 	private transient final ArrayListStack requestTargets = new ArrayListStack(3)
 	{
 		private static final long serialVersionUID = 1L;
 
 		public void add(int arg0Object arg1)
 		{
 			super.add(arg0arg1);
 		}
 
 		public boolean add(Object arg0)
 		{
 			return super.add(arg0);
 		}
 
 		public boolean addAll(Collection arg0)
 		{
 			Iterator it = arg0.iterator();
 			while (it.hasNext())
 			{
 			}
 			return super.addAll(arg0);
 		}
 
 		public boolean addAll(int arg0Collection arg1)
 		{
 			Iterator it = arg1.iterator();
 			while (it.hasNext())
 			{
 			}
 			return super.addAll(arg0arg1);
 		}
 	};

Any page parameters. Only set when the request is resolving and the parameters are passed into a page.
 
The session object.
 
 	private Session session;

the time that this request cycle object was created.
 
 	private final long startTime = System.currentTimeMillis();

The application object.
 
 	protected final Application application;

The processor for this request.
 
 	protected final IRequestCycleProcessor processor;

The current request.
 
 	protected Request request;

The current response.
 
 	protected Response response;

Boolean if the next to be encoded url is targeting a new window (ModalWindow, popup, tab). This temporary flag is specifically needed for portlet-support as then such a page needs a special target (Resource) url. After each urlFor call, this flag is reset to false.
 
 	private transient boolean urlForNewWindowEncoding;

Constructor. This instance will be set as the current one for this thread.

Parameters:
application The application
request The request
response The response
 
 	protected RequestCycle(final Application applicationfinal Request request,
 		final Response response)
 	{
 		this. = application;
 		this. = request;
 		this. = response;
 		 = response;
 
 		// Set this RequestCycle into ThreadLocal variable
 		.set(this);
 	}

Gets the application object.

Returns:
Application interface
 
 	public final Application getApplication()
 	{
 		return ;
 	}

Gets the new agent info object for this session. This method calls Session.getClientInfo(), which may or may not cache the client info object and typically calls newClientInfo() when no client info object was cached.

Returns:
the agent info object based on this request
 
 	public final ClientInfo getClientInfo()
 	{
 	}

Get the original response the request was create with. Access may be necessary with the response has temporarily being replaced but your components requires access to lets say the cookie methods of a WebResponse.

Returns:
The original response object.
 
 	public final Response getOriginalResponse()
 	{
 	}

Any set page parameters. Typically only available when a request to a bookmarkable page with a Page.(org.apache.wicket.PageParameters) constructor was made.

Returns:
the page parameters or null
 
 	{
 		return ;
 	}

Gets the processor for delegated request cycle handling.

Returns:
the processor for delegated request cycle handling
 
 	public abstract IRequestCycleProcessor getProcessor();

Gets whether the page for this request should be redirected.

Deprecated:
Use isRedirect() instead
Returns:
whether the page for this request should be redirected
 
 	public final boolean getRedirect()
 	{
 		return isRedirect();
 	}

Gets the request.

Returns:
Request object
 
 	public final Request getRequest()
 	{
 		return ;
 	}

Gets the current request target. May be null.

Returns:
the current request target, null if none was set yet.
 
 	public final IRequestTarget getRequestTarget()
 	{
 	}

Gets the response.

Returns:
Response object
 
 	public final Response getResponse()
 	{
 		return ;
 	}

Gets the page that is to be rendered for this request in case the last set request target is of type org.apache.wicket.request.target.component.PageRequestTarget.

Returns:
the page or null
 
 	public final Page getResponsePage()
 	{
 		if (target instanceof IPageRequestTarget)
 		{
 			return ((IPageRequestTarget)target).getPage();
 		}
 		else if (target instanceof BookmarkablePageRequestTarget)
 		{
 		}
 		return null;
 	}

Gets the page class that is to be instantiated and rendered for this request in case the last set request target is of type org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.

Returns:
the page class or null
 
 	public final Class getResponsePageClass()
 	{
 		if (target != null && (target instanceof IBookmarkablePageRequestTarget))
 		{
 		}
 		return null;
 	}

Gets the session.

Returns:
Session object
 
 	public final Session getSession()
 	{
 		if ( == null)
 		{
 			 = Session.get();
 		}
 		return ;
 	}

Returns:
The start time for this request
 
 	public final long getStartTime()
 	{
 		return ;
 	}

Gets whether the page for this request should be redirected.

Returns:
whether the page for this request should be redirected
 
 	public boolean isRedirect()
 	{
 		return ;
 	}

Template method that is called when a runtime exception is thrown, just before the actual handling of the runtime exception. This is called by org.apache.wicket.request.AbstractRequestCycleProcessor.respond(java.lang.RuntimeException,org.apache.wicket.RequestCycle).

Parameters:
page Any page context where the exception was thrown
e The exception
Returns:
Any error page to redirect to
 
 	{
 		return null;
 	}

THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.

Redirects browser to the given page. Don't use this method directly, but use setResponsePage(org.apache.wicket.Page) instead.

Parameters:
page The page to redirect to
 
 	public abstract void redirectTo(final Page page);

THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.

Responds to a request.

 
 	public final void request()
 	{
 
 		// set start step
 
 		// loop through steps
 		steps();
 	}

THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.

Responds to a request to re-render a single component.

NOTE: This method is typically only used for testing purposes.

Parameters:
component to be re-rendered
 
 	public final void request(final Component component)
 	{
 
 		if (component.isAuto())
 		{
 			throw new WicketRuntimeException("Auto-added components can not be re-rendered");
 		}
 
 		request(new ComponentRequestTarget(component));
 	}

THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.

Responds to a request with the request target.

Parameters:
target request target
 
 	public final void request(IRequestTarget target)
 	{
 
 		// set it as the current target, on the top of the stack
 
 		// set start step
 
 		// loop through steps
 		steps();
 	}

Permit clients like testers to examine feedback messages after processing.

Parameters:
automaticallyClearFeedbackMessages True to automatically detach request cycle at end of processing
 
 	public void setAutomaticallyClearFeedbackMessages(boolean automaticallyClearFeedbackMessages)
 	{
 		// FIXME This method is a quick fix for a unit testing problem that
 		// should not exist
 		this. = automaticallyClearFeedbackMessages;
 	}

Sets whether the page for this request should be redirected.

Parameters:
redirect True if the page for this request cycle should be redirected to rather than directly rendered.
 
 	public final void setRedirect(final boolean redirect)
 	{
 		this. = redirect;
 	}

Parameters:
request The request to set.
 
 	public final void setRequest(Request request)
 	{
 		this. = request;
 	}

Sets the request target as the current.

Parameters:
requestTarget the request target to set as current
 
 	public final void setRequestTarget(IRequestTarget requestTarget)
 	{
 		{
 			{
 				.debug("replacing request target " + former + " with " + requestTarget);
 			}
 			else
 			{
 				.debug("setting request target to " + requestTarget);
 			}
 		}
 
 		// change the current step to a step that will handle the
 		// new target if need be
 		if ( >= )
 		{
 			{
 				.debug("rewinding request processing to PROCESS_EVENTS");
 			}
 
 			// we are not actually doing event processing again,
 			// but since we are still in the loop here, the next
 			// actual value will be RESPOND again
 		}
 		// NOTE: if we are at PROCESS_EVENTS, leave it as we don't
 		// want to re-execute that step again
 
 		.push(requestTarget);
 	}

Called when a request target is set on the request cycle

Parameters:
requestTarget
 
 	protected void onRequestTargetSet(IRequestTarget requestTarget)
 	{
 	}

Sets response.

Parameters:
response The response
Returns:
the original response
 
 	public final Response setResponse(final Response response)
 	{
 		final Response orig = this.;
 		this. = response;
 		return orig;
 	}

Attempts to return name of current page map

Returns:
name of current page map
 
 	{
 		IRequestTarget target = RequestCycle.get().getRequestTarget();
 		if (target instanceof IPageRequestTarget)
 		{
 			Page page = ((IPageRequestTarget)target).getPage();
 			return page != null ? page.getPageMapName() : null;
 		}
 		else if (target instanceof IBookmarkablePageRequestTarget)
 		{
 		}
 		else
 		{
 			return null;
 		}
 	}

Convenience method that sets page class as the response. This will generate a redirect to the page with a bookmarkable url

Parameters:
pageClass The page class to render as a response
 
 	public final void setResponsePage(final Class pageClass)
 	{
 		setResponsePage(pageClassnull);
 	}

Sets the page class with optionally the page parameters as the render target of this request.

Parameters:
pageClass The page class to render as a response
pageParameters The page parameters that gets appended to the bookmarkable url,
 
 	public final void setResponsePage(final Class pageClassfinal PageParameters pageParameters)
 	{
 		setResponsePage(pageClasspageParametersgetCurrentPageMap());
 	}

Sets the page class with optionally the page parameters and page map name as the render target of this request.

Parameters:
pageClass The page class to render as a response
pageParameters The page parameters that gets appended to the bookmarkable url,
pageMapName The pagemap in which the response page should be created
 
 	public final void setResponsePage(final Class pageClassfinal PageParameters pageParameters,
 		final String pageMapName)
 	{
 		IRequestTarget target = new BookmarkablePageRequestTarget(pageMapNamepageClass,
 			pageParameters);
 	}

Sets the page as the render target of this request.

Parameters:
page The page to render as a response
 
 	public final void setResponsePage(final Page page)
 	{
 		IRequestTarget target = new PageRequestTarget(page);
 	}

 
 	public String toString()
 	{
 		return "[RequestCycle" + "@" + Integer.toHexString(hashCode()) + " thread=" +
 			Thread.currentThread().getName() + "]";
 	}

Returns:
true if the next to be encoded url is targeting a new window (ModalWindow, popup, tab).
 
 	public final boolean isUrlForNewWindowEncoding()
 	{
 	}

Indicate if the next to be encoded url is targeting a new window (ModalWindow, popup, tab). This temporary flag is specifically needed for portlet-support as then such a page needs a special target (Resource) url. After each urlFor call, this flag is reset to false.
 
 	public final void setUrlForNewWindowEncoding()
 	{
 	}

Returns an encoded URL that references the given request target and clears the urlForNewWindowEncoding flag.

Parameters:
requestTarget the request target to reference
Returns:
a URL that references the given request target
 
 	private final CharSequence encodeUrlFor(final IRequestTarget requestTarget)
 	{
 		CharSequence url = getProcessor().getRequestCodingStrategy().encode(thisrequestTarget);
 		return url;
 	}

Returns a bookmarkable URL that references a given page class using a given set of page parameters. Since the URL which is returned contains all information necessary to instantiate and render the page, it can be stored in a user's browser as a stable bookmark.

Parameters:
pageClass Class of page
parameters Parameters to page
Returns:
Bookmarkable URL to page
 
 	public final CharSequence urlFor(final Class pageClassfinal PageParameters parameters)
 	{
 		return urlFor(nullpageClassparameters);
 	}

Returns a URL that references a given interface on a given behavior of a component. When the URL is requested from the server at a later time, the interface on the behavior will be called. A URL returned by this method will not be stable across sessions and cannot be bookmarked by a user.

Parameters:
component The component to reference
behaviour The behavior to reference
listener The listener interface on the component
Returns:
A URL that encodes a page, component, behavior and interface to call
 
 	public final CharSequence urlFor(final Component componentfinal IBehavior behaviour,
 		final RequestListenerInterface listener)
 	{
 		int index = component.getBehaviorsRawList().indexOf(behaviour);
 		if (index == -1)
 		{
 			throw new IllegalArgumentException("Behavior " + this +
 				" was not registered with this component: " + component.toString());
 		}
 		params.setBehaviorId(String.valueOf(index));
 		if ( instanceof ServletWebRequest)
 		{
 			// If we're coming in with an existing depth, use it. Otherwise,
 			// compute from the URL. This provides correct behavior for repeated
 			// AJAX requests: If we need to generate a URL within an AJAX
 			// request for another one, it needs to be at the same depth as the
 			// original AJAX request.
 			int urlDepth = swr.getRequestParameters().getUrlDepth();
 			params.setUrlDepth(urlDepth > -1 ? urlDepth : swr.getDepthRelativeToWicketHandler());
 		}
 
 		final IRequestTarget target = new BehaviorRequestTarget(component.getPage(), component,
 			listenerparams);
 		return encodeUrlFor(target);
 	}

Returns a URL that references a given interface on a component. When the URL is requested from the server at a later time, the interface will be called. A URL returned by this method will not be stable across sessions and cannot be bookmarked by a user.

Parameters:
component The component to reference
listener The listener interface on the component
params Additional parameters to pass to the page
Returns:
A URL that encodes a page, component and interface to call
 
 	public final CharSequence urlFor(final Component component,
 		final RequestListenerInterface listenerValueMap params)
 	{
 		// Get Page holding component and mark it as stateful.
 		final Page page = component.getPage();
 		final IRequestTarget target;
 		if (listener != . && component.isStateless() &&
 			page.isBookmarkable() && page.getStatelessHint())
 		{
 			PageParameters pageParameters = page.getPageParameters();
 			if (pageParameters == null)
 			{
 				pageParameters = new PageParameters();
 			}
 			else
 			{
 				pageParameters = (PageParameters)pageParameters.clone();
 			}
 
 			if (params != null)
 			{
 				Iterator it = params.entrySet().iterator();
 				while (it.hasNext())
 				{
 					final Map.Entry entry = (Entry)it.next();
 					final String key = entry.getKey().toString();
 					final String value = entry.getValue().toString();
 					// Do not encode values here. It is the encoder's job
 					// to do the endoding. This leads to double encoding
 					// - Doug Donohoe
 					// @see https://issues.apache.org/jira/browse/WICKET-1627
 					// pageParameters.add(encodeQueryStringItem(key), encodeQueryStringItem(value));
 					pageParameters.add(keyvalue);
 				}
 			}
 
 				page.getClass(), pageParameterscomponentlistener);
 			return encodeUrlFor(target);
 		}
 		else
 		{
 
 			// make session non-volatile if not already so
 			final Session session = getSession();
 			if (session.isTemporary())
 			{
 				session.bind();
 			}
 
 			// Get the listener interface name
 			target = new ListenerInterfaceRequestTarget(pagecomponentlistener);
 
 			CharSequence url = encodeUrlFor(target);
 
 			if (params != null)
 			{
 				Iterator it = params.entrySet().iterator();
 				while (it.hasNext())
 				{
 					final Map.Entry entry = (Entry)it.next();
 					final String key = entry.getKey().toString();
 					final String value = entry.getValue().toString();
 					buff.append("&");
 					buff.append("=");
 				}
 
 				url = buff;
 			}
 			return url;
 		}
 
 	}

Url encodes value using UTF-8

Parameters:
value value to encode
Returns:
encoded value
 
 	private static String encodeQueryStringItem(String value)
 	{
 	}

Returns a URL that references a given interface on a component. When the URL is requested from the server at a later time, the interface will be called. A URL returned by this method will not be stable across sessions and cannot be bookmarked by a user.

Parameters:
component The component to reference
listener The listener interface on the component
Returns:
A URL that encodes a page, component and interface to call
 
 	public final CharSequence urlFor(final Component component,
 		final RequestListenerInterface listener)
 	{
 		return urlFor(componentlistenernull);
 	}

Returns a bookmarkable URL that references a given page class using a given set of page parameters. Since the URL which is returned contains all information necessary to instantiate and render the page, it can be stored in a user's browser as a stable bookmark.

Parameters:
pageMap Pagemap to use. If null is passed the default page map will be used
pageClass Class of page
parameters Parameters to page
Returns:
Bookmarkable URL to page
 
 	public final CharSequence urlFor(final IPageMap pageMapfinal Class pageClass,
 		final PageParameters parameters)
 	{
 		final IRequestTarget target = new BookmarkablePageRequestTarget(pageMap == null
 			? . : pageMap.getName(), pageClassparameters);
 		return encodeUrlFor(target);
 	}

Returns a URL that references the given request target.

Parameters:
requestTarget the request target to reference
Returns:
a URL that references the given request target
	public final CharSequence urlFor(final IRequestTarget requestTarget)
		return encodeUrlFor(requestTarget);
	}

Returns a URL that references the given page. It also touches the page in the session so that it is put in the front of the page stack. Use this method only if you plan to use it the next request.

Parameters:
page The page
Returns:
The url pointing to the provided page
	public final CharSequence urlFor(final Page page)
		IRequestTarget target = new PageRequestTarget(page);
		return encodeUrlFor(target);
	}

Returns a URL that references a shared resource through the provided resource reference.

Parameters:
resourceReference The resource reference where a url must be generated for.
Returns:
The url for the shared resource
	public final CharSequence urlFor(final ResourceReference resourceReference)
		return urlFor(resourceReferencenull);
	}

Returns a URL that references a shared resource through the provided resource reference.

Parameters:
resourceReference The resource reference where a url must be generated for.
parameters The parameters to pass to the resource.
Returns:
The url for the shared resource
	public final CharSequence urlFor(final ResourceReference resourceReferenceValueMap parameters)
		RequestParameters requestParameters = new RequestParameters();
		requestParameters.setResourceKey(resourceReference.getSharedResourceKey());
			!Strings.isEmpty(resourceReference.getName()))
			Time time = resourceReference.lastModifiedTime();
			if (time != null)
				if (parameters == null)
					parameters = new ValueMap();
					parameters.put("wicket:lm"new Long(time.getMilliseconds()));
		requestParameters.setParameters(parameters);
		return encodeUrlFor(new SharedResourceRequestTarget(requestParameters));
	}

Checks whether no processing has been done yet and throws an exception when a client tries to reuse this instance.
	private void checkReuse()
				"RequestCycles are non-reusable objects. This instance (" + this +
					") already executed");
	}

THIS METHOD IS WICKET PRIVATE API. DO NOT CALL UNLESS YOU KNOW WHAT YOU ARE DOING. Clean up the request cycle.
	public void detach()
		// clean up target stack; calling detach has effects like
		// NOTE: don't remove the targets as testing code might need them
		// furthermore, the targets will be gc-ed with this cycle too
		for (int i = 0; i < .size(); i++)
			if (target != null)
				try
					target.detach(this);
				catch (Throwable e)
					.error("there was an error cleaning up target " + target + "."e);
			// remove any rendered and otherwise obsolete feedback messages from
			// the session
			try
			catch (Throwable re)
				.error("there was an error cleaning up the feedback messages"re);
		// let the session cleanup after a request, flushing changes etc.
			try
			catch (Throwable re)
				.error("there was an error detaching the request from the session " +  +
					"."re);
		if (getResponse() instanceof BufferedWebResponse)
			try
			catch (Throwable re)
				.error("there was an error filtering the response."re);
		try
		catch (Throwable e)
			.error("Exception occurred during onEndRequest"e);
		try
		catch (Throwable e)
			.error("Exception occurred during onEndRequest of the SessionStore"e);
		// if we have a request logger, update that now
		try
			if (requestLogger != null)
				requestLogger.requestTime((System.currentTimeMillis() - ));
		catch (Throwable re)
			.error("there was an error in the RequestLogger ending."re);
		// Release thread local resources
		try
		catch (Throwable re)
			.error("Exception occurred during threadDetach"re);
	}

Prepare the request cycle.
	private void prepare()
		try
			.error("Exception occurred during onEndRequest of the SessionStore"e);
		// Event callback
	}

Call the event processing and and respond methods on the request processor and apply synchronization if needed.
	private final void processEventsAndRespond()
		// let the processor handle/ issue any events
		// set current stage manually this time
		// generate a response
	}

Call the event processing and and respond methods on the request processor and apply synchronization if needed.
	private final void respond()
	}

Safe version of getProcessor() that throws an exception when the processor is null.

Returns:
the request processor
		if (processor == null)
			throw new WicketRuntimeException("request cycle processor must be not-null");
		return processor;
	}

Returns:
True if a session exists for the calling thread
	private boolean sessionExists()
		return Session.exists();
	}

handle the current step in the request processing.
	private final void step()
		try
			switch ()
				case  : {
					// prepare the request
					break;
				case  : {
					// resolve the target of the request using the request
					// parameters
					final IRequestTarget target = .resolve(this,
					// has to result in a request target
					if (target == null)
						 = false;
						// throw new WicketRuntimeException(
						// "the processor did not resolve to any request target");
					// Add (inserting at the bottom) in case before or during
					// target resolving one or more request targets were pushed
					// on the stack before this. If that is the case, they
					// should be handled before this
					.add(0, target);
					break;
				case  : {
					break;
				case  : {
					// generate a response
					break;
				default : {
					// nothing
		catch (AbortException e)
			throw e;
			/*
			 * check if the raised exception wraps an abort exception. if so, it is probably wise to
			 * unwrap and rethrow the abort exception
			 */
			Throwable cause = e.getCause();
			while (cause != null)
				if (cause instanceof AbortException)
					throw ((AbortException)cause);
				cause = cause.getCause();
				// set step manually to handle exception
				// probably our last chance the exception can be logged.
				// Note that a PageExpiredException should not be logged, because
				// it's not an internal error
				if (!(e instanceof PageExpiredException))
				// try to play nicely and let the request processor handle the
				// exception response. If that doesn't work, any runtime exception
				// will automatically be bubbled up
				if ( != null)
			else
				// hmmm, we were already handling an exception! give up
					"unexpected exception when handling another exception: " + e.getMessage(), e);
	}


INTERNAL. This method is not part of public Wicket Api. Do not call it. Returns whether wicket handled this request or not (i.e. when no request target was found).

Returns:
true if wicket handled this request, false otherwise
	public boolean wasHandled()
		return ;
	private boolean handled = true;

Loop through the processing steps starting from the current one.
	private final void steps()
		try
			// Arbitrary maximum number of steps
			final int maxSteps = 100;
			// Loop through steps
			for (int totalSteps = 0;  < totalSteps++)
				// There is no way to catch infinite loops since the response
				// step can always throw an AbstractRestartResponseException and
				// start the process over at the RESPOND step. So we do a sanity
				// check here and limit the total number of steps to an
				// arbitrary maximum that we consider unreasonable for working
				// code.
				if (totalSteps >= maxSteps)
					throw new IllegalStateException("Request processing executed " + maxSteps +
						" steps, which means it is probably in an infinite loop.");
				try
					// if a redirect exception has been issued we abort what we
					// were doing and begin responding to the top target on the
					// stack
		finally
			// set step manually to clean up
			// clean up the request
			// set step manually to done
	}

Releases the current thread local related resources. The threadlocal of this request cycle is reset. If we are in a 'redirect' state, we do not want to lose our messages as - e.g. when handling a form - there's a fat chance we are coming back for the rendering of it.
	private final void threadDetach()
		// Detach from session
			try
			catch (RuntimeException re)
				.error("there was an error detaching the session"re);
			// Since we are explicitly redirecting to a page already, we do not
			// want a second redirect to occur automatically
		// Clear ThreadLocal reference; makes sense as this object should not be
		// reused
	}

Possibly set the page parameters. Only set when the request is resolving and the parameters are passed into a page.

Parameters:
parameters the parameters to set
	final void setPageParameters(PageParameters parameters)
			 = parameters;
	}

Called when an unrecoverable runtime exception during request cycle handling occurred, which will result in displaying a user facing error page. Clients can override this method in case they want to customize logging. NOT called for page expired exceptions.

Parameters:
e the runtime exception
	}

Creates a new agent info object based on this request. Typically, this method is called once by the session and the returned object will be cached in the session after that call; we can expect the client to stay the same for the whole session, and implementations of newClientInfo() might be relatively expensive.

Returns:
the agent info object based on this request
	protected abstract ClientInfo newClientInfo();

Called when the request cycle object is beginning its response
	protected void onBeginRequest()
	}

Called when the request cycle object has finished its response
	protected void onEndRequest()
	}

MetaDataEntry array.
Sets the metadata for this request cycle using the given key. If the metadata object is not of the correct type for the metadata key, an IllegalArgumentException will be thrown. For information on creating MetaDataKeys, see MetaDataKey.

Parameters:
key The singleton key for the metadata
object The metadata object
Throws:
java.lang.IllegalArgumentException
See also:
MetaDataKey
	// TODO: Replace the Serializable type with Object for next wicket version
	public final void setMetaData(final MetaDataKey keyfinal Serializable object)
		 = key.set(object);
	}

Gets metadata for this request cycle using the given key.

Parameters:
key The key for the data
Returns:
The metadata or null if no metadata was found for the given key
See also:
MetaDataKey
	public final Serializable getMetaData(final MetaDataKey key)
		return (Serializable)key.get();
New to GrepCode? Check out our FAQ X