KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > packtag > tag > ScriptTag


1 /**
2  * Project pack:tag >> http://packtag.sf.net
3  *
4  * This software is published under the terms of the LGPL
5  * License version 2.1, a copy of which has been included with this
6  * distribution in the 'lgpl.txt' file.
7  *
8  * Last author: $Author: danielgalan $
9  * Last modified: $Date: 2007/04/22 19:04:24 $
10  * Revision: $Revision: 1.1 $
11  *
12  * $Log: ScriptTag.java,v $
13  * Revision 1.1 2007/04/22 19:04:24 danielgalan
14  * pack.tag moved from subversion to good old CVS
15  *
16  */

17 package net.sf.packtag.tag;
18
19 import javax.servlet.jsp.JspWriter JavaDoc;
20
21 import net.sf.packtag.implementation.JsminPackStrategy;
22 import net.sf.packtag.strategy.PackStrategy;
23
24
25
26 /**
27  * JSP Tag for compressing JavaScript resources.
28  *
29  * @author Daniel Galán y Martins
30  * @version $Revision: 1.1 $
31  */

32 public class ScriptTag extends BaseTag {
33
34     private static final long serialVersionUID = -5324074433734258409L;
35
36     //private final static String SCRIPT_START_SOLO = "<script type=\"text/javascript\" language=\"JavaScript\">";
37
private final static String JavaDoc SCRIPT_START = "<script type=\"text/javascript\" language=\"JavaScript\" SRC=\"";
38     private final static String JavaDoc SCRIPT_END_SOLO = "</script>";
39     private final static String JavaDoc SCRIPT_END = "\">" + SCRIPT_END_SOLO;
40     
41
42     protected void writeResouce(JspWriter JavaDoc writer, String JavaDoc path) throws Exception JavaDoc {
43         writer.write(SCRIPT_START + path + SCRIPT_END);
44     }
45
46
47     protected PackStrategy getPackStrategy() throws Exception JavaDoc {
48         String JavaDoc className = getPackStrategyClassName("script");
49         if ((className == null) || className.equals(BaseTag.EMPTY_STRING)) {
50             return new JsminPackStrategy();
51         }
52         return (PackStrategy)Class.forName(className).newInstance();
53     }
54
55
56     protected String JavaDoc getResourceExtension() {
57         return "js";
58     }
59
60 }
61
Popular Tags