View Javadoc

    1   /*
    2    * $Id: URLTag.java 471756 2006-11-06 15:01:43Z husted $
    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.views.jsp;
    22
    23  import javax.servlet.http.HttpServletRequest;
    24  import javax.servlet.http.HttpServletResponse;
    25
    26  import org.apache.struts2.components.Component;
    27  import org.apache.struts2.components.URL;
    28
    29  import com.opensymphony.xwork2.util.ValueStack;
    30
    31
    32  /***
    33   * @see URL
    34   */
    35  public class URLTag extends ComponentTagSupport {
    36
    37      private static final long serialVersionUID = 1722460444125206226L;
    38
    39      protected String includeParams;
    40      protected String scheme;
    41      protected String value;
    42      protected String action;
    43      protected String namespace;
    44      protected String method;
    45      protected String encode;
    46      protected String includeContext;
    47      protected String portletMode;
    48      protected String windowState;
    49      protected String portletUrlType;
    50      protected String anchor;
    51
    52      public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
    53          return new URL(stack, req, res);
    54      }
    55
    56      protected void populateParams() {
    57          super.populateParams();
    58
    59          URL url = (URL) component;
    60          url.setIncludeParams(includeParams);
    61          url.setScheme(scheme);
    62          url.setValue(value);
    63          url.setMethod(method);
    64          url.setNamespace(namespace);
    65          url.setAction(action);
    66          url.setPortletMode(portletMode);
    67          url.setPortletUrlType(portletUrlType);
    68          url.setWindowState(windowState);
    69          url.setAnchor(anchor);
    70
    71          if (encode != null) {
    72              url.setEncode(Boolean.valueOf(encode).booleanValue());
    73          }
    74          if (includeContext != null) {
    75              url.setIncludeContext(Boolean.valueOf(includeContext).booleanValue());
    76          }
    77      }
    78
    79      public void setEncode(String encode) {
    80          this.encode = encode;
    81      }
    82
    83      public void setIncludeContext(String includeContext) {
    84          this.includeContext = includeContext;
    85      }
    86
    87      public void setIncludeParams(String name) {
    88          includeParams = name;
    89      }
    90
    91      public void setAction(String action) {
    92          this.action = action;
    93      }
    94
    95      public void setNamespace(String namespace) {
    96          this.namespace = namespace;
    97      }
    98
    99      public void setMethod(String method) {
    100         this.method = method;
    101     }
    102
    103     public void setScheme(String scheme) {
    104         this.scheme = scheme;
    105     }
    106
    107     public void setValue(String value) {
    108         this.value = value;
    109     }
    110     public void setPortletMode(String portletMode) {
    111         this.portletMode = portletMode;
    112     }
    113     public void setPortletUrlType(String portletUrlType) {
    114         this.portletUrlType = portletUrlType;
    115     }
    116     public void setWindowState(String windowState) {
    117         this.windowState = windowState;
    118     }
    119
    120     public void setAnchor(String anchor) {
    121         this.anchor = anchor;
    122     }
    123 }