|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.servlet.jsp.tagext.TagSupport | +--javawebparts.taglib.jstags.JSDigesterTag
This class is a custom tag that renders the JSDigester. This is a
client-side implementation of the Commons Digester component, quite a bit
trimmed down though (i.e., only a few of the most common rules are
implemented).
JSDigester uses the SAXParser code from the Mozilla JSLib library. It is
included here for convenience, with some minor changes required to work
for JSDigester, and also to save some space.
The implemented rules are CreateObject, SetProperties, BeanPropertySetter
and SetNext. Here is a usage example:
function testJSDigester() {
sampleXML = "<movies numMovies=\"2\">\n";
sampleXML += " <movie>\n";
sampleXML += " <title>Star Wars</title>\n";
sampleXML += " <actor gender=\"male\">Harrison Ford<
/actor>\n";
sampleXML += " <actor gender=\"female\">
Carrie Fisher</actor>\n";
sampleXML += " </movie>\n";
sampleXML += " <movie>\n";
sampleXML += " <title>Real Genius</title>\n";
sampleXML += " <actor gender=\"male\">Val Kilmer<
/actor>\n";
sampleXML += " </movie>\n";
sampleXML += "</movies>";
jsDigester = new JSDigester();
jsDigester.addObjectCreate("movies", "Movies");
jsDigester.addSetProperties("movies");
jsDigester.addObjectCreate("movies/movie", "Movie");
jsDigester.addBeanPropertySetter("movies/movie/title",
"setTitle");
jsDigester.addObjectCreate("movies/movie/actor", "Actor");
jsDigester.addSetProperties("movies/movie/actor");
jsDigester.addBeanPropertySetter("movies/movie/actor",
"setName");
jsDigester.addSetNext("movies/movie/actor", "addActor");
jsDigester.addSetNext("movies/movie", "addMovie");
myMovies = jsDigester.parse(sampleXML);
}
(This is directly from the sample app. This makes use of some custom
Javascript "classes", so please see the sample app for full details)
Because the rendered code is considerably bigger than most of the other
tags in the JSTags library, it is not shown here.
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 |
Constructor Summary | |
JSDigesterTag()
|
Method Summary | |
int |
doStartTag()
Render the results of the tag. |
private void |
renderJSDigester(java.lang.StringBuffer sb)
Renders the JSDigester class code. |
private void |
renderRules(java.lang.StringBuffer sb)
Renders the Digester rule classes. |
private void |
renderSAXParser(java.lang.StringBuffer sb)
Renders the SAXParser handler class code. |
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 |
Field Detail |
private static org.apache.commons.logging.Log log
private java.lang.String renderScriptTags
Constructor Detail |
public JSDigesterTag()
Method Detail |
public void setRenderScriptTags(java.lang.String inRenderScriptTags)
inRenderScriptTags
- renderScriptTags.public int doStartTag() throws javax.servlet.jsp.JspException
doStartTag
in interface javax.servlet.jsp.tagext.Tag
doStartTag
in class javax.servlet.jsp.tagext.TagSupport
javax.servlet.jsp.JspException
- If anything goes wrongprivate void renderSAXParser(java.lang.StringBuffer sb)
sb
- StringBuffer the output is being built up in.private void renderJSDigester(java.lang.StringBuffer sb)
sb
- StringBuffer the output is being built up in.private void renderRules(java.lang.StringBuffer sb)
sb
- StringBuffer the output is being built up in.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |