Java Code Examples for javax.servlet.jsp.tagext.Tag#SKIP_BODY

The following examples show how to use javax.servlet.jsp.tagext.Tag#SKIP_BODY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebAppURLTag.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@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;
   }
 
Example 2
Source File: FormatMiliSecondsTag.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int doStartTag() {
	String ret = FormatUtil.formatMiliSeconds(time);

	try {
		pageContext.getOut().write(ret);
	} catch (IOException e) {
		e.printStackTrace();
	}

	return Tag.SKIP_BODY;
}
 
Example 3
Source File: TableColumnsTag.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
private int pollNext ()
{
    if ( !this.columns.isEmpty () )
    {
        this.pageContext.setAttribute ( this.var, this.columns.pollFirst () );
        return Tag.EVAL_BODY_INCLUDE;
    }
    else
    {
        return Tag.SKIP_BODY;
    }
}
 
Example 4
Source File: PermissionTag.java    From lemon with Apache License 2.0 5 votes vote down vote up
public int doStartTag() throws JspException {
    boolean authorized = getPermissionChecker().isAuthorized(permission);

    if (!authorized) {
        return Tag.SKIP_BODY;
    }

    return Tag.EVAL_BODY_INCLUDE;
}
 
Example 5
Source File: TableRowTag.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
private int pollNext ()
{
    if ( this.providers == null || this.providers.isEmpty () )
    {
        return Tag.SKIP_BODY;
    }

    this.currentProvider = this.providers.pollFirst ();

    return Tag.EVAL_BODY_INCLUDE;
}
 
Example 6
Source File: DefineBindTag.java    From hasor with Apache License 2.0 5 votes vote down vote up
@Override
public int doStartTag() throws JspException {
    verifyAttribute(AttributeNames.Var, AttributeNames.BindType, AttributeNames.Name);
    //
    try {
        AppContext appContext = getAppContext();
        ClassLoader classLoader = ClassUtils.getClassLoader(appContext.getClassLoader());
        Class<?> defineType = Class.forName(this.getBindType(), false, classLoader);
        storeToVar(appContext.findBindingBean(this.getName(), defineType));
        return Tag.SKIP_BODY;
    } catch (ClassNotFoundException e) {
        throw new JspException(e);
    }
}
 
Example 7
Source File: TableExtensionTag.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public int doStartTag () throws JspException
{
    final TableRowTag rowTag = (TableRowTag)findAncestorWithClass ( this, TableRowTag.class );
    if ( rowTag == null )
    {
        return Tag.SKIP_BODY;
    }

    final TableColumnProvider provider = rowTag.getCurrentProvider ();
    if ( provider == null )
    {
        return Tag.SKIP_BODY;
    }

    final TableDescriptor descriptor = rowTag.getDescriptor ();
    if ( descriptor == null )
    {
        return Tag.SKIP_BODY;
    }

    final Object item = rowTag.getItem ();

    final PrintWriter pw = new PrintWriter ( this.pageContext.getOut () );

    try
    {
        provider.provideContent ( descriptor, item, pw );
    }
    catch ( final IOException e )
    {
        throw new JspException ( e );
    }

    return Tag.SKIP_BODY;
}
 
Example 8
Source File: InputList.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
private int pushNext ( final boolean first )
{
    this.index++;

    if ( this.index >= this.items.length )
    {
        return Tag.SKIP_BODY;
    }

    this.currentValue = this.items[this.index];
    this.pageContext.setAttribute ( this.var, this.currentValue );

    return first ? EVAL_BODY_INCLUDE : EVAL_BODY_AGAIN;
}
 
Example 9
Source File: InputList.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public int doStartTag () throws JspException
{
    final Object value = getPathValue ( this.path );

    if ( value == null )
    {
        return Tag.SKIP_BODY;
    }

    if ( value.getClass ().isArray () )
    {
        this.items = (Object[])value;
    }
    else if ( value instanceof Collection<?> )
    {
        final int length = ( (Collection<?>)value ).size ();
        this.items = ( (Collection<?>)value ).toArray ( new Object[length] );
    }
    else
    {
        this.items = new Object[] { value };
    }

    this.index = -1;
    return pushNext ( true );
}
 
