本文整理汇总了Java中javax.servlet.jsp.tagext.TagSupport类的典型用法代码示例。如果您正苦于以下问题:Java TagSupport类的具体用法?Java TagSupport怎么用?Java TagSupport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TagSupport类属于javax.servlet.jsp.tagext包,在下文中一共展示了TagSupport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderTag
import javax.servlet.jsp.tagext.TagSupport; //导入依赖的package包/类
@Override
public String renderTag(TagSupport tag, PageContext pageContext, String body) throws Exception {
StringWriter strWriter = new StringWriter();
HttpServletResponse response = mock(HttpServletResponse.class);
when(response.getWriter()).thenReturn(new PrintWriter(strWriter, true));
if (!mockingDetails(pageContext).isSpy()) {
pageContext = spy(pageContext);
}
JspWriter jspWriter = new JspWriterImpl(response);
doReturn(jspWriter).when(pageContext).getOut();
tag.setPageContext(pageContext);
if (Tag.EVAL_BODY_INCLUDE == tag.doStartTag()) {
jspWriter.flush();
strWriter.write(body);
}
jspWriter.flush();
tag.doEndTag();
jspWriter.flush();
tag.release();
return strWriter.toString();
}
示例2: doInitBody
import javax.servlet.jsp.tagext.TagSupport; //导入依赖的package包/类
public void doInitBody() throws JspException {
//Test for doInitBody method.
if ( "doInitBody".equalsIgnoreCase ( this.getAtt1() ) ) {
TestString += this.getAtt1();
}
// Test for getParent method in TagSupport
if ( "getParent".equalsIgnoreCase ( this.getAtt2() ) ) {
TagSupport ts = new TagSupport();
setParent( this );
Tag tt = getParent();
if ( tt == this ) {
TestString = TestString + "Pass";
} else {
TestString = TestString + "Fails";
}
}
}
示例3: getParentTag
import javax.servlet.jsp.tagext.TagSupport; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private P getParentTag()
throws JspException
{
try
{
AbstractBusinessObjectTag<T> parentTag = null;
for(
parentTag = (AbstractBusinessObjectTag)TagSupport.findAncestorWithClass(this, AbstractBusinessObjectTag.class);
parentTag != null && ! businessObjectType.equals(parentTag.getBusinessObjectType());
parentTag = (AbstractBusinessObjectTag)TagSupport.findAncestorWithClass(parentTag, AbstractBusinessObjectTag.class) );
return (P)parentTag;
}
catch (ClassCastException e)
{
throw new JspException("Parent tag of this '" + this.getClass().getName() + "' must present business object of type '" + getBusinessObjectType().getName() + "'.");
}
}
示例4: doEndTag
import javax.servlet.jsp.tagext.TagSupport; //导入依赖的package包/类
/**
*
* @see javax.servlet.jsp.tagext.TagSupport#doEndTag()
*/
public int doEndTag() throws JspException
{
try
{
section = null;
pageContext.removeAttribute("counter");
pageContext.removeAttribute("sectionCounter");
pageContext.getOut().write("</table>");
return TagSupport.EVAL_PAGE;
}
catch(Exception e)
{
throw new JspException(Debugger.stackTrace(e));
}
}
示例5: doStartTag
import javax.servlet.jsp.tagext.TagSupport; //导入依赖的package包/类
@Override
public int doStartTag() throws JspException {
StringTokenizer tokenizer = new StringTokenizer(privileges, ";");
String[] privs = new String[tokenizer.countTokens()];
for(int i=0; tokenizer.hasMoreTokens(); i++) {
privs[i] = tokenizer.nextToken();
}
if(ownedObject instanceof UserOwnable) {
showControl = editMode && authorityManager.hasAtLeastOnePrivilege( (UserOwnable) ownedObject, privs);
}
else if(ownedObject instanceof AgencyOwnable) {
showControl = editMode && authorityManager.hasAtLeastOnePrivilege( (AgencyOwnable) ownedObject, privs);
}
else {
showControl = false;
}
// release the object (usually its a ti) from the tag to prevent a memory leak (Tags are pooled)
ownedObject = null;
return TagSupport.EVAL_BODY_INCLUDE;
}
示例6: doStartTag
import javax.servlet.jsp.tagext.TagSupport; //导入依赖的package包/类
@Override
public int doStartTag() throws JspException {
try {
if (name.contains(subGroupSeparator)) {
int sepIndex = name.lastIndexOf(subGroupSeparator);
String parentName = name.substring(0, sepIndex);
String subGroupName = name.substring(sepIndex + subGroupSeparator.length());
pageContext.getOut().print("<div class=\"subGroupParent\">");
pageContext.getOut().print(parentName);
pageContext.getOut().print("</div>");
pageContext.getOut().print(subGroupSeparator);
pageContext.getOut().print("<div class=\"subGroupChild\">");
pageContext.getOut().print(subGroupName);
pageContext.getOut().print("</div>");
} else {
pageContext.getOut().print(name);
}
} catch (IOException ex) {
throw new JspException(ex);
}
return TagSupport.SKIP_BODY;
}
示例7: doStartTag
import javax.servlet.jsp.tagext.TagSupport; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public int doStartTag() throws JspException {
rowAlt = 0;
try {
//NodeTree theTree = (NodeTree) ExpressionUtil.evalNotNull("tree", "tree", tree, NodeTree.class, this, pageContext);
NodeTree theTree = getTree();
Iterator<Node> rootIterator = theTree.getRootNodes().iterator();
pageContext.getOut().println("<table cellspacing=\"0\" cellpadding=\"0\">");
displayHeader(pageContext.getOut());
while (rootIterator.hasNext()) {
display(pageContext.getOut(), rootIterator.next(), 0);
}
pageContext.getOut().println("</table>");
}
catch (IOException ex) {
throw new JspException(ex.getMessage(), ex);
}
// Never process the body.
return TagSupport.SKIP_BODY;
}
示例8: doStartTag_beforeRave_existingAttribute
import javax.servlet.jsp.tagext.TagSupport; //导入依赖的package包/类
@Test
public void doStartTag_beforeRave_existingAttribute() throws Exception {
tag.setLocation(ScriptLocation.BEFORE_RAVE);
expect(pageContext.getRequest()).andReturn(request);
expect(request.getAttribute(ModelKeys.BEFORE_RAVE_INIT_SCRIPT)).andReturn(VALID_SCRIPT);
expect(pageContext.getOut()).andReturn(writer);
writer.print(VALID_SCRIPT.toString());
expectLastCall();
replay(pageContext, request, writer);
int returnValue = tag.doStartTag();
assertThat(returnValue, is(TagSupport.EVAL_BODY_INCLUDE));
verify(pageContext, request, writer);
}
示例9: doStartTag_afterRave_existingAttribute
import javax.servlet.jsp.tagext.TagSupport; //导入依赖的package包/类
@Test
public void doStartTag_afterRave_existingAttribute() throws Exception {
tag.setLocation(ScriptLocation.AFTER_RAVE);
expect(pageContext.getRequest()).andReturn(request);
expect(request.getAttribute(ModelKeys.AFTER_RAVE_INIT_SCRIPT)).andReturn(VALID_SCRIPT);
expect(pageContext.getOut()).andReturn(writer);
writer.print(VALID_SCRIPT.toString());
expectLastCall();
replay(pageContext, request, writer);
int returnValue = tag.doStartTag();
assertThat(returnValue, is(TagSupport.EVAL_BODY_INCLUDE));
verify(pageContext, request, writer);
}
示例10: doStartTag_skip
import javax.servlet.jsp.tagext.TagSupport; //导入依赖的package包/类
@Test
public void doStartTag_skip() throws IOException, JspException {
List<String> strings = new ArrayList<String>();
strings.add(SCRIPT);
strings.add(SCRIPT_2);
expect(service.getScriptBlocks(ScriptLocation.BEFORE_RAVE, context)).andReturn(null);
replay(service);
JspWriter writer = createNiceMock(JspWriter.class);
replay(writer);
expect(pageContext.getOut()).andReturn(writer).anyTimes();
replay(pageContext);
tag.setLocation(ScriptLocation.BEFORE_RAVE);
int result = tag.doStartTag();
assertThat(result, is(equalTo(TagSupport.SKIP_BODY)));
verify(writer);
}
示例11: doAfterBody
import javax.servlet.jsp.tagext.TagSupport; //导入依赖的package包/类
public int doAfterBody() {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(baos, "UTF-8");
bodyContent.writeOut(writer);
writer.flush();
button.put("label", baos.toString("UTF-8"));
} catch (IOException e) {
e.printStackTrace();
}
DialogTag dialog = (DialogTag) TagSupport.findAncestorWithClass(this,
DialogTag.class);
dialog.addButton(button);
button = new HashMap<String, String>();
bodyContent.clearBody();
return SKIP_BODY;
}
示例12: doStartTag
import javax.servlet.jsp.tagext.TagSupport; //导入依赖的package包/类
/**
* Do after start tag parsed.
* @throws JspException if anything goes wrong.
* @return Return value
*/
@Override
public final int doStartTag() throws JspException {
int rVal = TagSupport.SKIP_BODY;
try {
SessionMode mode =
org.rti.webgenome.webui.util.PageContext.getSessionMode(
(HttpServletRequest) pageContext.getRequest());
if (mode == SessionMode.CLIENT) {
rVal = TagSupport.EVAL_BODY_INCLUDE;
}
} catch (SessionTimeoutException e) {
rVal = TagSupport.SKIP_BODY;
}
return rVal;
}
示例13: doStartTag
import javax.servlet.jsp.tagext.TagSupport; //导入依赖的package包/类
/**
* Do after start tag parsed.
* @throws JspException if anything goes wrong.
* @return Return value
*/
@Override
public final int doStartTag() throws JspException {
Map<String, QuantitationType> index =
QuantitationType.getQuantitationTypeIndex();
Writer out = pageContext.getOut();
for (String id : index.keySet()) {
String name = index.get(id).getName();
try {
out.write("<option value=\"" + id + "\">" + name + "</option>");
} catch (IOException e) {
throw new JspException("Error writing to page.");
}
}
return TagSupport.SKIP_BODY;
}
示例14: doStartTag
import javax.servlet.jsp.tagext.TagSupport; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public int doStartTag() throws JspException {
int rval = TagSupport.SKIP_BODY;
if (name != null && name.length() > 0) {
Object obj = pageContext.findAttribute(name);
if (obj != null) {
if (!(obj instanceof Experiment)) {
throw new JspException("Bean named '"
+ this.name + "' not of type Experiment");
}
Experiment exp = (Experiment) obj;
if (exp.isDerived()) {
AnalysisDataSourceProperties props =
(AnalysisDataSourceProperties)
exp.getDataSourceProperties();
Collection<UserConfigurableProperty> userProps =
props.getUserConfigurableProperties();
if (userProps != null && userProps.size() > 0) {
rval = TagSupport.EVAL_BODY_INCLUDE;
}
}
}
}
return rval;
}
示例15: doStartTag
import javax.servlet.jsp.tagext.TagSupport; //导入依赖的package包/类
/**
* Do after start tag parsed.
* @throws JspException if anything goes wrong.
* @return Return value
*/
@Override
public final int doStartTag() throws JspException {
int rVal = TagSupport.SKIP_BODY;
try {
Principal principal =
org.rti.webgenome.webui.util.PageContext.getPrincipal(
(HttpServletRequest) pageContext.getRequest());
if (principal.isAdmin()) {
rVal = TagSupport.EVAL_BODY_INCLUDE;
}
} catch (SessionTimeoutException e) {
rVal = TagSupport.SKIP_BODY;
}
return rVal;
}