KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > turbine > services > jsp > util > JspLink


1 package org.apache.turbine.services.jsp.util;
2
3 /*
4  * Copyright 2001-2004 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
19 import org.apache.turbine.util.DynamicURI;
20 import org.apache.turbine.util.RunData;
21 import org.apache.turbine.util.uri.URIConstants;
22
23 /**
24  * A customized version of the DynamicURI to be used in JSP templates.
25  * This is automatically inserted into the request so page authors
26  * can create links in templates.
27  * Here's an example of its use:<br>
28  * <code>
29  * <jsp:useBean id="link" class="JspLink" scope="request"/%>
30  * <%= link.setPage("index.jsp").setPathInfo("key", "value") %>
31  * This would return:
32  * http://foo.com/myapp/servlet/Turbine/key/value/template/index.jsp
33  * </code>
34  *
35  * @author <a HREF="john.mcnally@clearink.com">John McNally</a>
36  * @author <a HREF="mbryson@mont.mindspring.com">Dave Bryson</a>
37  * @author Jon S. Stevens <a HREF="mailto:jon@latchkey.com">jon@latchkey.com</a>
38  * @author <a HREF="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
39  * @version $Id: JspLink.java,v 1.5.2.2 2004/05/20 03:06:51 seade Exp $
40  * deprecated Use {@org.apache.turbine.services.pull.tools.TemplateLink} instead.
41  */

42 public class JspLink
43     extends DynamicURI
44 {
45     /**
46      * Constructor
47      *
48      * @param data A Rundata Object
49      */

50     public JspLink(RunData data)
51     {
52         super(data);
53     }
54
55     /**
56      * Returns the URI
57      * @return String the uri http://foo.com/...
58      */

59     public String JavaDoc toString()
60     {
61         String JavaDoc output = super.toString();
62
63         // This was added to allow multilple $link variables in one
64
// JSP template
65
removePathInfo();
66         removeQueryData();
67
68         return output;
69     }
70
71     /**
72      * Sets the template variable used by the WebMacroSite Service
73      * @param String the template name
74      * @return JspLink
75      */

76     public JspLink setPage(String JavaDoc t)
77     {
78         return (JspLink) addPathInfo(URIConstants.CGI_TEMPLATE_PARAM, t);
79     }
80 }
81
Popular Tags