|
Struts example source code file (PortletActionRedirectResult.java)
The Struts PortletActionRedirectResult.java source code/* * $Id: PortletActionRedirectResult.java 833239 2009-11-05 23:46:50Z rgielen $ * * 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.struts2.portlet.result; import java.util.Arrays; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import javax.portlet.PortletMode; import org.apache.struts2.dispatcher.ServletActionRedirectResult; import org.apache.struts2.dispatcher.mapper.ActionMapper; import org.apache.struts2.dispatcher.mapper.ActionMapping; import org.apache.struts2.portlet.PortletActionConstants; import org.apache.struts2.views.util.UrlHelper; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.util.reflection.ReflectionExceptionHandler; import com.opensymphony.xwork2.util.reflection.ReflectionException; import com.opensymphony.xwork2.util.logging.Logger; import com.opensymphony.xwork2.util.logging.LoggerFactory; import com.opensymphony.xwork2.config.entities.ResultConfig; import com.opensymphony.xwork2.inject.Inject; /** * * Portlet modification of the {@link ServletActionRedirectResult}. * * <!-- START SNIPPET: description --> * * This result uses the {@link ActionMapper} provided by the * {@link ActionMapperFactory} to instruct the render phase to invoke the * specified action and (optional) namespace. This is better than the * {@link PortletResult} because it does not require you to encode the URL * patterns processed by the {@link ActionMapper} in to your struts.xml * configuration files. This means you can change your URL patterns at any point * and your application will still work. It is strongly recommended that if you * are redirecting to another action, you use this result rather than the * standard redirect result. * * See examples below for an example of how request parameters could be passed * in. * * <!-- END SNIPPET: description --> * * <b>This result type takes the following parameters: * * <!-- START SNIPPET: params --> * * <ul> * * <li>actionName (default) - the name of the action that will be * redirect to</li> * * <li>namespace - used to determine which namespace the action is in * that we're redirecting to . If namespace is null, this defaults to the * current namespace</li> * * </ul> * * <!-- END SNIPPET: params --> * * <b>Example: * * <pre> * <!-- START SNIPPET: example --> * <package name="public" extends="struts-default"> * <action name="login" class="..."> * <!-- Redirect to another namespace --> * <result type="redirectAction"> * <param name="actionName">dashboard</param> * <param name="namespace">/secure</param> * </result> * </action> * </package> * * <package name="secure" extends="struts-default" namespace="/secure"> * <-- Redirect to an action in the same namespace --> * <action name="dashboard" class="..."> * <result>dashboard.jsp</result> * <result name="error" type="redirectAction">error</result> * </action> * * <action name="error" class="..."> * <result>error.jsp</result> * </action> * </package> * * <package name="passingRequestParameters" extends="struts-default" namespace="/passingRequestParameters"> * <-- Pass parameters (reportType, width and height) --> * <!-- * The redirectAction url generated will be : * /genReport/generateReport.action?reportType=pie&width=100&height=100 * --> * <action name="gatherReportInfo" class="..."> * <result name="showReportResult" type="redirectAction"> * <param name="actionName">generateReport</param> * <param name="namespace">/genReport</param> * <param name="reportType">pie</param> * <param name="width">100</param> * <param name="height">100</param> * </result> * </action> * </package> * * * <!-- END SNIPPET: example --> * </pre> * * @see ActionMapper */ public class PortletActionRedirectResult extends PortletResult implements ReflectionExceptionHandler { private static final long serialVersionUID = -7627388936683562557L; private static final Logger LOG = LoggerFactory.getLogger(PortletActionRedirectResult.class); /** The default parameter */ public static final String DEFAULT_PARAM = "actionName"; protected String actionName; protected String namespace; protected String method; private Map<String, String> requestParameters = new LinkedHashMap Other Struts examples (source code examples)Here is a short list of links related to this Struts PortletActionRedirectResult.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.