View Javadoc

1   /*
2    * $Id: URLTag.java 565422 2007-08-13 17:09:16Z jholmes $
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 escapeAmp;
48      protected String portletMode;
49      protected String windowState;
50      protected String portletUrlType;
51      protected String anchor;
52      protected String forceAddSchemeHostAndPort;
53  
54      public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
55          return new URL(stack, req, res);
56      }
57  
58      protected void populateParams() {
59          super.populateParams();
60  
61          URL url = (URL) component;
62          url.setIncludeParams(includeParams);
63          url.setScheme(scheme);
64          url.setValue(value);
65          url.setMethod(method);
66          url.setNamespace(namespace);
67          url.setAction(action);
68          url.setPortletMode(portletMode);
69          url.setPortletUrlType(portletUrlType);
70          url.setWindowState(windowState);
71          url.setAnchor(anchor);
72  
73          if (encode != null) {
74              url.setEncode(Boolean.valueOf(encode).booleanValue());
75          }
76          if (includeContext != null) {
77              url.setIncludeContext(Boolean.valueOf(includeContext).booleanValue());
78          }
79          if (escapeAmp != null) {
80              url.setEscapeAmp(Boolean.valueOf(escapeAmp).booleanValue());
81          }
82  	if (forceAddSchemeHostAndPort != null) {
83              url.setForceAddSchemeHostAndPort(Boolean.valueOf(forceAddSchemeHostAndPort).booleanValue());
84          }
85      }
86  
87      public void setEncode(String encode) {
88          this.encode = encode;
89      }
90  
91      public void setIncludeContext(String includeContext) {
92          this.includeContext = includeContext;
93      }
94  
95      public void setEscapeAmp(String escapeAmp) {
96          this.escapeAmp = escapeAmp;
97      }
98  
99      public void setIncludeParams(String name) {
100         includeParams = name;
101     }
102 
103     public void setAction(String action) {
104         this.action = action;
105     }
106 
107     public void setNamespace(String namespace) {
108         this.namespace = namespace;
109     }
110 
111     public void setMethod(String method) {
112         this.method = method;
113     }
114 
115     public void setScheme(String scheme) {
116         this.scheme = scheme;
117     }
118 
119     public void setValue(String value) {
120         this.value = value;
121     }
122 
123     public void setPortletMode(String portletMode) {
124         this.portletMode = portletMode;
125     }
126 
127     public void setPortletUrlType(String portletUrlType) {
128         this.portletUrlType = portletUrlType;
129     }
130 
131     public void setWindowState(String windowState) {
132         this.windowState = windowState;
133     }
134 
135     public void setAnchor(String anchor) {
136         this.anchor = anchor;
137     }
138 
139     public void setForceAddSchemeHostAndPort(String forceAddSchemeHostAndPort) {
140         this.forceAddSchemeHostAndPort = forceAddSchemeHostAndPort;
141     }
142 }