Package com.netscape.cms.servlet.common
Class CMSTemplate
- java.lang.Object
-
- com.netscape.cms.servlet.common.CMSFile
-
- com.netscape.cms.servlet.common.CMSTemplate
-
public class CMSTemplate extends CMSFile
File templates. This implementation will take an HTML file with a special customer tag <CMS_TEMPLATE> and replace the tag with a series of javascript variable definitions (depending on the servlet)- Version:
- $Revision$, $Date$
-
-
Field Summary
Fields Modifier and Type Field Description static org.slf4j.Loggerloggerjava.lang.StringmPostOutputjava.lang.StringmPreOutputstatic java.lang.StringSUFFIXstatic java.lang.StringTEMPLATE_TAG-
Fields inherited from class com.netscape.cms.servlet.common.CMSFile
mAbsPath, mContent, mLastAccess, mLastModified
-
-
Constructor Summary
Constructors Constructor Description CMSTemplate(java.io.File file, java.lang.String charset)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.StringescapeJavaScriptString(java.lang.String v)Escape the contents of src string in preparation to be enclosed in double quotes as a JavaScript String Literal within an <script> portion of an HTML document.static java.lang.StringescapeJavaScriptStringHTML(java.lang.String v)Like escapeJavaScriptString(String s) but also escapes for HTML processing; i.e., first encode for HTML and then encode for outputting in JavaScript.java.lang.StringgetOutput(CMSTemplateParams input)for debugging, return contents that would've been outputed.java.lang.StringgetTemplateName()booleaninit(java.io.File template)booleanoutputEpilog(java.io.PrintWriter out)Output the post HTML tags and post-output buffer.booleanoutputProlog(java.io.PrintWriter out)Ouput the pre-amble HTML Header including the pre-output buffer.voidrenderOutput(java.io.OutputStream rout, CMSTemplateParams input)Write a javascript representation of 'input' surrounded by SCRIPT tags to the outputstream-
Methods inherited from class com.netscape.cms.servlet.common.CMSFile
getAbsPath, getContent, getLastAccess, getLastModified, setLastAccess, toString, toString
-
-
-
-
Field Detail
-
logger
public static org.slf4j.Logger logger
-
SUFFIX
public static final java.lang.String SUFFIX
- See Also:
- Constant Field Values
-
mPreOutput
public java.lang.String mPreOutput
-
mPostOutput
public java.lang.String mPostOutput
-
TEMPLATE_TAG
public static final java.lang.String TEMPLATE_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CMSTemplate
public CMSTemplate(java.io.File file, java.lang.String charset) throws java.io.IOException, EBaseExceptionConstructor- Parameters:
file- template file to loadcharset- character set- Throws:
java.io.IOException- if the there was an error opening the fileEBaseException
-
-
Method Detail
-
init
public boolean init(java.io.File template) throws EBaseException, java.io.IOException- Throws:
EBaseExceptionjava.io.IOException
-
renderOutput
public void renderOutput(java.io.OutputStream rout, CMSTemplateParams input) throws java.io.IOExceptionWrite a javascript representation of 'input' surrounded by SCRIPT tags to the outputstream- Parameters:
rout- the outputstream to write toinput- the parameters to write- Throws:
java.io.IOException
-
outputProlog
public boolean outputProlog(java.io.PrintWriter out)
Ouput the pre-amble HTML Header including the pre-output buffer.- Parameters:
out- output stream specified- Returns:
- success or error
-
outputEpilog
public boolean outputEpilog(java.io.PrintWriter out)
Output the post HTML tags and post-output buffer.- Parameters:
out- output stream specified- Returns:
- success or error
-
getTemplateName
public java.lang.String getTemplateName()
- Returns:
- full path of template
-
escapeJavaScriptString
public static java.lang.String escapeJavaScriptString(java.lang.String v)
Escape the contents of src string in preparation to be enclosed in double quotes as a JavaScript String Literal within an <script> portion of an HTML document.
-
escapeJavaScriptStringHTML
public static java.lang.String escapeJavaScriptStringHTML(java.lang.String v)
Like escapeJavaScriptString(String s) but also escapes for HTML processing; i.e., first encode for HTML and then encode for outputting in JavaScript.
-
getOutput
public java.lang.String getOutput(CMSTemplateParams input) throws java.io.IOException
for debugging, return contents that would've been outputed.- Throws:
java.io.IOException
-
-