List of usage examples for javax.servlet.jsp JspException getMessage
public String getMessage()
From source file:org.openmrs.web.taglib.OpenmrsRequestContextAwareBodyTag.java
/** * After tag body has been evaluated and buffered this creates and exposes the current RequestContext. Delegates to * {@link #doEndTagInternal()} for actual work. *///ww w . jav a2s . co m @Override public final int doEndTag() throws JspException { try { // get request content available from pageContext this.requestContext = (RequestContext) this.pageContext .getAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE); // if request context is not specified, create empty request context and set it into pageContext if (this.requestContext == null) { this.requestContext = new JspAwareRequestContext(this.pageContext); this.pageContext.setAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE, this.requestContext); } // do actual work of this tag return doEndTagInternal(); } catch (JspException ex) { logger.error(ex.getMessage(), ex); throw ex; } catch (RuntimeException ex) { logger.error(ex.getMessage(), ex); throw ex; } catch (Exception ex) { logger.error(ex.getMessage(), ex); throw new JspTagException(ex.getMessage()); } }
From source file:net.mlw.vlh.web.tag.support.HtmlDisplayProvider.java
/** * Formats the text to be displayed as the header by wraping it in a link if * sorting is enabled. Alt (hint) is localized, please define in your * property file for messages the property "sorting" * /*from www . jav a2 s.c o m*/ * @param columnInfo The ColumnInfo. * @param tableInfo The TableInfo. * @param info The ValueListInfo. * @return The formated HTML. */ public String getHeaderLabel(ColumnInfo columnInfo, TableInfo tableInfo, ValueListInfo info, Map includeParameters) { ValueListConfigBean config = tableInfo.getConfig(); Map parameters = new HashMap(includeParameters); if (columnInfo.getDefaultSort() != null) { // Get the current sort column and direction. String column = info.getSortingColumn(); Integer direction = info.getSortingDirection(); parameters.put(ValueListInfo.PAGING_NUMBER_PER + tableInfo.getId(), String.valueOf(info.getPagingNumberPer())); parameters.put(ValueListInfo.PAGING_PAGE + tableInfo.getId(), "1"); parameters.put(ValueListInfo.SORT_COLUMN + tableInfo.getId(), columnInfo.getAdapterPropertyName()); parameters.put(ValueListInfo.SORT_DIRECTION + tableInfo.getId(), ((columnInfo.getAdapterPropertyName().equals(column)) ? (ValueListInfo.ASCENDING.equals(direction) ? ValueListInfo.DESCENDING : ValueListInfo.ASCENDING) : columnInfo.getDefaultSort())); if (info.isFocusEnabled()) { parameters.put(ValueListInfo.DO_FOCUS + tableInfo.getId(), info.isDoFocusAgain() ? "true" : "false"); if (info.getFocusProperty() != null) { parameters.put(ValueListInfo.FOCUS_PROPERTY + tableInfo.getId(), info.getFocusProperty()); } if (info.getFocusValue() != null) { parameters.put(ValueListInfo.FOCUS_VALUE + tableInfo.getId(), info.getFocusValue()); } } StringBuffer sb = new StringBuffer(); renderHeaderLabelLink(sb, columnInfo, tableInfo, info, parameters); if (columnInfo.getAdapterPropertyName().equals(column)) { if (usePadding) { sb.append(" "); } sb.append("<img src=\"") .append(getImageHome((HttpServletRequest) tableInfo.getPageContext().getRequest())) .append("/sort("); sb.append((ValueListInfo.ASCENDING.equals(direction) ? ValueListInfo.DESCENDING : ValueListInfo.ASCENDING)); sb.append(").png\" border=\"0\"/>"); } else if (columnInfo.getDefaultSort() != null) { Locale locale = config.getLocaleResolver() .resolveLocale((HttpServletRequest) (tableInfo.getPageContext().getRequest())); String altSort; try { altSort = config.getDisplayHelper().help(tableInfo.getPageContext(), config.getMessageSource().getMessage("sorting", null, "Sort", locale)); } catch (JspException e) { LOGGER.error("getHeaderLabel() - Error getting property 'sorting' : " + e.getMessage() + " Locale locale = " + locale + ", String column = " + column + " using defalt hint for sorting images."); altSort = "Sort"; } sb.append(((usePadding) ? " " : "")).append("<img alt=\"").append(altSort).append("\" src=\"") .append(getImageHome((HttpServletRequest) tableInfo.getPageContext().getRequest())) .append("/sort(null).png\" border=\"0\"/>"); } return sb.toString(); } else { return columnInfo.getTitle(); } }
From source file:org.hdiv.web.servlet.tags.form.SelectTagTests.java
public void testWithInvalidList() throws Exception { this.tag.setPath("country"); this.tag.setItems("${other}"); this.tag.setItemValue("isoCode"); try {/*from ww w.ja v a 2 s. c o m*/ this.tag.doStartTag(); fail("Must not be able to use a non-Collection typed value as the value of 'items'"); } catch (JspException expected) { String message = expected.getMessage(); assertTrue(message.indexOf("items") > -1); assertTrue(message.indexOf("org.hdiv.beans.TestBean") > -1); } }
From source file:com.sun.faces.taglib.jsf_core.ViewTag.java
public int doStartTag() throws JspException { int rc = 0;/*from w w w . j a va 2 s. co m*/ try { rc = super.doStartTag(); } catch (JspException e) { if (log.isDebugEnabled()) { log.debug("Can't leverage base class", e); } throw e; } catch (Throwable t) { if (log.isDebugEnabled()) { log.debug("Can't leverage base class", t); } throw new JspException(t); } FacesContext facesContext = FacesContext.getCurrentInstance(); Util.doAssert(facesContext != null); // this must happen after our overriderProperties executes. pageContext.getResponse().setLocale(facesContext.getViewRoot().getLocale()); ResponseWriter writer = facesContext.getResponseWriter(); Util.doAssert(writer != null); try { writer.startDocument(); } catch (IOException e) { throw new JspException(e.getMessage()); } return rc; }
From source file:org.apache.struts.taglib.TestTagUtils.java
public void testGetActionErrors1a() { ActionMessages actionErrors = new ActionMessages(); actionErrors.add("prop", new ActionMessage("key.key")); request.setAttribute("errors", actionErrors); try {/*from www . j a va 2 s.c om*/ ActionMessages errors = tagutils.getActionMessages(pageContext, "errors"); assertNotNull("errors should not be null", errors); assertNotNull("errors prop should not be null", errors.get("prop")); String val = null; int i = 0; for (Iterator iter = errors.get("prop"); iter.hasNext();) { ActionMessage error = (ActionMessage) iter.next(); val = error.getKey(); i++; } assertEquals("only 1 error", i, 1); assertEquals("errors prop should match", val, "key.key"); } catch (JspException e) { fail(e.getMessage()); } }
From source file:org.apache.struts.taglib.TestTagUtils.java
public void testGetActionErrors1b() { request.setAttribute("foo", "bar"); try {//from ww w .j av a 2 s . com ActionMessages errors = tagutils.getActionMessages(pageContext, "foo"); assertNotNull("errors should not be null", errors); assertNotNull("errors prop should not be null", errors.get("prop")); String key = null; int i = 0; for (Iterator iter = errors.get(ActionMessages.GLOBAL_MESSAGE); iter.hasNext();) { ActionMessage error = (ActionMessage) iter.next(); key = error.getKey(); Object[] values = error.getValues(); assertNull(values); i++; } assertEquals("only 1 error", i, 1); assertEquals("key should match", key, "bar"); } catch (JspException e) { fail(e.getMessage()); } }
From source file:org.apache.struts.taglib.TestTagUtils.java
public void testGetActionErrors1c() { String[] vals = new String[] { "bar", "baz" }; request.setAttribute("foo", vals); try {//from w w w .j a v a 2 s .com ActionMessages errors = tagutils.getActionMessages(pageContext, "foo"); assertNotNull("errors should not be null", errors); assertNotNull("errors prop should not be null", errors.get("prop")); String key = null; int i = 0; for (Iterator iter = errors.get(ActionMessages.GLOBAL_MESSAGE); iter.hasNext();) { ActionMessage error = (ActionMessage) iter.next(); key = error.getKey(); Object[] values = error.getValues(); assertNull((values)); assertEquals("1st key should match", key, vals[i]); i++; } assertEquals("only 1 error", i, 2); } catch (JspException e) { fail(e.getMessage()); } }
From source file:org.apache.struts.taglib.TestTagUtils.java
public void testGetActionErrors1e() { ActionMessages actionErrors = new ActionMessages(); actionErrors.add("prop", new ActionMessage("key.key")); request.setAttribute("errors", actionErrors); try {//from www .j a v a 2 s.co m ActionMessages errors = tagutils.getActionMessages(pageContext, "does-not-exist"); assertNotNull("errors should not be null", errors); assertNotNull("errors prop should not be null", errors.get("prop")); for (Iterator iter = errors.get("prop"); iter.hasNext();) { fail("Should not have any errors for does-not-exist"); } } catch (JspException e) { fail(e.getMessage()); } }
From source file:org.apache.struts.taglib.TestTagUtils.java
public void testActionMessages_getActionMessages_PageContext_String1() { ActionMessages actionMessages = new ActionMessages(); actionMessages.add("prop", new ActionMessage("key.key")); request.setAttribute("messages", actionMessages); try {/* w w w .j ava 2 s . co m*/ ActionMessages messages = tagutils.getActionMessages(pageContext, "messages"); assertNotNull("messages should not be null", messages); assertNotNull("messages prop should not be null", messages.get("prop")); String val = null; int i = 0; for (Iterator iter = messages.get("prop"); iter.hasNext();) { ActionMessage message = (ActionMessage) iter.next(); val = message.getKey(); i++; } assertEquals("only 1 message", i, 1); assertEquals("messages prop should match", val, "key.key"); } catch (JspException e) { fail(e.getMessage()); } }
From source file:org.apache.struts.taglib.TestTagUtils.java
public void testActionMessages_getActionMessages_PageContext_String2() { ActionMessages actionMessages = new ActionMessages(); actionMessages.add("prop", new ActionMessage("key.key")); request.setAttribute("messages", actionMessages); try {/*from w ww .j av a 2s . c o m*/ ActionMessages messages = tagutils.getActionMessages(pageContext, "messages"); assertNotNull("messages should not be null", messages); assertNotNull("messages prop should not be null", messages.get("prop")); String val = null; int i = 0; for (Iterator iter = messages.get("prop"); iter.hasNext();) { ActionMessage message = (ActionMessage) iter.next(); val = message.getKey(); i++; } assertEquals("only 1 message", i, 1); assertEquals("messages prop should match", val, "key.key"); } catch (JspException e) { fail(e.getMessage()); } }