|
Struts example source code file (PortletActionContext.java)
The Struts PortletActionContext.java source code/*
* $Id: PortletActionContext.java 724030 2008-12-06 19:32:29Z nilsga $
*
* 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.context;
import java.util.Map;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletConfig;
import javax.portlet.PortletContext;
import javax.portlet.PortletRequest;
import javax.portlet.PortletResponse;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import org.apache.struts2.StrutsStatics;
import org.apache.struts2.dispatcher.mapper.ActionMapping;
import org.apache.struts2.portlet.PortletActionConstants;
import com.opensymphony.xwork2.ActionContext;
/**
* PortletActionContext. ActionContext thread local for the portlet environment.
*
* @version $Revision: 724030 $ $Date: 2008-12-06 20:32:29 +0100 (Sat, 06 Dec 2008) $
*/
public class PortletActionContext implements PortletActionConstants {
/**
* Get the PortletConfig of the portlet that is executing.
*
* @return The PortletConfig of the executing portlet.
*/
public static PortletConfig getPortletConfig() {
return (PortletConfig) getContext().get(PORTLET_CONFIG);
}
/**
* Get the RenderRequest. Can only be invoked in the render phase.
*
* @return The current RenderRequest.
* @throws IllegalStateException If the method is invoked in the wrong phase.
*/
public static RenderRequest getRenderRequest() {
if (!isRender()) {
throw new IllegalStateException(
"RenderRequest cannot be obtained in event phase");
}
return (RenderRequest) getContext().get(REQUEST);
}
/**
* Get the RenderResponse. Can only be invoked in the render phase.
*
* @return The current RenderResponse.
* @throws IllegalStateException If the method is invoked in the wrong phase.
*/
public static RenderResponse getRenderResponse() {
if (!isRender()) {
throw new IllegalStateException(
"RenderResponse cannot be obtained in event phase");
}
return (RenderResponse) getContext().get(RESPONSE);
}
/**
* Get the ActionRequest. Can only be invoked in the event phase.
*
* @return The current ActionRequest.
* @throws IllegalStateException If the method is invoked in the wrong phase.
*/
public static ActionRequest getActionRequest() {
if (!isEvent()) {
throw new IllegalStateException(
"ActionRequest cannot be obtained in render phase");
}
return (ActionRequest) getContext().get(REQUEST);
}
/**
* Get the ActionRequest. Can only be invoked in the event phase.
*
* @return The current ActionRequest.
* @throws IllegalStateException If the method is invoked in the wrong phase.
*/
public static ActionResponse getActionResponse() {
if (!isEvent()) {
throw new IllegalStateException(
"ActionResponse cannot be obtained in render phase");
}
return (ActionResponse) getContext().get(RESPONSE);
}
/**
* Get the action namespace of the portlet. Used to organize actions for multiple portlets in
* the same portlet application.
*
* @return The portlet namespace as defined in <code>portlet.xml and
Other Struts examples (source code examples)Here is a short list of links related to this Struts PortletActionContext.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.