KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > views > jsp > URLTag


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 /*
6  * WebWork, Web Application Framework
7  *
8  * Distributable under Apache license.
9  * See terms of license at opensource.org
10  */

11 package com.opensymphony.webwork.views.jsp;
12
13 import com.opensymphony.webwork.components.URL;
14 import org.apache.commons.logging.Log;
15 import org.apache.commons.logging.LogFactory;
16
17 import javax.servlet.http.HttpServletRequest JavaDoc;
18 import javax.servlet.http.HttpServletResponse JavaDoc;
19 import javax.servlet.jsp.JspException JavaDoc;
20
21
22 /**
23  * This tag is used to create a URL.
24  * You can use the "param" tag inside the body to provide
25  * additional request parameters.
26  *
27  * @author Rickard Öberg (rickard@dreambean.com)
28  * @version $Revision: 1.24 $
29  * @see com.opensymphony.webwork.views.jsp.ParamTag
30  */

31 public class URLTag extends ParametereizedBodyTagSupport {
32     protected URL url;
33
34     protected String JavaDoc includeParams;
35     protected String JavaDoc scheme;
36     protected String JavaDoc value;
37     protected String JavaDoc encode;
38     protected String JavaDoc includeContext;
39
40     public int doEndTag() throws JspException JavaDoc {
41         url.addAllParameters(getParameters());
42         url.end(pageContext.getOut());
43
44         return EVAL_PAGE;
45     }
46
47     public int doStartTag() throws JspException JavaDoc {
48         url = new URL(getStack(),
49                 (HttpServletRequest JavaDoc) pageContext.getRequest(),
50                 (HttpServletResponse JavaDoc) pageContext.getResponse());
51         url.setIncludeParams(includeParams);
52         url.setScheme(scheme);
53         url.setValue(value);
54         if (encode != null) {
55             url.setEncode(Boolean.valueOf(encode).booleanValue());
56         }
57         if (includeContext != null) {
58             url.setIncludeContext(Boolean.valueOf(includeContext).booleanValue());
59         }
60         url.start(pageContext.getOut());
61
62         return EVAL_BODY_BUFFERED;
63     }
64
65     public void setEncode(String JavaDoc encode) {
66         this.encode = encode;
67     }
68
69     public void setIncludeContext(String JavaDoc includeContext) {
70         this.includeContext = includeContext;
71     }
72
73     public void setIncludeParams(String JavaDoc aName) {
74         includeParams = aName;
75     }
76
77     public void setScheme(String JavaDoc aScheme) {
78         scheme = aScheme;
79     }
80
81     public void setValue(String JavaDoc aName) {
82         value = aName;
83     }
84 }
85
Popular Tags