当前位置: 首页>>代码示例>>Java>>正文


Java Tag类代码示例

本文整理汇总了Java中javax.servlet.jsp.tagext.Tag的典型用法代码示例。如果您正苦于以下问题:Java Tag类的具体用法?Java Tag怎么用?Java Tag使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Tag类属于javax.servlet.jsp.tagext包,在下文中一共展示了Tag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doEndTag

import javax.servlet.jsp.tagext.Tag; //导入依赖的package包/类
/**
 * Does two things:
 * <ul>
 *      <li>Stops the page if the corresponding attribute has been set</li>
 *      <li>Prints a message another tag encloses this one.</li>
 * </ul>
 */
public int doEndTag() throws JspTagException
{
    //get the parent if any
    Tag parent = this.getParent();

    if (parent != null) {
        try {
            JspWriter out = this.pageContext.getOut();
            out.println("This tag has a parent. <BR>");

        } catch (IOException e) {
            throw new JspTagException(e.getMessage());
        }
    }

    if (this.stopPage) {

        return Tag.SKIP_PAGE;
    }

    return Tag.EVAL_PAGE;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:30,代码来源:SampleTag.java

示例2: init

import javax.servlet.jsp.tagext.Tag; //导入依赖的package包/类
@Override
protected void init(ServletConfig config) {
    maxSize = Constants.MAX_POOL_SIZE;
    String maxSizeS = getOption(config, OPTION_MAXSIZE, null);
    if (maxSizeS != null) {
        maxSize = Integer.parseInt(maxSizeS);
        if (maxSize < 0) {
            maxSize = Constants.MAX_POOL_SIZE;
        }
    }

    perThread = new ThreadLocal<PerThreadData>() {
        @Override
        protected PerThreadData initialValue() {
            PerThreadData ptd = new PerThreadData();
            ptd.handlers = new Tag[maxSize];
            ptd.current = -1;
            perThreadDataVector.addElement(ptd);
            return ptd;
        }
    };
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:23,代码来源:PerThreadTagHandlerPool.java

示例3: init

import javax.servlet.jsp.tagext.Tag; //导入依赖的package包/类
protected void init(ServletConfig config) {
    int maxSize = -1;
    String maxSizeS = getOption(config, OPTION_MAXSIZE, null);
    if (maxSizeS != null) {
        try {
            maxSize = Integer.parseInt(maxSizeS);
        } catch (Exception ex) {
            maxSize = -1;
        }
    }
    if (maxSize < 0) {
        maxSize = Constants.MAX_POOL_SIZE;
    }
    this.handlers = new Tag[maxSize];
    this.current = -1;
    instanceManager = InstanceManagerFactory.getInstanceManager(config);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:18,代码来源:TagHandlerPool.java

示例4: hasAncestorOfType

import javax.servlet.jsp.tagext.Tag; //导入依赖的package包/类
/**
 * Determine whether the supplied {@link Tag} has any ancestor tag
 * of the supplied type.
 * @param tag the tag whose ancestors are to be checked
 * @param ancestorTagClass the ancestor {@link Class} being searched for
 * @return {@code true} if the supplied {@link Tag} has any ancestor tag
 * of the supplied type
 * @throws IllegalArgumentException if either of the supplied arguments is {@code null};
 * or if the supplied {@code ancestorTagClass} is not type-assignable to
 * the {@link Tag} class
 */
public static boolean hasAncestorOfType(Tag tag, Class<?> ancestorTagClass) {
	Assert.notNull(tag, "Tag cannot be null");
	Assert.notNull(ancestorTagClass, "Ancestor tag class cannot be null");
	if (!Tag.class.isAssignableFrom(ancestorTagClass)) {
		throw new IllegalArgumentException(
				"Class '" + ancestorTagClass.getName() + "' is not a valid Tag type");
	}
	Tag ancestor = tag.getParent();
	while (ancestor != null) {
		if (ancestorTagClass.isAssignableFrom(ancestor.getClass())) {
			return true;
		}
		ancestor = ancestor.getParent();
	}
	return false;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:TagUtils.java

示例5: init

import javax.servlet.jsp.tagext.Tag; //导入依赖的package包/类
protected void init(ServletConfig config) {
    maxSize = Constants.MAX_POOL_SIZE;
    String maxSizeS = getOption(config, OPTION_MAXSIZE, null);
    if (maxSizeS != null) {
        maxSize = Integer.parseInt(maxSizeS);
        if (maxSize < 0) {
            maxSize = Constants.MAX_POOL_SIZE;
        }
    }

    perThread = new ThreadLocal() {
        protected Object initialValue() {
            PerThreadData ptd = new PerThreadData();
            ptd.handlers = new Tag[maxSize];
            ptd.current = -1;
            perThreadDataVector.addElement(ptd);
            return ptd;
        }
    };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:PerThreadTagHandlerPool.java

示例6: init

import javax.servlet.jsp.tagext.Tag; //导入依赖的package包/类
protected void init( ServletConfig config ) {
    int maxSize=-1;
    String maxSizeS=getOption(config, OPTION_MAXSIZE, null);
    if( maxSizeS != null ) {
        try {
            maxSize=Integer.parseInt(maxSizeS);
        } catch( Exception ex) {
            maxSize=-1;
        }
    }
    if( maxSize <0  ) {
        maxSize=Constants.MAX_POOL_SIZE;
    }
    this.handlers = new Tag[maxSize];
    this.current = -1;
    instanceManager = InstanceManagerFactory.getInstanceManager(config);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:TagHandlerPool.java

示例7: get

import javax.servlet.jsp.tagext.Tag; //导入依赖的package包/类
/**
 * Gets the next available tag handler from this tag handler pool,
 * instantiating one if this tag handler pool is empty.
 *
 * @param handlerClass Tag handler class
 *
 * @return Reused or newly instantiated tag handler
 *
 * @throws JspException if a tag handler cannot be instantiated
 */
public Tag get(Class handlerClass) throws JspException {
	Tag handler;
    synchronized( this ) {
        if (current >= 0) {
            handler = handlers[current--];
            return handler;
        }
    }

    // Out of sync block - there is no need for other threads to
    // wait for us to construct a tag for this thread.
    try {
    	if (Constants.USE_INSTANCE_MANAGER_FOR_TAGS) {
    		return (Tag) instanceManager.newInstance(handlerClass.getName(), handlerClass.getClassLoader());
    	} else {
            Tag instance = (Tag) handlerClass.newInstance();
            if (Constants.INJECT_TAGS) {
                instanceManager.newInstance(instance);
            }
            return instance;
    	}
    } catch (Exception e) {
        throw new JspException(e.getMessage(), e);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:TagHandlerPool.java

示例8: reuse

import javax.servlet.jsp.tagext.Tag; //导入依赖的package包/类
/**
 * Adds the given tag handler to this tag handler pool, unless this tag
 * handler pool has already reached its capacity, in which case the tag
 * handler's release() method is called.
 *
 * @param handler Tag handler to add to this tag handler pool
 */
public void reuse(Tag handler) {
    synchronized( this ) {
        if (current < (handlers.length - 1)) {
            handlers[++current] = handler;
            return;
        }
    }
    // There is no need for other threads to wait for us to release
    handler.release();
    if (Constants.INJECT_TAGS) {
        try {
            instanceManager.destroyInstance(handler);
        } catch (Exception e) {
            log.warn("Error processing preDestroy on tag instance of "
                    + handler.getClass().getName(), e);
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:TagHandlerPool.java

示例9: doStartTag

import javax.servlet.jsp.tagext.Tag; //导入依赖的package包/类
@Override
   public int doStartTag() throws JspException {
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

String path = WebUtil.getBaseServerURL() + request.getContextPath();
if (!path.endsWith("/")) {
    path += "/";
}

try {
    JspWriter writer = pageContext.getOut();
    writer.print(path);
} catch (IOException e) {
    WebAppURLTag.log.error("ServerURLTag unable to write out server URL due to IOException. ", e);
    throw new JspException(e);
}
return Tag.SKIP_BODY;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:WebAppURLTag.java

示例10: doStartTag

import javax.servlet.jsp.tagext.Tag; //导入依赖的package包/类
@Override
   public int doStartTag() throws JspException {
HttpSession ss = SessionManager.getSession();
if (ss != null) {
    UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
    if (user != null) {
	processProperty(user);
    } else {
	UserTag.log.warn("UserTag unable to access user details as userDTO is missing. Session is " + ss);
    }
} else {
    UserTag.log.warn("UserTag unable to access user details as shared session is missing");
}

return Tag.SKIP_BODY;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:UserTag.java

示例11: init

import javax.servlet.jsp.tagext.Tag; //导入依赖的package包/类
@Override
protected void init(ServletConfig config) {
	maxSize = Constants.MAX_POOL_SIZE;
	String maxSizeS = getOption(config, OPTION_MAXSIZE, null);
	if (maxSizeS != null) {
		maxSize = Integer.parseInt(maxSizeS);
		if (maxSize < 0) {
			maxSize = Constants.MAX_POOL_SIZE;
		}
	}

	perThread = new ThreadLocal<PerThreadData>() {
		@Override
		protected PerThreadData initialValue() {
			PerThreadData ptd = new PerThreadData();
			ptd.handlers = new Tag[maxSize];
			ptd.current = -1;
			perThreadDataVector.addElement(ptd);
			return ptd;
		}
	};
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:23,代码来源:PerThreadTagHandlerPool.java

示例12: init

import javax.servlet.jsp.tagext.Tag; //导入依赖的package包/类
protected void init(ServletConfig config) {
	int maxSize = -1;
	String maxSizeS = getOption(config, OPTION_MAXSIZE, null);
	if (maxSizeS != null) {
		try {
			maxSize = Integer.parseInt(maxSizeS);
		} catch (Exception ex) {
			maxSize = -1;
		}
	}
	if (maxSize < 0) {
		maxSize = Constants.MAX_POOL_SIZE;
	}
	this.handlers = new Tag[maxSize];
	this.current = -1;
	instanceManager = InstanceManagerFactory.getInstanceManager(config);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:18,代码来源:TagHandlerPool.java

示例13: get

import javax.servlet.jsp.tagext.Tag; //导入依赖的package包/类
/**
 * Gets the next available tag handler from this tag handler pool,
 * instantiating one if this tag handler pool is empty.
 * 
 * @param handlerClass
 *            Tag handler class
 * @return Reused or newly instantiated tag handler
 * @throws JspException
 *             if a tag handler cannot be instantiated
 */
public Tag get(Class<? extends Tag> handlerClass) throws JspException {
	Tag handler;
	synchronized (this) {
		if (current >= 0) {
			handler = handlers[current--];
			return handler;
		}
	}

	// Out of sync block - there is no need for other threads to
	// wait for us to construct a tag for this thread.
	try {
		if (Constants.USE_INSTANCE_MANAGER_FOR_TAGS) {
			return (Tag) instanceManager.newInstance(handlerClass.getName(), handlerClass.getClassLoader());
		} else {
			Tag instance = handlerClass.newInstance();
			instanceManager.newInstance(instance);
			return instance;
		}
	} catch (Exception e) {
		Throwable t = ExceptionUtils.unwrapInvocationTargetException(e);
		ExceptionUtils.handleThrowable(t);
		throw new JspException(e.getMessage(), t);
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:36,代码来源:TagHandlerPool.java

示例14: renderTag

import javax.servlet.jsp.tagext.Tag; //导入依赖的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

示例15: simpleBindWithHtmlEscaping

import javax.servlet.jsp.tagext.Tag; //导入依赖的package包/类
@Test
public void simpleBindWithHtmlEscaping() throws Exception {
	final String NAME = "Rob \"I Love Mangos\" Harrop";
	final String HTML_ESCAPED_NAME = "Rob &quot;I Love Mangos&quot; Harrop";

	this.tag.setPath("name");
	this.rob.setName(NAME);

	assertEquals(Tag.SKIP_BODY, this.tag.doStartTag());

	String output = getOutput();
	assertTagOpened(output);
	assertTagClosed(output);

	assertContainsAttribute(output, "type", getType());
	assertValueAttribute(output, HTML_ESCAPED_NAME);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:InputTagTests.java


注:本文中的javax.servlet.jsp.tagext.Tag类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。