View Javadoc

1   /*
2    * $Id: URLTag.java 451544 2006-09-30 05:38:02Z mrdon $
3    *
4    * Copyright 2006 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.struts2.views.jsp;
19  
20  import javax.servlet.http.HttpServletRequest;
21  import javax.servlet.http.HttpServletResponse;
22  
23  import org.apache.struts2.components.Component;
24  import org.apache.struts2.components.URL;
25  
26  import com.opensymphony.xwork2.util.ValueStack;
27  
28  
29  /***
30   * @see URL
31   */
32  public class URLTag extends ComponentTagSupport {
33  	
34  	private static final long serialVersionUID = 1722460444125206226L;
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 String encode;
43      protected String includeContext;
44      protected String portletMode;
45      protected String windowState;
46      protected String portletUrlType;
47      protected String anchor;
48  
49      public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
50          return new URL(stack, req, res);
51      }
52  
53      protected void populateParams() {
54          super.populateParams();
55  
56          URL url = (URL) component;
57          url.setIncludeParams(includeParams);
58          url.setScheme(scheme);
59          url.setValue(value);
60          url.setMethod(method);
61          url.setNamespace(namespace);
62          url.setAction(action);
63          url.setPortletMode(portletMode);
64          url.setPortletUrlType(portletUrlType);
65          url.setWindowState(windowState);
66          url.setAnchor(anchor);
67  
68          if (encode != null) {
69              url.setEncode(Boolean.valueOf(encode).booleanValue());
70          }
71          if (includeContext != null) {
72              url.setIncludeContext(Boolean.valueOf(includeContext).booleanValue());
73          }
74      }
75  
76      public void setEncode(String encode) {
77          this.encode = encode;
78      }
79  
80      public void setIncludeContext(String includeContext) {
81          this.includeContext = includeContext;
82      }
83  
84      public void setIncludeParams(String name) {
85          includeParams = name;
86      }
87  
88      public void setAction(String action) {
89          this.action = action;
90      }
91  
92      public void setNamespace(String namespace) {
93          this.namespace = namespace;
94      }
95  
96      public void setMethod(String method) {
97          this.method = method;
98      }
99  
100     public void setScheme(String scheme) {
101         this.scheme = scheme;
102     }
103 
104     public void setValue(String value) {
105         this.value = value;
106     }
107     public void setPortletMode(String portletMode) {
108         this.portletMode = portletMode;
109     }
110     public void setPortletUrlType(String portletUrlType) {
111         this.portletUrlType = portletUrlType;
112     }
113     public void setWindowState(String windowState) {
114         this.windowState = windowState;
115     }
116 
117     public void setAnchor(String anchor) {
118         this.anchor = anchor;
119     }
120 }