View Javadoc

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