Example 10
Source File: DefineTypeTag.java    From hasor with Apache License 2.0 5 votes vote down vote up
@Override
public int doStartTag() throws JspException {
    verifyAttribute(AttributeNames.Var, AttributeNames.BindType);
    //
    try {
        AppContext appContext = getAppContext();
        ClassLoader classLoader = ClassUtils.getClassLoader(appContext.getClassLoader());
        Class<?> defineType = Class.forName(this.getBindType(), false, classLoader);
        storeToVar(appContext.getInstance(defineType));
        return Tag.SKIP_BODY;
    } catch (ClassNotFoundException e) {
        throw new JspException(e);
    }
}
 
Example 11
Source File: FormatSizeTag.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int doStartTag() {
	String ret = FormatUtil.formatSize(size);

	try {
		pageContext.getOut().write(ret);
	} catch (IOException e) {
		e.printStackTrace();
	}

	return Tag.SKIP_BODY;
}
 
Example 12
Source File: GetNameTag.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int doStartTag() {
	String ret = PathUtils.getName(path);

	try {
		pageContext.getOut().write(ret);
	} catch (IOException e) {
		e.printStackTrace();
	}

	return Tag.SKIP_BODY;
}
 
Example 13
Source File: EscapeHtmlTag.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int doStartTag() {
	String ret = FormatUtil.escapeHtml(string);

	try {
		pageContext.getOut().write(ret);
	} catch (IOException e) {
		e.printStackTrace();
	}

	return Tag.SKIP_BODY;
}
 
Example 14
Source File: StartsWithTag.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int doStartTag() {
	boolean ret = string.startsWith(prefix);

	try {
		pageContext.getOut().write(Boolean.toString(ret));
	} catch (IOException e) {
		e.printStackTrace();
	}

	return Tag.SKIP_BODY;
}
 
Example 15
Source File: RaceIconTag.java    From CardFantasy with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public int doEndTag() {
    JspWriter writer = this.pageContext.getOut();
    try {
        String tagText = String.format(
                "<img src='%s/resources/img/frame/Race_%s_Icon.png' alt='%s' title='%s' class='%s' />",
                this.pageContext.getServletContext().getContextPath(),
                this.getRaceName(), this.getRaceName(), this.getRaceName(),
                (this.cssClass == null || this.cssClass.isEmpty()) ? "race-icon" : this.cssClass);
        writer.print(tagText);
    } catch (IOException e) {
        logger.error(e);
    }
    return Tag.SKIP_BODY;
}
 
Example 16
Source File: PropertyIconTag.java    From CardFantasy with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public int doEndTag() {
    JspWriter writer = this.pageContext.getOut();
    try {
        String tagText = String.format(
                "<img src='%s/resources/img/frame/Property_%s_Icon.png' class='%s' />",
                this.pageContext.getServletContext().getContextPath(),
                this.getPropertyName(),
                (this.cssClass == null || this.cssClass.isEmpty()) ? "property-icon" : this.cssClass);
        writer.print(tagText);
    } catch (IOException e) {
        logger.error(e);
    }
    return Tag.SKIP_BODY;
}
 
Example 17
Source File: PortraitTag.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
   public int doEndTag() throws JspException {

String serverURL = Configuration.get(ConfigurationKeys.SERVER_URL);
serverURL = serverURL == null ? null : serverURL.trim();

try {
    if (userId != null && userId.length() > 0) {
	String code = null;
	HashMap<String, String> cache = getPortraitCache();
	code = cache.get(userId);

	if (code == null) {
	    Integer userIdInt = Integer.decode(userId);
	    User user = (User) getUserManagementService().findById(User.class, userIdInt);
	    boolean isHover = (hover != null ? Boolean.valueOf(hover) : false);
	    if ( isHover ) {
		code = buildHoverUrl(user);
	    } else {
		code = buildDivUrl(user);
	    }
	    cache.put(userId, code);
	}

	JspWriter writer = pageContext.getOut();
	writer.print(code);
    }

} catch (NumberFormatException nfe) {
    PortraitTag.log.error("PortraitId unable to write out portrait details as userId is invalid. " + userId,
	    nfe);
} catch (IOException ioe) {
    PortraitTag.log.error(
	    "PortraitId unable to write out portrait details due to IOException. UserId is " + userId, ioe);
} catch (Exception e) {
    PortraitTag.log.error(
	    "PortraitId unable to write out portrait details due to an exception. UserId is " + userId, e);
}
return Tag.SKIP_BODY;
   }
 
Example 18
Source File: DefineBeanTag.java    From hasor with Apache License 2.0 4 votes vote down vote up
@Override
public int doStartTag() {
    verifyAttribute(AttributeNames.Var, AttributeNames.BeanID);
    storeToVar(getAppContext().getBindInfo(this.getBeanID()));
    return Tag.SKIP_BODY;
}
 
