View Javadoc

1   package org.apache.turbine.services.jsp.util;
2   
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  import org.apache.turbine.util.DynamicURI;
23  import org.apache.turbine.util.RunData;
24  import org.apache.turbine.util.uri.URIConstants;
25  
26  /***
27   * A customized version of the DynamicURI to be used in JSP templates.
28   * This is automatically inserted into the request so page authors
29   * can create links in templates.
30   * Here's an example of its use:<br>
31   * <code>
32   * <jsp:useBean id="link" class="JspLink" scope="request"/%>
33   * <%= link.setPage("index.jsp").setPathInfo("key", "value") %>
34   * This would return:
35   *     http://foo.com/myapp/servlet/Turbine/key/value/template/index.jsp
36   * </code>
37   *
38   * @author <a href="john.mcnally@clearink.com">John McNally</a>
39   * @author <a href="mbryson@mont.mindspring.com">Dave Bryson</a>
40   * @author Jon S. Stevens <a href="mailto:jon@latchkey.com">jon@latchkey.com</a>
41   * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
42   * @version $Id: JspLink.java 534872 2007-05-03 14:07:18Z tv $
43   * @deprecated Use {@org.apache.turbine.services.pull.tools.TemplateLink} instead.
44   */
45  public class JspLink
46      extends DynamicURI
47  {
48      /***
49       * Constructor
50       *
51       * @param data A Rundata Object
52       */
53      public JspLink(RunData data)
54      {
55          super(data);
56      }
57  
58      /***
59       * Returns the URI
60       * @return String the uri http://foo.com/...
61       */
62      public String toString()
63      {
64          String output = super.toString();
65  
66          // This was added to allow multilple $link variables in one
67          // JSP template
68          removePathInfo();
69          removeQueryData();
70  
71          return output;
72      }
73  
74      /***
75       * Sets the template variable used by the WebMacroSite Service
76       * @param String the template name
77       * @return JspLink
78       */
79      public JspLink setPage(String t)
80      {
81          return (JspLink) addPathInfo(URIConstants.CGI_TEMPLATE_PARAM, t);
82      }
83  }