List of usage examples for javax.servlet.jsp JspTagException JspTagException
public JspTagException(Throwable rootCause)
From source file:org.hyperic.hq.ui.taglib.RecentAlertsTag.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 *//*from w w w . j ava2 s . c o m*/ public final int doStartTag() throws JspException { try { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); ServletContext ctx = pageContext.getServletContext(); EventsBoss eb = Bootstrap.getBean(EventsBoss.class); AuthzBoss ab = Bootstrap.getBean(AuthzBoss.class); int sessionId = RequestUtils.getSessionId(request).intValue(); // Recent alerts in the last two hours List userAlerts = eb.findRecentAlerts(sessionId, maxAlerts, 0, 2 * MeasurementConstants.HOUR, null); if (log.isTraceEnabled()) { log.trace("found " + userAlerts.size() + " recent alerts"); } ArrayList alertArr = new ArrayList(); Iterator it = userAlerts.iterator(); AuthzSubject subject = ab.getCurrentSubject(sessionId); for (int i = 0; i < maxAlerts && it.hasNext(); i++) { Escalatable alert = (Escalatable) it.next(); AlertDefinitionInterface defInfo = alert.getDefinition().getDefinitionInfo(); AppdefEntityID adeId = AppdefUtil.newAppdefEntityId(defInfo.getResource()); AppdefEntityValue aVal = new AppdefEntityValue(adeId, subject); alertArr.add(new RecentAlertBean(alert.getId(), alert.getAlertInfo().getTimestamp(), defInfo.getId(), defInfo.getName(), 0, adeId.getId(), new Integer(adeId.getType()), aVal.getName(), alert.getAlertInfo().isFixed())); } Object[] recentAlerts = alertArr.toArray(new RecentAlertBean[0]); request.setAttribute(var, recentAlerts); request.setAttribute(sizeVar, new Integer(recentAlerts.length)); } catch (SessionNotFoundException e) { log.warn("User is not logged in"); } catch (SessionTimeoutException e) { log.warn("User session has expired"); } catch (Exception e) { log.warn("Error while generating recent alerts tag", e); throw new JspTagException(e.getMessage()); } return SKIP_BODY; }
From source file:se.softhouse.garden.orchid.spring.tags.OrchidMessageTag.java
/** * Resolve the specified message into a concrete message String. The * returned message String should be unescaped. */// ww w .ja v a 2s . c o m protected String resolveMessage() throws JspException, NoSuchMessageException { MessageSource messageSource = getMessageSource(); if (messageSource == null) { throw new JspTagException("No corresponding MessageSource found"); } try { String resolvedCode = ExpressionEvaluationUtils.evaluateString("code", this.code, this.pageContext); if (resolvedCode != null) { HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest(); HttpServletResponse response = (HttpServletResponse) this.pageContext.getResponse(); this.arguments.arg(OrchidMessageFormatLinkFunction.LINK_FUNC, new OrchidMessageFormatLinkFunction(request, response)); // We have a code or default text that we need to resolve. Object[] argumentsArray = new Object[] { this.arguments }; String message = messageSource.getMessage(resolvedCode, argumentsArray, getRequestContext().getLocale()); String type = messageSource.getMessage("+.type." + resolvedCode, argumentsArray, null, getRequestContext().getLocale()); return formatMessage(message, type); } // All we have is a specified literal text. return this.code; } catch (Throwable e) { return this.defaultMessage; } }
From source file:org.jsecurity.web.tags.PrincipalTag.java
private String getPrincipalProperty(Object principal, String property) throws JspTagException { String strValue = null;//from w ww . j a va2 s. co m try { BeanInfo bi = Introspector.getBeanInfo(principal.getClass()); // Loop through the properties to get the string value of the specified property boolean foundProperty = false; for (PropertyDescriptor pd : bi.getPropertyDescriptors()) { if (pd.getName().equals(property)) { Object value = pd.getReadMethod().invoke(principal, (Object[]) null); strValue = String.valueOf(value); foundProperty = true; break; } } if (!foundProperty) { final String message = "Property [" + property + "] not found in principal of type [" + principal.getClass().getName() + "]"; if (log.isErrorEnabled()) { log.error(message); } throw new JspTagException(message); } } catch (Exception e) { final String message = "Error reading property [" + property + "] from principal of type [" + principal.getClass().getName() + "]"; if (log.isErrorEnabled()) { log.error(message, e); } throw new JspTagException(message, e); } return strValue; }
From source file:net.ontopia.topicmaps.nav2.utils.FrameworkUtils.java
/** * INTERNAL: Returns the values retrieved from the given variable * names or qnames in the order given.//from w ww . j ava2s. c om * * @param params - variable names or qnames, separated by whitespaces. */ private static List getMultipleValuesAsList(String params, PageContext pageContext) throws JspTagException { log.debug("getMultipleValuesAsList"); // find parsecontext NavigatorPageIF ctxt = (NavigatorPageIF) pageContext.getAttribute(NavigatorApplicationIF.CONTEXT_KEY, PageContext.REQUEST_SCOPE); ParseContextIF pctxt = (ParseContextIF) ctxt.getDeclarationContext(); // get the values String[] names = StringUtils.split(params); List varlist = new ArrayList(names.length); for (int i = 0; i < names.length; i++) { Collection values; if (names[i].indexOf(':') != -1) { // it's a qname try { values = Collections.singleton(pctxt.getObject(new QName(names[i]))); } catch (AntlrWrapException e) { throw new JspTagException(e.getException().getMessage() + " (in action parameter list)"); } } else // it's a variable name values = InteractionELSupport.extendedGetValue(names[i], pageContext); varlist.add(values); } return varlist; }
From source file:com.redhat.rhn.frontend.taglibs.ListDisplayTagBase.java
protected void setupPageList() throws JspTagException { ListTag listTag = (ListTag) findAncestorWithClass(this, ListTag.class); if (listTag == null) { throw new JspTagException("Tag nesting error: " + "listDisplay must be nested in a list tag"); }/*w ww. j ava2s . c o m*/ pageList = listTag.getPageList(); iterator = pageList.iterator(); }
From source file:com.seajas.search.utilities.tags.MessageTag.java
/** * Resolve the specified message into a concrete message String. The returned message String should be unescaped. * //from www .j a v a 2 s . c o m * @throws JspException * @throws NoSuchMessageException */ protected String resolveMessage() throws JspException, NoSuchMessageException { MessageSource messageSource = getMessageSource(); if (messageSource == null) { throw new JspTagException("No corresponding MessageSource found"); } // Evaluate the specified MessageSourceResolvable, if any. MessageSourceResolvable resolvedMessage = null; if (this.message instanceof MessageSourceResolvable) { resolvedMessage = (MessageSourceResolvable) this.message; } else if (this.message != null) { String expr = this.message.toString(); resolvedMessage = (MessageSourceResolvable) ExpressionEvaluationUtils.evaluate("message", expr, MessageSourceResolvable.class, pageContext); } if (resolvedMessage != null) { // We have a given MessageSourceResolvable. return messageSource.getMessage(resolvedMessage, getRequestContext().getLocale()); } String resolvedCode = ExpressionEvaluationUtils.evaluateString("code", this.code, pageContext); String resolvedText = ExpressionEvaluationUtils.evaluateString("text", this.text, pageContext); if (resolvedCode != null || resolvedText != null) { // We have a code or default text that we need to resolve. Object[] argumentsArray = arguments.toArray(new Object[arguments.size()]); if (resolvedText != null) { // We have a fallback text to consider. return messageSource.getMessage(resolvedCode, argumentsArray, resolvedText, getRequestContext().getLocale()); } else { // We have no fallback text to consider. return messageSource.getMessage(resolvedCode, argumentsArray, getRequestContext().getLocale()); } } // All we have is a specified literal text. return resolvedText; }
From source file:org.opencms.jsp.CmsJspTagContentShow.java
/** * @see javax.servlet.jsp.tagext.Tag#doStartTag() *///from w w w .j a va2 s. c o m @Override public int doStartTag() throws JspException { // get a reference to the parent "content container" class Tag ancestor = findAncestorWithClass(this, I_CmsXmlContentContainer.class); if (ancestor == null) { CmsMessageContainer errMsgContainer = Messages.get().container(Messages.ERR_PARENTLESS_TAG_1, "contentshow"); String msg = Messages.getLocalizedMessage(errMsgContainer, pageContext); throw new JspTagException(msg); } I_CmsXmlContentContainer contentContainer = (I_CmsXmlContentContainer) ancestor; // now get the content element value to display String content = contentShowTagAction(contentContainer, pageContext, getElement(), m_locale, m_escapeHtml); try { if (content != null) { pageContext.getOut().print(content); } } catch (IOException e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_ERR_JSP_BEAN_0), e); } throw new JspException(e); } return SKIP_BODY; }
From source file:com.ei.itop.common.tag.MessageTag.java
/** * Resolves the message, escapes it if demanded, * and writes it to the page (or exposes it as variable). * @see #resolveMessage()/* ww w. j av a 2s. c om*/ * @see org.springframework.web.util.HtmlUtils#htmlEscape(String) * @see org.springframework.web.util.JavaScriptUtils#javaScriptEscape(String) * @see #writeMessage(String) */ @Override protected final int doStartTagInternal() throws JspException, IOException { try { // Resolve the unescaped message. String msg = resolveMessage(); // HTML and/or JavaScript escape, if demanded. msg = isHtmlEscape() ? HtmlUtils.htmlEscape(msg) : msg; msg = this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(msg) : msg; // Expose as variable, if demanded, else write to the page. String resolvedVar = ExpressionEvaluationUtils.evaluateString("var", this.var, pageContext); if (resolvedVar != null) { String resolvedScope = ExpressionEvaluationUtils.evaluateString("scope", this.scope, pageContext); pageContext.setAttribute(resolvedVar, msg, TagUtils.getScope(resolvedScope)); } else { writeMessage(msg); } return EVAL_BODY_INCLUDE; } catch (NoSuchMessageException ex) { throw new JspTagException(getNoSuchMessageExceptionDescription(ex)); } }
From source file:org.terasoluna.gfw.web.message.MessagesPanelTag.java
/** * Creates messagesPanel tag/* ww w .j av a 2 s .c om*/ * @throws JspException In case when {@link JspException} is generated later in the chain when tag configured by * messagesPanel could not be created * @see org.springframework.web.servlet.tags.RequestContextAwareTag#doStartTagInternal() */ @Override protected int doStartTagInternal() throws JspException { if (!StringUtils.hasText(this.panelElement) && !StringUtils.hasText(this.outerElement) && !StringUtils.hasText(this.innerElement)) { throw new JspTagException("At least one out of panelElement, outerElement, innerElement should be set"); } TagWriter tagWriter = createTagWriter(); Object messages = this.pageContext.findAttribute(messagesAttributeName); if (messages != null) { if (StringUtils.hasText(panelElement)) { tagWriter.startTag(panelElement); // <div> StringBuilder className = new StringBuilder(panelClassName); String type = getType(messages); appendPanelTypeClassPrefix(className, type); className.append(type); if (StringUtils.hasText(className)) { tagWriter.writeAttribute("class", className.toString()); } } if (StringUtils.hasText(outerElement)) { tagWriter.startTag(outerElement); // <ul> } writeMessages(tagWriter, messages); if (StringUtils.hasText(outerElement)) { tagWriter.endTag(); // </ul> } if (StringUtils.hasText(panelElement)) { tagWriter.endTag(); // </div> } } return EVAL_BODY_INCLUDE; }
From source file:org.hyperic.hq.ui.taglib.display.ResourceDecorator.java
public int doStartTag() throws JspTagException { ColumnTag ancestorTag = (ColumnTag) TagSupport.findAncestorWithClass(this, ColumnTag.class); if (ancestorTag == null) { throw new JspTagException("A ResourceDecorator must be used within a ColumnTag."); }// w w w . j a v a 2 s . c o m ancestorTag.setDecorator(this); return SKIP_BODY; }