Example usage for javax.servlet.jsp JspTagException JspTagException

List of usage examples for javax.servlet.jsp JspTagException JspTagException

Introduction

In this page you can find the example usage for javax.servlet.jsp JspTagException JspTagException.

Prototype


public JspTagException(Throwable rootCause) 

Source Link

Document

Constructs a new JSP Tag exception when the JSP Tag needs to throw an exception and include a message about the "root cause" exception that interfered with its normal operation.

Usage

From source file:org.jahia.taglibs.query.QueryDefinitionTag.java

/**
 * @return/*from   w w  w. j  av  a2  s . c o  m*/
 * @throws JspException
 */
@Override
public int doEndTag() throws JspException {
    try {
        pageContext.setAttribute(getVar(), getQueryObjectModel(), getScope());
    } catch (RepositoryException e) {
        throw new JspTagException(e);
    } finally {
        resetState();
    }

    return EVAL_PAGE;
}

From source file:org.easyrec.taglib.ProfileRenderer.java

@Override
public int doEndTag() throws JspTagException {
    try {/*www  . ja  va  2 s  . c  o  m*/
        String tagId = "profile" + Long.toString(System.currentTimeMillis());
        StringBuilder fullHTML = new StringBuilder();
        fullHTML.append("<div class=\"profile\">");
        String profileContent = getSourceViewJSON(profile); //since JSON is now the primary format, we try this first
        if (profileContent == null) {
            profileContent = getListViewHTML(profile);
        }
        if (profileContent == null) {
            profileContent = getSourceViewHTML(profile);
        }
        fullHTML.append("   <div id=\"profileHTML-").append(tagId).append("\">");
        fullHTML.append(profileContent);
        fullHTML.append("   </div>");
        fullHTML.append("</div>");

        pageContext.getOut().write(fullHTML.toString());
    } catch (java.io.IOException e) {
        throw new JspTagException("IO Error: " + e.getMessage());
    }
    return EVAL_PAGE;
}

From source file:org.hyperic.hq.ui.taglib.display.ImageButtonDecorator.java

public int doStartTag() throws JspTagException {
    ColumnTag ancestorTag = (ColumnTag) TagSupport.findAncestorWithClass(this, ColumnTag.class);
    if (ancestorTag == null) {
        throw new JspTagException("A CheckboxDecorator must be used within a ColumnTag.");
    }//www  .j  a  va 2  s .c o  m
    ancestorTag.setDecorator(this);
    return SKIP_BODY;
}

From source file:net.ontopia.topicmaps.webed.impl.utils.TagUtils.java

/**
 * Gets the topic map object from the given <code>obj_name</code> by
 * requesting the context manager retrieved by the given
 * <code>pageContext</code>.
 *//*from w ww .j  a va 2  s .  c om*/
public static TMObjectIF getTMObject(PageContext pageContext, String obj_name) throws JspTagException {

    Object obj = ContextUtils.getSingleValue(obj_name, pageContext);
    if (obj == null)
        return null;
    if (!(obj instanceof TMObjectIF))
        throw new JspTagException("Object with name '" + obj_name + "' " + "cannot be casted to TMObjectIF.");
    return ((TMObjectIF) obj);
}

From source file:org.hyperic.hq.ui.taglib.display.EqualsDecorator.java

public int doStartTag() throws JspTagException {
    ColumnTag ancestorTag = (ColumnTag) TagSupport.findAncestorWithClass(this, ColumnTag.class);

    if (ancestorTag == null) {
        throw new JspTagException("A BooleanDecorator must be used within a ColumnTag.");
    }//from  ww  w . j  a  va  2s.  c o  m

    // You have to make a clone, otherwise, if there are more than one
    // boolean decorator in this table, then we'll end up with only one
    // boolean decorator object
    EqualsDecorator clone;
    try {
        clone = (EqualsDecorator) this.clone();
    } catch (CloneNotSupportedException e) {
        // Then just use this
        clone = this;
    }

    ancestorTag.setDecorator(clone);
    return SKIP_BODY;
}

From source file:org.madsonic.taglib.UrlTag.java

