javawebparts.taglib.jstags
Class CreateBookmarkTag
java.lang.Object
|
+--javax.servlet.jsp.tagext.TagSupport
|
+--javawebparts.taglib.jstags.CreateBookmarkTag
- All Implemented Interfaces:
- javax.servlet.jsp.tagext.IterationTag, java.io.Serializable, javax.servlet.jsp.tagext.Tag
- public class CreateBookmarkTag
- extends javax.servlet.jsp.tagext.TagSupport
This class is a custom tag that renders the JWPCreateBookmark() Javascript
function which can be called to bookmark the current page, or an arbitrary
URL. Note that this function DOES NOT work if you load a file manually in
a browser (i.e., if you try to bookmark a local file).
This tag uses the following attributes:
renderScriptTags - true/false - When set to true, the Javascript will be
rendered inside a <script> </script> tag pair. When set to
false, this will not be done and it is expected that the
<jstags:fullTrim/> tag appears inside a
<script> </script> tag pair. If this attribute is not present,
the script tags WILL be rendered.
It renders the following Javascript:
function JWPCreateBookmark(jwpcb_inURL, jwpcb_inTitle) {
if (arguments.length == 0) {
jwpcb_inURL = location.href;
jwpcb_inTitle = document.title;
} else if (arguments.length == 1) {
jwpcb_inURL = location.href;
}
if (window.external) {
window.external.AddFavorite(location.href, document.title);
} else if (window.sidebar) {
window.sidebar.addPanel(jwpcb_inTitle, jwpcb_inURL, "");
} else {
alert("I am sorry but your browser does not support adding " +
"bookmarks via script.");
}
}
Usage example:
JWPCreateBookmark();
This will bookmark the current page, using the document's title.
JWPCreateBookmark("My Title");
This will bookmark the current page, using the value passed in as the title.
JWPCreateBookmark("http://www.cnn.com", "CNN News Page");
This will bookmark the page found at the URL "http://www.cnn.com" using the
title "CNN News Page".
- Author:
- Frank W. Zammetti.
- See Also:
- Serialized Form
Field Summary |
private static org.apache.commons.logging.Log |
log
Log instance. |
private java.lang.String |
renderScriptTags
Whether to render the opening and closing script tags around the
emitted Javascript. |
Fields inherited from class javax.servlet.jsp.tagext.TagSupport |
id, pageContext |
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag |
EVAL_BODY_AGAIN |
Fields inherited from interface javax.servlet.jsp.tagext.Tag |
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE |
Method Summary |
int |
doStartTag()
Render the results of the tag. |
void |
setRenderScriptTags(java.lang.String inRenderScriptTags)
renderScriptTags mutator. |
Methods inherited from class javax.servlet.jsp.tagext.TagSupport |
doAfterBody, doEndTag, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setPageContext, setParent, setValue |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
private static org.apache.commons.logging.Log log
- Log instance.
renderScriptTags
private java.lang.String renderScriptTags
- Whether to render the opening and closing script tags around the
emitted Javascript.
CreateBookmarkTag
public CreateBookmarkTag()
setRenderScriptTags
public void setRenderScriptTags(java.lang.String inRenderScriptTags)
- renderScriptTags mutator.
- Parameters:
inRenderScriptTags
- renderScriptTags.
doStartTag
public int doStartTag()
throws javax.servlet.jsp.JspException
- Render the results of the tag.
- Specified by:
doStartTag
in interface javax.servlet.jsp.tagext.Tag
- Overrides:
doStartTag
in class javax.servlet.jsp.tagext.TagSupport
- Returns:
- Return code.
- Throws:
javax.servlet.jsp.JspException
- If anything goes wrong
Copyright © 2005 Frank W. Zammetti