View Javadoc

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