All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.wicket.request.handler.RenderPageRequestHandler Maven / Gradle / Ivy

Go to download

A module that creates a .jar from the classes in wicket, wicket-util and wicket-request modules in order to create a valid OSGi bundle of the wicket framework.

The newest version!
/*
 * 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.request.handler;

import org.apache.wicket.Application;
import org.apache.wicket.request.IRequestCycle;
import org.apache.wicket.request.IRequestHandler;
import org.apache.wicket.request.component.IRequestablePage;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.handler.render.PageRenderer;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.util.lang.Args;

/**
 * {@link IRequestHandler} that renders page instance. Depending on the redirectPolicy
 * flag and current request strategy the handler either just renders the page to the response, or
 * redirects to render the page. REDIRECT_TO_BUFFER strategy is also supported.
 * 

* * @author Matej Knopp */ public class RenderPageRequestHandler implements IPageRequestHandler, IPageClassRequestHandler { private final IPageProvider pageProvider; private final RedirectPolicy redirectPolicy; /** * Determines whether Wicket does a redirect when rendering a page * * @author Matej Knopp */ public enum RedirectPolicy { /** * Always redirect if current request URL is different than page URL. */ ALWAYS_REDIRECT, /** * Never redirect - always render the page to current response. */ NEVER_REDIRECT, /** * Redirect if necessary. The redirect will happen when all of the following conditions are * met: *

    *
  • current request URL is different than page URL *
  • page is not stateless or (page is stateless and session is not temporary) *
  • render strategy is either REDIRECT_TO_BUFFER or REDIRECT_TO_RENDER *
*/ AUTO_REDIRECT } /** * Construct. Renders the page with a redirect if necessary. * * @param pageProvider */ public RenderPageRequestHandler(IPageProvider pageProvider) { this(pageProvider, RedirectPolicy.AUTO_REDIRECT); } /** * Construct. * * @param pageProvider * @param redirectPolicy */ public RenderPageRequestHandler(IPageProvider pageProvider, RedirectPolicy redirectPolicy) { Args.notNull(pageProvider, "pageProvider"); Args.notNull(redirectPolicy, "redirectPolicy"); this.redirectPolicy = redirectPolicy; this.pageProvider = pageProvider; } /** * @return page provider */ public IPageProvider getPageProvider() { return pageProvider; } /** * @return redirect policy */ public RedirectPolicy getRedirectPolicy() { return redirectPolicy; } /** {@inheritDoc} */ public Class getPageClass() { return pageProvider.getPageClass(); } /** {@inheritDoc} */ public PageParameters getPageParameters() { return pageProvider.getPageParameters(); } /** {@inheritDoc} */ public void detach(IRequestCycle requestCycle) { pageProvider.detach(); } /** {@inheritDoc} */ public IRequestablePage getPage() { return pageProvider.getPageInstance(); } /** {@inheritDoc} */ public void respond(IRequestCycle requestCycle) { PageRenderer renderer = Application.get().getPageRendererProvider().get(this); renderer.respond((RequestCycle)requestCycle); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy