Save This Page
Home » struts-2.1.8.1-src » org.apache » struts2 » components » [javadoc | source]
    1   /*
    2    * $Id$
    3    *
    4    * Licensed to the Apache Software Foundation (ASF) under one
    5    * or more contributor license agreements.  See the NOTICE file
    6    * distributed with this work for additional information
    7    * regarding copyright ownership.  The ASF licenses this file
    8    * to you under the Apache License, Version 2.0 (the
    9    * "License"); you may not use this file except in compliance
   10    * with the License.  You may obtain a copy of the License at
   11    *
   12    *  http://www.apache.org/licenses/LICENSE-2.0
   13    *
   14    * Unless required by applicable law or agreed to in writing,
   15    * software distributed under the License is distributed on an
   16    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   17    * KIND, either express or implied.  See the License for the
   18    * specific language governing permissions and limitations
   19    * under the License.
   20    */
   21   package org.apache.struts2.components;
   22   
   23   import com.opensymphony.xwork2.util.ValueStack;
   24   
   25   import javax.servlet.http.HttpServletRequest;
   26   import javax.servlet.http.HttpServletResponse;
   27   import java.util.Map;
   28   
   29   /**
   30    * Default implementation of UrlProvider
   31    */
   32   public class ComponentUrlProvider implements UrlProvider {
   33       protected HttpServletRequest httpServletRequest;
   34       protected HttpServletResponse httpServletResponse;
   35   
   36       protected String includeParams;
   37       protected String scheme;
   38       protected String value;
   39       protected String action;
   40       protected String namespace;
   41       protected String method;
   42       protected boolean encode = true;
   43       protected boolean includeContext = true;
   44       protected boolean escapeAmp = true;
   45       protected String portletMode;
   46       protected String windowState;
   47       protected String portletUrlType;
   48       protected String anchor;
   49       protected boolean forceAddSchemeHostAndPort;
   50       protected String urlIncludeParams;
   51       protected ExtraParameterProvider extraParameterProvider;
   52       protected UrlRenderer urlRenderer;
   53   
   54       protected Component component;
   55       private Map parameters;
   56   
   57       /**
   58        *
   59        * @param component The component used to delagete some calls to
   60        * @param parameters parameters passed from <param...>
   61        */
   62       public ComponentUrlProvider(Component component, Map parameters) {
   63           this.component = component;
   64           this.parameters = parameters;
   65       }
   66   
   67       public String determineActionURL(String action, String namespace, String method, HttpServletRequest req, HttpServletResponse res, Map parameters, String scheme, boolean includeContext, boolean encodeResult, boolean forceAddSchemeHostAndPort, boolean escapeAmp) {
   68           return component.determineActionURL(action, namespace, method, req, res, parameters, scheme, includeContext, encodeResult, forceAddSchemeHostAndPort, escapeAmp);
   69       }
   70   
   71       public String determineNamespace(String namespace, ValueStack stack, HttpServletRequest req) {
   72           return component.determineNamespace(namespace, stack, req);
   73       }
   74   
   75       public String findString(String expr) {
   76           return component.findString(expr);
   77       }
   78   
   79       public Map getParameters() {
   80           return parameters;
   81       }
   82   
   83       public HttpServletRequest getHttpServletRequest() {
   84           return httpServletRequest;
   85       }
   86   
   87       public void setHttpServletRequest(HttpServletRequest httpServletRequest) {
   88           this.httpServletRequest = httpServletRequest;
   89       }
   90   
   91       public HttpServletResponse getHttpServletResponse() {
   92           return httpServletResponse;
   93       }
   94   
   95       public void setHttpServletResponse(HttpServletResponse httpServletResponse) {
   96           this.httpServletResponse = httpServletResponse;
   97       }
   98   
   99       public String getIncludeParams() {
  100           return includeParams;
  101       }
  102   
  103       public void setIncludeParams(String includeParams) {
  104           this.includeParams = includeParams;
  105       }
  106   
  107       public String getScheme() {
  108           return scheme;
  109       }
  110   
  111       public void setScheme(String scheme) {
  112           this.scheme = scheme;
  113       }
  114   
  115       public boolean isPutInContext() {
  116           return component instanceof ContextBean;
  117       }
  118   
  119       public String getVar() {
  120           return isPutInContext() ? ((ContextBean)component).getVar() :  null;
  121       }
  122   
  123       public String getValue() {
  124           return value;
  125       }
  126   
  127       public void setValue(String value) {
  128           this.value = value;
  129       }
  130   
  131       public String getAction() {
  132           return action;
  133       }
  134   
  135       public void setAction(String action) {
  136           this.action = action;
  137       }
  138   
  139       public String getNamespace() {
  140           return namespace;
  141       }
  142   
  143       public void setNamespace(String namespace) {
  144           this.namespace = namespace;
  145       }
  146   
  147       public String getMethod() {
  148           return method;
  149       }
  150   
  151       public void setMethod(String method) {
  152           this.method = method;
  153       }
  154   
  155       public boolean isEncode() {
  156           return encode;
  157       }
  158   
  159       public void setEncode(boolean encode) {
  160           this.encode = encode;
  161       }
  162   
  163       public boolean isIncludeContext() {
  164           return includeContext;
  165       }
  166   
  167       public void setIncludeContext(boolean includeContext) {
  168           this.includeContext = includeContext;
  169       }
  170   
  171       public boolean isEscapeAmp() {
  172           return escapeAmp;
  173       }
  174   
  175       public void setEscapeAmp(boolean escapeAmp) {
  176           this.escapeAmp = escapeAmp;
  177       }
  178   
  179       public String getPortletMode() {
  180           return portletMode;
  181       }
  182   
  183       public void setPortletMode(String portletMode) {
  184           this.portletMode = portletMode;
  185       }
  186   
  187       public String getWindowState() {
  188           return windowState;
  189       }
  190   
  191       public void setWindowState(String windowState) {
  192           this.windowState = windowState;
  193       }
  194   
  195       public String getPortletUrlType() {
  196           return portletUrlType;
  197       }
  198   
  199       public ValueStack getStack() {
  200           return component.getStack();
  201       }
  202   
  203       public void setPortletUrlType(String portletUrlType) {
  204           this.portletUrlType = portletUrlType;
  205       }
  206   
  207       public String getAnchor() {
  208           return anchor;
  209       }
  210   
  211       public void setAnchor(String anchor) {
  212           this.anchor = anchor;
  213       }
  214   
  215       public boolean isForceAddSchemeHostAndPort() {
  216           return forceAddSchemeHostAndPort;
  217       }
  218   
  219       public void setForceAddSchemeHostAndPort(boolean forceAddSchemeHostAndPort) {
  220           this.forceAddSchemeHostAndPort = forceAddSchemeHostAndPort;
  221       }
  222   
  223       public void putInContext(String result) {
  224           if (isPutInContext()) {
  225               ((ContextBean)component).putInContext(result);
  226           }
  227       }
  228   
  229       public String getUrlIncludeParams() {
  230           return urlIncludeParams;
  231       }
  232   
  233       public void setUrlIncludeParams(String urlIncludeParams) {
  234           this.urlIncludeParams = urlIncludeParams;
  235       }
  236   
  237       public ExtraParameterProvider getExtraParameterProvider() {
  238           return extraParameterProvider;
  239       }
  240   
  241       public void setExtraParameterProvider(ExtraParameterProvider extraParameterProvider) {
  242           this.extraParameterProvider = extraParameterProvider;
  243       }
  244   
  245       public UrlRenderer getUrlRenderer() {
  246           return urlRenderer;
  247       }
  248   
  249       public void setUrlRenderer(UrlRenderer urlRenderer) {
  250           this.urlRenderer = urlRenderer;
  251       }
  252   }

Save This Page
Home » struts-2.1.8.1-src » org.apache » struts2 » components » [javadoc | source]