KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opensubsystems > patterns > ordereddata > www > OrderedDataInitTag


1 /*
2  * Copyright (c) 2006 - 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
3  *
4  * Project: OpenSubsystems
5  *
6  * $Id: OrderedDataInitTag.java,v 1.4 2007/01/07 06:14:53 bastafidli Exp $
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; version 2 of the License.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */

21  
22 package org.opensubsystems.patterns.ordereddata.www;
23
24 import javax.servlet.http.HttpServletRequest JavaDoc;
25 import javax.servlet.jsp.JspException JavaDoc;
26
27 import org.opensubsystems.core.www.PageElementCacheTag;
28
29 /**
30  * Custom tag to initialize css and javascript files related to data ordering.
31  * This needs to be the first tag of all ordered data tags and should be
32  * placed in the page before the html tag. The <core:pagecache id="xyz"/>
33  * in emptypage.jsp layout will take the elements put into cache by this tag and
34  * place them at correct location.
35  *
36  * @version $Id: OrderedDataInitTag.java,v 1.4 2007/01/07 06:14:53 bastafidli Exp $
37  * @author Julian Legeny
38  * @code.reviewer Miro Halas
39  * @code.reviewed 1.1 2006/04/25 00:44:46 jlegeny
40  */

41 public class OrderedDataInitTag extends PageElementCacheTag
42 {
43    // Attributes ///////////////////////////////////////////////////////////////
44

45    /**
46     * Generated serial version id for this class.
47     */

48    private static final long serialVersionUID = 7650261534929475794L;
49
50    // Constructors /////////////////////////////////////////////////////////////
51

52    /**
53     * Constructor for custom tag.
54     */

55    public OrderedDataInitTag()
56    {
57       super();
58    }
59    
60    // Business logic ///////////////////////////////////////////////////////////
61

62    /**
63     * {@inheritDoc}
64     */

65    public int doStartTag(
66    ) throws JspException JavaDoc
67    {
68       String JavaDoc contextpath;
69       StringBuffer JavaDoc sbBuffer = new StringBuffer JavaDoc();
70
71       contextpath = ((HttpServletRequest JavaDoc)pageContext.getRequest()).getContextPath();
72
73       /*
74       <link rel="StyleSheet" type="text/css" media="screen"
75             href="<%=contextpath%>/patterns/css/ordereddata.css" >
76       <script type="text/javascript" language="JavaScript"
77               src="<%=contextpath%>/core/js/ordereddata.js"></script>
78       <script type="text/javascript" language="JavaScript"
79       */

80
81       /*
82       sbBuffer.append("<link HREF=\"");
83       sbBuffer.append(contextpath);
84       sbBuffer.append("/patterns/css/ordereddata.css\" rel=\"StyleSheet\"" +
85                       " type=\"text/css\" media=\"screen\">");
86       cache(PageElementCacheTag.CSS_ELEMENT, sbBuffer.toString());
87       */

88
89       sbBuffer.delete(0, sbBuffer.length());
90       sbBuffer.append("<script type=\"text/javascript\" language=\"JavaScript\" SRC=\"");
91       sbBuffer.append(contextpath);
92       sbBuffer.append("/patterns/js/ordereddata.js\"></script>\n");
93       cache(PageElementCacheTag.JS_ELEMENT, sbBuffer.toString());
94       
95       return (SKIP_BODY);
96    }
97
98    /**
99     * {@inheritDoc}
100     */

101    public int doEndTag(
102    ) throws JspException JavaDoc
103    {
104       return (EVAL_PAGE);
105    }
106 }
107
Popular Tags