List of usage examples for javax.servlet.jsp JspTagException JspTagException
public JspTagException(Throwable rootCause)
From source file:org.hyperic.hq.ui.taglib.display.AvailabilityDecorator.java
public int doStartTag() throws JspTagException { ColumnTag ancestorTag = (ColumnTag) TagSupport.findAncestorWithClass(this, ColumnTag.class); if (ancestorTag == null) { throw new JspTagException("An AvailabilityDecorator must be used within a ColumnTag."); }/*from w w w. j a v a 2 s. c o m*/ // the rules are a little more complicated than what can be expressed in // the tld... if (resourceIsSet) { if (resourceIdIsSet || resourceTypeIdIsSet) { throw new JspTagException("An AvailabilityDecorator must either specify a 'resource' " + " attribute or both 'resourceId' and 'resourceTypeId' attributes"); } } else if (!valueIsSet) { if (!resourceIdIsSet && !resourceTypeIdIsSet) { throw new JspTagException("An AvailabilityDecorator must either specify a 'resource' " + " attribute or both 'resourceId' and 'resourceTypeId' attributes"); } } ancestorTag.setDecorator(this); return SKIP_BODY; }
From source file:jp.terasoluna.fw.web.struts.taglib.BodyTag.java
/** * ^O]Jn?\bh?B/* ww w . j a va2 s .c o m*/ * * @return ???w?B? <code>EVAL_BODY_INCLUDE</code> * @throws JspException JSPO */ @Override public int doStartTag() throws JspException { HttpServletRequest req = (HttpServletRequest) pageContext.getRequest(); String onLoadBody = (String) req.getAttribute(ON_LOAD_KEY); StringBuilder tag = new StringBuilder(); tag.append("<body"); if (onLoadBody != null || onload != null) { tag.append(" onLoad=\"__onLoad__()\""); } if (this.onunload != null) { tag.append(" onUnLoad=\"" + this.onunload + "\""); } if (this.styleClass != null) { tag.append(" class=\"" + this.styleClass + "\""); } if (this.bgcolor != null) { tag.append(" bgcolor=\"" + this.bgcolor + "\""); } if (this.background != null) { if (this.background.startsWith("/")) { this.background = req.getContextPath() + this.background; } else { this.background = req.getContextPath() + "/" + this.background; } tag.append(" background=\"" + this.background + "\""); } if (this.text != null) { tag.append(" text=\"" + this.text + "\""); } if (this.link != null) { tag.append(" link=\"" + this.link + "\""); } if (this.vlink != null) { tag.append(" vlink=\"" + this.vlink + "\""); } if (this.alink != null) { tag.append(" alink=\"" + this.alink + "\""); } tag.append(">" + System.getProperty("line.separator")); StringBuilder func = null; if (onLoadBody != null || onload != null) { func = new StringBuilder(); func.append("<script type=\"text/javascript\">" + System.getProperty("line.separator")); func.append("<!--" + System.getProperty("line.separator")); func.append("function __onLoad__() {" + System.getProperty("line.separator")); if (onload != null) { func.append(" "); func.append(onload); if (!onload.endsWith(";")) { func.append(";"); } func.append(System.getProperty("line.separator")); } if (onLoadBody != null) { func.append(onLoadBody); } func.append("}" + System.getProperty("line.separator")); func.append("//-->" + System.getProperty("line.separator")); func.append("</script>" + System.getProperty("line.separator")); } try { JspWriter out = pageContext.getOut(); out.print(tag.toString()); if (func != null) { out.print(func.toString()); } } catch (IOException e) { log.error("Output failed."); throw new JspTagException(e.toString()); } return EVAL_BODY_INCLUDE; }
From source file:jp.terasoluna.fw.web.struts.taglib.BodyTag.java
/** * ^O]?I?\bh?B//w ww . j av a 2 s .c om * * @return ???w?B? <code>EVAL_PAGE</code> * @throws JspException JSPO */ @Override public int doEndTag() throws JspException { try { JspWriter out = pageContext.getOut(); out.print("</body>"); } catch (IOException e) { log.error("Output failed"); throw new JspTagException(e.toString()); } return EVAL_PAGE; }
From source file:jp.terasoluna.fw.web.taglib.DateFormatterTagBase.java
/** * ^O]Jn?\bh?B/* w w w .j av a 2 s. c om*/ * * @return ???w?B? <code>SKIP_BODY</code> * @throws JspException JSPO */ @Override public int doStartTag() throws JspException { Object value = this.value; if (value == null) { // bean???Av?beanbNAbv // ???A^?[ if (ignore) { if (TagUtil.lookup(pageContext, name, scope) == null) { return SKIP_BODY; // ?o } } // v?v?peBlbNAbv value = TagUtil.lookup(pageContext, name, property, scope); if (value == null) { return SKIP_BODY; // ?o } } // v?peBlString^xDate Date date = null; if (value instanceof String) { // Eg String trimed = StringUtil.rtrim((String) value); // ttH?[}bg String dateFormat = StringUtils.defaultIfEmpty(getFormat(), getDefaultDateFormat()); // xDate^ SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); try { date = sdf.parse(trimed); } catch (ParseException e) { log.error("Date parsing error."); throw new JspTagException(e.getMessage()); } } else if (value instanceof Date) { date = (Date) value; } else { return SKIP_BODY; // ?o } // tH?[}bg String output = doFormat(date); if (id != null) { // idw?AXNveBO?p // y?[WXR?[vZbg?B pageContext.setAttribute(id, output); } else { // idw?Av?peBlC^vg // ?BK?tB^?B if (filter) { TagUtil.write(pageContext, TagUtil.filter(output)); } else { TagUtil.write(pageContext, output); } } return SKIP_BODY; }
From source file:net.ontopia.topicmaps.webed.impl.utils.TagUtils.java
/** * INTERNAL: Creates the field name used by a particular action and registers * the data used by the action in the user session. * // w w w . j av a 2s .c om * @param pageContext the context of the page being rendered * @param action_name the name of the action * @param group_name the name of the action group * @param paramlist the parameters to the action (list of collections) * @param sub_actions the sub-actions of this action, if any * @param value the current value of the form control * @param create_ads_if_not_exists whether to create ActionDataSet * if not found * @return the name of the form field that will trigger the action */ private static String registerData(PageContext pageContext, String action_name, String group_name, List paramlist, List sub_actions, Set value, boolean create_ads_if_not_exists, boolean run_if_no_changes) throws JspTagException { // retrieve action ActionRegistryIF registry = getActionRegistry(pageContext); ActionInGroup action = ActionUtils.getAction(registry, group_name, action_name); if (action == null) throw new JspTagException("Unknown action '" + action_name + "' in group" + " '" + group_name + "', please check configuration."); // compute name String name = action.getName() + getNextCounterId(); // register action with field name ActionData data = new ActionData(action, TagUtils.serializeParameters(paramlist), value, sub_actions, name); data.setRunIfNoChanges(run_if_no_changes); ActionDataSet ads = getActionDataSet(pageContext, create_ads_if_not_exists); ads.addActionData(data); log.info("Attached action data to field " + name); return name; }
From source file:net.ontopia.topicmaps.webed.impl.utils.TagUtils.java
/** * INTERNAL: Creates an ActionData wrapper for the given action and * parameters./*from ww w . j ava 2 s . c om*/ * * @param params A whitespace-separated list of navigator variable names */ public static ActionData makeActionData(PageContext pageContext, String action_name, String group_name, String params) throws JspTagException { ActionRegistryIF registry = getActionRegistry(pageContext); ActionInGroup action = ActionUtils.getAction(registry, group_name, action_name); if (action == null) throw new JspTagException("Unknown action '" + action_name + "' in group" + " '" + group_name + "', please check configuration."); List paramlist = evaluateParameterList(pageContext, params); return new ActionData(action, TagUtils.serializeParameters(paramlist)); }
From source file:jp.terasoluna.fw.web.taglib.WriteTag.java
/** * <p>Jn^O???s?B</p>//w w w. ja va2s. com * * @return int ???w * @exception JspException JSPO??? */ @Override public int doStartTag() throws JspException { //v?bean? if (ignore && TagUtil.lookup(pageContext, name, scope) == null) { return SKIP_BODY; } //v?v?peB? Object value = TagUtil.lookup(pageContext, name, property, scope); if (value == null) { if (replaceNullToNbsp) { TagUtil.write(pageContext, " "); } return SKIP_BODY; } String output = value.toString(); if (output.length() == 0) { if (replaceNullToNbsp) { TagUtil.write(pageContext, " "); return SKIP_BODY; } // ???AreplaceNullToNbspfalse?A // addBR?]<br>t^?A // return?B } //v?peBl\ StringReader sr = null; BufferedReader br = null; try { sr = new StringReader(output); br = new BufferedReader(sr); StringBuilder sbuilder = new StringBuilder(); StringBuilder strBuilder = new StringBuilder(); String tmpLine = null; int sizeMngCount = 1; int index = 0; // List?sR?[h?i[?B List<String> lines = new ArrayList<String>(); while ((tmpLine = br.readLine()) != null) { lines.add(tmpLine); } for (String line : lines) { if (index > 0 && replaceLFtoBR) { // ?sR?[h<br> sbuilder.append("<br>"); // JEgZbg sizeMngCount = 1; } if (!"".equals(line)) { strBuilder.setLength(0); char ch = line.charAt(0); for (int i = 0; i < line.length(); i++, sizeMngCount++) { ch = line.charAt(i); strBuilder.append(ch); // wTCY??A\nt^?B if (fillColumn > 0 && sizeMngCount > 1 && sizeMngCount % fillColumn == 0) { // ?AwTCY?A???A\nt^?B // ?sreplaceLFtoBR == true (f?[^?sR?[h?A<br>) // ??I?s?s (?I[?A?sR?[h?s) if (i == line.length() - 1 && replaceLFtoBR) { // } else if (i == line.length() - 1 && index == lines.size() - 1) { // } else { strBuilder.append("\n"); } } } line = strBuilder.toString(); } if (filter) { // Tj^CY line = TagUtil.filter(line); } // pXy?[X u?A\n<br>u char[] content = line.toCharArray(); StringBuilder result = new StringBuilder(); for (int i = 0; i < content.length; i++) { switch (content[i]) { case ' ': if (replaceSpToNbsp) { result.append(" "); } else { result.append(content[i]); } break; case '\n': result.append("<br>"); break; default: result.append(content[i]); break; } } sbuilder.append(result); ++index; } // v?peBl<br>t^ if (addBR) { sbuilder.append("<br>"); } output = sbuilder.toString(); } catch (IOException e) { log.error("StringReader IO error."); throw new JspTagException(e.getMessage()); } finally { if (sr != null) { sr.close(); } try { if (br != null) { br.close(); } } catch (IOException e1) { if (log.isWarnEnabled()) { log.warn("StringReader close error : " + e1); } } } TagUtil.write(pageContext, output); return SKIP_BODY; }
From source file:jp.terasoluna.fw.web.struts.taglib.PageLinksTag.java
/** * ^O]Jn?\bh?B//from w w w .j a va 2 s. c om * * @return ???w * @throws JspException JSPO */ @Override public int doStartTag() throws JspException { //?`FbN if (!submit && (action == null || "".equals(action))) { log.error(ERROR_MESSAGE_ACTION_REQUIRED); throw new JspException(ERROR_MESSAGE_ACTION_REQUIRED); } // v?peBt@Cy?[WWvpN^O? getLinkProperty(); //\?s? Object objRow = lookup(pageContext, name, rowProperty, scope); int row = getInt(objRow); //\?s?0?????I?B if (row <= 0) { if (log.isWarnEnabled()) { log.warn(WARN_MESSAGE_ILLEGAL_ROW); } return EVAL_BODY_INCLUDE; } //Jn?sCfbNX Object objIndex = lookup(pageContext, name, indexProperty, scope); int startIndex = getInt(objIndex); //S?? Object objTotal = lookup(pageContext, name, totalProperty, scope); int totalCount = getInt(objTotal); //StringBuilder?? StringBuilder sb = new StringBuilder(); //?y?[W??A?y?[W???B attributePageCount(getPageIndex(row, startIndex), getPageCount(row, totalCount)); if (submit) { //submit?true?ATu~bg?sy?[WN?o?B //\?s??AJnCfbNX^O?o defineHtml(row, startIndex, totalCount); //Oy?[WN? addPrevSubmit(sb, row, startIndex, totalCount); //y?[W?N? addDirectSubmit(sb, row, startIndex, totalCount); //y?[WN? addNextSubmit(sb, row, startIndex, totalCount); } else { //submit?false?? //Oy?[WN? addPrevLink(sb, row, startIndex, totalCount); //y?[W?N? addDirectLink(sb, row, startIndex, totalCount); //y?[WN? addNextLink(sb, row, startIndex, totalCount); } //StringBuildere?o?B if (id == null || "".equals(id)) { try { JspWriter writer = pageContext.getOut(); writer.println(sb.toString()); } catch (IOException e) { log.error(e.getMessage()); throw new JspTagException(e.toString()); } } else { pageContext.setAttribute(id, sb.toString()); } return EVAL_BODY_INCLUDE; }
From source file:com.bst.tags.TableTag.java
/** * Will write the export. The default behavior is to write directly to the response. If the ResponseOverrideFilter * is configured for this request, will instead write the exported content to a map in the Request object. * @param exportView export view/*from ww w.j av a 2 s .c om*/ * @throws JspException for problem in clearing the response or for invalid export views * @throws IOException exception thrown when writing content to the response */ protected void writeExport(ExportView exportView) throws IOException, JspException { String filename = properties.getExportFileName(this.currentMediaType); HttpServletResponse response = (HttpServletResponse) this.pageContext.getResponse(); HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest(); Map bean = (Map) request.getAttribute(FILTER_CONTENT_OVERRIDE_BODY); boolean usingFilter = bean != null; String mimeType = exportView.getMimeType(); // original encoding, be sure to add it back after reset() String characterEncoding = response.getCharacterEncoding(); if (usingFilter) { if (!bean.containsKey(TableTagParameters.BEAN_BUFFER)) { // We are running under the export filter, call it log.debug("Exportfilter enabled in unbuffered mode, setting headers"); response.addHeader(TableTagParameters.PARAMETER_EXPORTING, TagConstants.EMPTY_STRING); } else { // We are running under the export filter in buffered mode bean.put(TableTagParameters.BEAN_CONTENTTYPE, mimeType); bean.put(TableTagParameters.BEAN_FILENAME, filename); if (exportView instanceof TextExportView) { StringWriter writer = new StringWriter(); ((TextExportView) exportView).doExport(writer); bean.put(TableTagParameters.BEAN_BODY, writer.toString()); } else if (exportView instanceof BinaryExportView) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); ((BinaryExportView) exportView).doExport(stream); bean.put(TableTagParameters.BEAN_BODY, stream.toByteArray()); } else { throw new JspTagException("Export view " + exportView.getClass().getName() + " must implement TextExportView or BinaryExportView"); } return; } } else { log.debug("Exportfilter NOT enabled"); // response can't be already committed at this time if (response.isCommitted()) { throw new ExportException(getClass()); } try { response.reset(); pageContext.getOut().clearBuffer(); } catch (Exception e) { throw new ExportException(getClass()); } } if (!usingFilter && characterEncoding != null && mimeType.indexOf("charset") == -1) //$NON-NLS-1$ { mimeType += "; charset=" + characterEncoding; //$NON-NLS-1$ } response.setContentType(mimeType); if (StringUtils.isNotEmpty(filename)) { response.setHeader("Content-Disposition", //$NON-NLS-1$ "attachment; filename=\"" + filename + "\""); //$NON-NLS-1$ //$NON-NLS-2$ } if (exportView instanceof TextExportView) { Writer writer; if (usingFilter) { writer = response.getWriter(); } else { writer = pageContext.getOut(); } ((TextExportView) exportView).doExport(writer); } else if (exportView instanceof BinaryExportView) { // dealing with binary content // note that this is not assured to work on any application server if the filter is not enabled. According // to the jsp specs response.getOutputStream() should no be called in jsps. ((BinaryExportView) exportView).doExport(response.getOutputStream()); } else { throw new JspTagException("Export view " + exportView.getClass().getName() + " must implement TextExportView or BinaryExportView"); } log.debug("Export completed"); }
From source file:jp.terasoluna.fw.web.struts.taglib.PageLinksTag.java
/** * HTML`?o?B//from w w w . j ava 2 s . co m * * @param row \?s? * @param startIndex \JnCfbNX * @param totalCount S?? * @throws JspException JSPO */ protected void defineHtml(int row, int startIndex, int totalCount) throws JspException { JspWriter writer = pageContext.getOut(); try { //OHidden^O?o?AtOm?B if (!getPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY + rowProperty)) { //\??Hidden^O writer.println("<input type=\"hidden\" name=\"" + rowProperty + "\" value=\"" + row + "\"/>"); //?otO?B setPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY + rowProperty); } //OHidden^O?o?AtOm?B if (!getPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY + indexProperty)) { //\JnCfbNXHidden^O writer.println( "<input type=\"hidden\" name=\"" + indexProperty + "\" value=\"" + startIndex + "\"/>"); //?otO?B setPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY + indexProperty); } //OHidden^O?o?AtOm?B if (!getPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY + event) && forward) { //\JnCfbNXHidden^O writer.println("<input type=\"hidden\" name=\"" + event + "\" value=\"\"/>"); //?otO?B setPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY + event); } //OHidden^O?o?AtOm?B if (!getPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY + "resetIndex") && resetIndex) { //startIndexHidden^O if (!"startIndex".equals(indexProperty)) { writer.println( "<input type=\"hidden\" name=\"" + "startIndex\" value=\"" + startIndex + "\"/>"); } //endIndexHidden^O int endIndex = startIndex + row - 1; if (endIndex >= totalCount) { writer.println( "<input type=\"hidden\" name=\"" + "endIndex\" value=\"" + (totalCount - 1) + "\"/>"); } else { writer.println("<input type=\"hidden\" name=\"" + "endIndex\" value=\"" + endIndex + "\"/>"); } //?otO?B setPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY + "resetIndex"); } //tH?[ String formName = ActionFormUtil.getActionFormName((HttpServletRequest) pageContext.getRequest()); //Tu~bg?sJavaScript?B //?Ay?[WN^O?L?q??P if (!getPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY)) { writer.println("<script type=\"text/javascript\">"); writer.println("<!--"); writer.println(" function pageLinkSubmit(rowObj, indexObj," + " row, startIndex){"); writer.println(" rowObj.value = row;"); writer.println(" indexObj.value = startIndex;"); //forward?true???Aevent?Hidden^O //p??[^??B if (forward) { writer.print(" document."); writer.print(formName); writer.print("."); writer.print(event); writer.print(".value = \""); writer.print(FORWARD_NAME); writer.println("\";"); } writer.print(" document."); writer.print(formName); writer.println(".submit();"); writer.println(" }"); writer.println("// -->"); writer.println("</script>"); //?otO?B setPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY); } } catch (IOException e) { log.error(e.getMessage()); throw new JspTagException(e.toString()); } }