當前位置: 首頁>>代碼示例>>Java>>正文


Java TagSupport類代碼示例

本文整理匯總了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();
}
 
開發者ID:quatico-solutions,項目名稱:aem-testing,代碼行數:25,代碼來源:Tags.java

示例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";
            }
        }
    }
 
開發者ID:bboypscmylife,項目名稱:opengse,代碼行數:22,代碼來源:TestTag.java

示例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() + "'.");
       }
}
 
開發者ID:VHAINNOVATIONS,項目名稱:Telepathology,代碼行數:20,代碼來源:AbstractBusinessObjectPropertyTag.java

示例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));
   }
}
 
開發者ID:nyla-solutions,項目名稱:nyla,代碼行數:20,代碼來源:SectionContainerTag.java

示例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;
}
 
開發者ID:DIA-NZ,項目名稱:webcurator,代碼行數:22,代碼來源:ShowControlTag.java

示例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;
}
 
開發者ID:DIA-NZ,項目名稱:webcurator,代碼行數:26,代碼來源:GrpNameTag.java

示例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;
}
 
開發者ID:DIA-NZ,項目名稱:webcurator,代碼行數:26,代碼來源:TreeTag.java

示例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);
}
 
開發者ID:apache,項目名稱:rave,代碼行數:17,代碼來源:RenderInitializationScriptTagTest.java

示例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);
}
 
開發者ID:apache,項目名稱:rave,代碼行數:17,代碼來源:RenderInitializationScriptTagTest.java

示例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);
}
 
開發者ID:apache,項目名稱:rave,代碼行數:21,代碼來源:ScriptTagTest.java

示例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;
}
 
開發者ID:yangjm,項目名稱:winlet,代碼行數:20,代碼來源:DialogButtonTag.java

示例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;
}
 
開發者ID:NCIP,項目名稱:webgenome,代碼行數:21,代碼來源:OnlyIfClientModeTag.java

示例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;
}
 
開發者ID:NCIP,項目名稱:webgenome,代碼行數:21,代碼來源:QuantitationTypeOptionsTag.java

示例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;
}
 
開發者ID:NCIP,項目名稱:webgenome,代碼行數:29,代碼來源:OnlyIfParameteredDerivedExperimentTag.java

示例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;
}
 
開發者ID:NCIP,項目名稱:webgenome,代碼行數:21,代碼來源:OnlyIfAdminTag.java


注:本文中的javax.servlet.jsp.tagext.TagSupport類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。