Example 19
Source File: CardLogoTag.java    From CardFantasy with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public int doEndTag() {
    JspWriter writer = this.pageContext.getOut();
    try {
        OfficialCard card = OfficialDataStore.getInstance().getCardByName(this.getCardName());
        String contextPath = this.pageContext.getServletContext().getContextPath();
        String cardPageUrl = contextPath + "/Wiki/Cards/" + card.getCardId() + ".shtml";
        String frameUrlFormat = contextPath + "/resources/img/frame/Square_%s_Frame.png";
        String invisibleFrameUrl = contextPath + "/resources/img/frame/Invisible_Square_Frame.png";
        String starUrl = contextPath + "/resources/img/frame/Star_" + card.getColor() + "_Bar.png";
        String logoUrl = card.getLogoUrl();

        /*
                <div class="card-logo-container">
                    <div class="card-logo">
                        <a href="<c:url value="/Wiki" />/Cards/${card.cardName}.shtml"><cf:cardLogo cardName="${card.cardName}" /></a>
                    </div>
                    <div class="card-name">
                        ${card.cardName}
                    </div>
                </div>
         */
        writer.println(String.format(
            "<div class='card-logo-container%s'>",
            this.isResponsive() ? " responsive" : ""));
        writer.println(String.format(
                "<div class='card-frame'><img src='%s' style='width: 100%%' /></div>",
                this.frameVisible ? String.format(frameUrlFormat, card.getRaceName()) : invisibleFrameUrl));
        writer.println(String.format(
                "<div class='card-logo'>" +
                    "<a href='%s' target='_self'>" +
                        "<img src='%s' alt='%s' title='%s' style='width: 100%%' />" +
                    "</a>" +
                "</div>",
            cardPageUrl,
            logoUrl, this.getCardName(), this.getCardName()));
        if (this.cardNameVisible) {
            writer.println(String.format(
                "<div class='card-name'>%s</div>", this.getCardName()));
        }
        if (this.starBarVisible) {
            writer.println(String.format(
                "<div class='card-star'><img src='%s' style='width: 100%%' /></div>", starUrl)); 
        }
        writer.println(
            "</div>");
    } catch (IOException e) {
        logger.error(e);
    }
    return Tag.SKIP_BODY;
}
 
Example 20
Source File: RuneLogoTag.java    From CardFantasy with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public int doEndTag() {
    JspWriter writer = this.pageContext.getOut();
    try {
        OfficialRune rune = OfficialDataStore.getInstance().getRuneByName(this.getRuneName());
        String contextPath = this.pageContext.getServletContext().getContextPath();
        String runePageUrl = contextPath + "/Wiki/Runes/" + rune.getRuneId() + ".shtml";
        String frameUrlFormat = contextPath + "/resources/img/frame/Square_Frame.png";
        String invisibleFrameUrl = contextPath + "/resources/img/frame/Invisible_Square_Frame.png";
        String starUrl = contextPath + "/resources/img/frame/Star_" + rune.getColor() + "_Bar.png";
        String logoUrl = rune.getSmallIconUrl();
        
        /*
                <div class="card-logo-container">
                    <div class="card-logo">
                        <a href="<c:url value="/Wiki" />/Cards/${card.cardName}"><cf:cardLogo cardName="${card.cardName}" /></a>
                    </div>
                    <div class="card-name">
                        ${card.cardName}
                    </div>
                </div>
         */
        writer.println(String.format(
            "<div class='rune-logo-container%s'>",
            this.isResponsive() ? " responsive" : ""));
        writer.println(String.format(
                "<div class='rune-frame'><img src='%s' style='width: 100%%' /></div>",
                this.frameVisible ? frameUrlFormat : invisibleFrameUrl));
        writer.println(String.format(
                "<div class='rune-logo'>" +
                    "<a href='%s' target='_self'>" +
                        "<img src='%s' alt='%s' title='%s' style='width: 100%%' />" +
                    "</a>" +
                "</div>",
            runePageUrl,
            logoUrl, this.getRuneName(), this.getRuneName()));
        if (this.runeNameVisible) {
            writer.println(String.format(
                "<div class='rune-name'>%s</div>", this.getRuneName()));
        }
        if (this.starBarVisible) {
            writer.println(String.format(
                "<div class='rune-star'><img src='%s' style='width: 100%%' /></div>", starUrl)); 
        }
        writer.println(
            "</div>");
    } catch (IOException e) {
        logger.error(e);
    }
    return Tag.SKIP_BODY;
}