List of usage examples for javax.servlet.jsp JspTagException JspTagException
public JspTagException(Throwable rootCause)
From source file:org.displaytag.util.DependencyChecker.java
/** * Displaytag requires commons-lang 2.x or better; it is not compatible with earlier versions. * @throws JspTagException if the wrong library, or no library at all, is found. *//* w w w. j a v a2 s. c om*/ public static void check() throws JspTagException { if (commonsLangChecked) { return; } try { // Do they have commons lang ? Class stringUtils = Class.forName("org.apache.commons.lang.StringUtils"); //$NON-NLS-1$ try { // this method is new in commons-lang 2.0 stringUtils.getMethod("capitalize", new Class[] { String.class }); //$NON-NLS-1$ } catch (NoSuchMethodException ee) { throw new JspTagException(Messages.getString("DependencyChecker.lib.incompatible", //$NON-NLS-1$ new Object[] { "commons-lang", new Integer(2), "http://jakarta.apache.org/commons/lang" } //$NON-NLS-1$ )); } } catch (ClassNotFoundException e) { throw new JspTagException(Messages.getString("DependencyChecker.lib.missing", //$NON-NLS-1$ new Object[] { "commons-lang", new Integer(2), "http://jakarta.apache.org/commons/lang" } //$NON-NLS-1$ )); } commonsLangChecked = true; }
From source file:org.terasoluna.gfw.web.util.JspTagUtils.java
/** * Convert to the Boolean value.//from w ww . j av a2s. co m * @param attributeValue string value of attribute * @param defaultValue If attribute value is not text(null or blank or whitespace only), apply this value. * @param attributeName attribute name (If attribute value is not true or false, sets in exception message) * @return converted Boolean value * @throws JspTagException If value that is not true or false is specified. */ public static boolean toBoolean(String attributeValue, boolean defaultValue, String attributeName) throws JspTagException { if (StringUtils.hasText(attributeValue)) { if ("true".equalsIgnoreCase(attributeValue) || "false".equalsIgnoreCase(attributeValue)) { return Boolean.parseBoolean(attributeValue); } else { throw new JspTagException("The value of " + attributeName + " must be either true or false."); } } return defaultValue; }
From source file:org.kmnet.com.fw.web.util.JspTagUtils.java
/** * Convert to the Boolean value./*from w w w . j a v a 2s. c o m*/ * @param attributeValue string value of attribute * @param defaultValue If attribute value is not text(null or blank or whitespace only), apply this value. * @param attributeName attribute name (If attribute value is not true or false, sets in exception message) * @return converted Boolean value * @throws JspTagException If value that is not true or false is specified. */ public static boolean toBoolean(String attributeValue, boolean defaultValue, String attributeName) throws JspTagException { if (StringUtils.hasText(attributeValue)) { if (attributeValue.equalsIgnoreCase("true") || attributeValue.equalsIgnoreCase("false")) { return Boolean.parseBoolean(attributeValue); } else { throw new JspTagException("The value of " + attributeName + " must be either true or false."); } } return defaultValue; }
From source file:com.rsmart.certification.tool.tag.AbstractLocalizableTag.java
/** * Resolve the specified message into a concrete message String. * The returned message String should be unescaped. * @param message//ww w . j a v a 2 s . com * @return * @throws javax.servlet.jsp.JspException */ protected String resolveMessage(String message) throws JspException, NoSuchMessageException { MessageSource messageSource = getMessageSource(); if (messageSource == null) { throw new JspTagException("No corresponding MessageSource found"); } return messageSource.getMessage(message, null, "??" + message + "??", getRequestContext().getLocale()); }
From source file:gov.nih.nci.calims2.taglib.EnumTag.java
/** * {@inheritDoc}/*from ww w. j ava 2 s .co m*/ */ public int doStartTag() throws JspException { try { Locale locale = TagHelper.getRequestContext(pageContext).getLocale(); if (value != null) { String message = (propertyName == null) ? value.getLocalizedValue(locale) : getPropertyValue(locale); pageContext.getOut().print(StringEscapeUtils.escapeHtml(message)); } return SKIP_BODY; } catch (IOException e) { throw new JspException(e); } catch (Exception e) { throw new JspTagException(e); } }
From source file:net.sourceforge.subsonic.taglib.WikiTag.java
public int doEndTag() throws JspException { String result;//from ww w . j a va 2s .c o m synchronized (RENDER_ENGINE) { result = RENDER_ENGINE.render(StringEscapeUtils.unescapeXml(text), RENDER_CONTEXT); } try { pageContext.getOut().print(result); } catch (IOException x) { throw new JspTagException(x); } return EVAL_PAGE; }
From source file:org.codehaus.groovy.grails.web.taglib.jsp.JspRenderInputTag.java
@Override protected int doStartTagInternal() throws Exception { if (StringUtils.isBlank(property)) { throw new JspTagException("Tag [renderInput] missing required attribute [property]"); }/*from w ww .j av a 2 s. c o m*/ if (StringUtils.isBlank(bean)) { throw new JspTagException("Tag [renderInput] missing required attribute [bean]"); } if (!ExpressionEvaluationUtils.isExpressionLanguage(bean)) { throw new JspTagException("Attribute [bean] of tag [renderInput] must be a JSTL expression"); } @SuppressWarnings("unused") Writer out = pageContext.getOut(); try { Object beanInstance = ExpressionEvaluationUtils.evaluate("bean", bean, Object.class, pageContext); if (beanInstance == null) { throw new JspTagException("Bean [" + bean + "] referenced by tag [renderInput] cannot be null"); } GrailsTagRegistry tagRegistry = GrailsTagRegistry.getInstance(); Map<String, Object> tagContext = new HashMap<String, Object>(); tagContext.put(GroovyPage.REQUEST, pageContext.getRequest()); tagContext.put(GroovyPage.RESPONSE, pageContext.getResponse()); tagContext.put(GroovyPage.SERVLET_CONTEXT, pageContext.getServletContext()); RenderInputTag tag = (RenderInputTag) tagRegistry.newTag(RenderInputTag.TAG_NAME); tag.init(tagContext); tag.setBean(beanInstance); tag.setProperty(property); tag.doStartTag(); } catch (InvalidPropertyException ipe) { throw new JspException("Attribute [property] with value [" + property + "] is not a valid property of bean [" + bean + "] in tag [renderInput]", ipe); } return SKIP_BODY; }
From source file:net.sourceforge.subsonic.taglib.FormatBytesTag.java
public int doEndTag() throws JspException { Locale locale = RequestContextUtils.getLocale((HttpServletRequest) pageContext.getRequest()); String result = StringUtil.formatBytes(bytes, locale); try {/*from w w w .j av a 2s . c o m*/ pageContext.getOut().print(result); } catch (IOException x) { throw new JspTagException(x); } return EVAL_PAGE; }
From source file:com.benfante.taglib.frontend.tags.AlertTag.java
protected final int doStartTagInternal() throws JspException, IOException { try {//from w ww. ja v a 2s . co m Map<String, String> flash = (Map<String, String>) pageContext.getRequest().getAttribute("flash"); if (flash == null) flash = (Map<String, String>) pageContext.getSession().getAttribute("flash"); if (flash != null && flash.get(type) != null) { // Resolve the message. MessageSource messageSource = getMessageSource(); if (messageSource == null) { throw new JspTagException("No corresponding MessageSource found"); } String msg = ""; try { Object[] argumentsArray = {}; msg = messageSource.getMessage(flash.get(type), argumentsArray, getRequestContext().getLocale()); } catch (Exception ex) { // If the message is unresolved, use the key as message msg = flash.get(type); } // Write the message writeMessage(msg); // And clean the session flash.remove(type); } return EVAL_BODY_INCLUDE; } catch (NoSuchMessageException ex) { throw new JspTagException(getNoSuchMessageExceptionDescription(ex)); } }
From source file:net.sourceforge.subsonic.taglib.EscapeJavaScriptTag.java
public int doEndTag() throws JspException { try {//from www . j a v a 2s. c om pageContext.getOut().print(StringEscapeUtils.escapeJavaScript(string)); } catch (IOException x) { throw new JspTagException(x); } return EVAL_PAGE; }