private String formatUrl() throws JspException {
    String baseUrl = UrlSupport.resolveUrl(value, null, pageContext);

    StringBuilder result = new StringBuilder();
    result.append(baseUrl);//from   w w w.j  av  a 2  s.  co  m
    if (!parameters.isEmpty()) {
        result.append('?');

        for (int i = 0; i < parameters.size(); i++) {
            Parameter parameter = parameters.get(i);
            try {
                result.append(parameter.getName());
                if (isUtf8Hex() && !isAsciiAlphaNumeric(parameter.getValue())) {
                    result.append(ParameterDecodingFilter.PARAM_SUFFIX);
                }

                result.append('=');
                if (parameter.getValue() != null) {
                    result.append(encode(parameter.getValue()));
                }
                if (i < parameters.size() - 1) {
                    result.append("&");
                }

            } catch (UnsupportedEncodingException x) {
                throw new JspTagException(x);
            }
        }
    }
    return result.toString();
}

From source file:net.sourceforge.subsonic.taglib.UrlTag.java

private String formatUrl() throws JspException {
    String baseUrl = UrlSupport.resolveUrl(value, null, pageContext);

    StringBuffer result = new StringBuffer();
    result.append(baseUrl);//ww  w .  j a  v a2s . c  o m
    if (!parameters.isEmpty()) {
        result.append('?');

        for (int i = 0; i < parameters.size(); i++) {
            Parameter parameter = parameters.get(i);
            try {
                result.append(parameter.getName());
                if (isUtf8Hex() && !isAsciiAlphaNumeric(parameter.getValue())) {
                    result.append(ParameterDecodingFilter.PARAM_SUFFIX);
                }

                result.append('=');
                if (parameter.getValue() != null) {
                    result.append(encode(parameter.getValue()));
                }
                if (i < parameters.size() - 1) {
                    result.append("&");
                }

            } catch (UnsupportedEncodingException x) {
                throw new JspTagException(x);
            }
        }
    }
    return result.toString();
}

From source file:org.openmrs.web.taglib.ForEachDrugOrderTag.java

/**
 * @see javax.servlet.jsp.tagext.Tag#doEndTag()
 *//*from  w  w  w.j a  v a  2 s . c o m*/
public int doEndTag() throws JspException {
    try {
        if (count > 0 && bodyContent != null) {
            count = 0;
            bodyContent.writeOut(bodyContent.getEnclosingWriter());
        }
    } catch (java.io.IOException e) {
        throw new JspTagException("IO Error: " + e.getMessage());
    }
    return EVAL_PAGE;
}

From source file:org.hyperic.hq.ui.taglib.OptionMessageListTag.java

/**
 * Process the tag, generating and formatting the list.
 *
 * @exception JspException if the scripting variable can not be
 * found or if there is an error processing the tag
 */// w  w  w  .ja  v a  2 s.  c  o  m
public final int doStartTag() throws JspException {
    try {
        SelectTag selectTag = (SelectTag) pageContext.getAttribute(Constants.SELECT_KEY);
        Object collection = TagUtils.getInstance().lookup(pageContext, name, property, null);

        if (collection == null) {
            _log.warn("OptionMessageList tag was looking for bean=" + name + " property=" + property
                    + " but it wasn't " + "found");
            throw new JspTagException("Unable to find bean=" + name + " property=" + property);
        }

        JspWriter out = pageContext.getOut();
        StringBuffer sb = new StringBuffer();
        for (Iterator i = getIterator(collection); i.hasNext();) {
            Object next = i.next();
            String value, key;

            if (next instanceof LabelValueBean) {
                LabelValueBean bean = (LabelValueBean) next;
                value = bean.getValue();
                key = _baseKey + '.' + bean.getLabel();
            } else {
                value = String.valueOf(next);
                key = _baseKey + '.' + value;
            }

            String label = TagUtils.getInstance().message(pageContext, _bundle, _locale, key);

            addOption(sb, label, value, selectTag.isMatched(value));
        }
        out.write(sb.toString());

        return SKIP_BODY;
    } catch (IOException e) {
        _log.warn("Unabel to generate message list", e);
        throw new JspTagException(e.toString());
    } catch (JspException e) {
        _log.warn("Unabel to generate message list", e);
        throw new JspTagException(e.toString());
    } catch (Exception e) {
        _log.warn("Unable to generate message list", e);
        throw new JspTagException(e.toString());
    }
}

From source file:ar.edu.unicen.exa.aop.aopetstore.waf.view.taglibs.smart.ClientStateTag.java

public int doStartTag() throws JspTagException {
    if (imageURL == null && buttonText == null) {
        throw new JspTagException(
                "ClientStateTag error: either an " + "imageURL or buttonText attribute must be specified.");
    }//  ww  w . j a v a  2s.  co  m
    return EVAL_BODY_BUFFERED;
}