List of usage examples for javax.servlet.jsp JspWriter print
abstract public void print(Object obj) throws IOException;
From source file:gov.nih.nci.ncicb.cadsr.common.jsp.tag.handler.AvailableValidValue.java
public int doStartTag() throws javax.servlet.jsp.JspException { HttpServletRequest req;//from w w w . j a v a2 s.c o m JspWriter out; try { req = (HttpServletRequest) pageContext.getRequest(); out = pageContext.getOut(); pageContext.setAttribute(AVAILABLE_VALID_VALUE_PRESENT, null); Question currQuestion = (Question) pageContext.getAttribute(questionBeanId); Map availableVVMap = (Map) pageContext.getSession().getAttribute(availableValidValusMapId); List questionVVList = currQuestion.getValidValues(); String questionIdSeq = currQuestion.getQuesIdseq(); List availableVVs = (List) availableVVMap.get(questionIdSeq); List nonListedVVs = (List) pageContext.getAttribute(questionIdSeq + "NotListedValidValues"); if (nonListedVVs == null && (availableVVs != null && !availableVVs.isEmpty())) { nonListedVVs = getNotListedValidValues(currQuestion.getValidValues(), availableVVs); pageContext.setAttribute(questionIdSeq + "NotListedValidValues", nonListedVVs); } if (availableVVs != null && !availableVVs.isEmpty()) { //List nonListedVVs = getNotListedValidValues(currQuestion.getValidValues(),availableVVs); if (!nonListedVVs.isEmpty()) { String html = generateHtml(nonListedVVs, availableVVs, questionIdSeq); out.print(html); pageContext.setAttribute(AVAILABLE_VALID_VALUE_PRESENT, "Yes"); } else { out.print(" "); pageContext.removeAttribute(AVAILABLE_VALID_VALUE_PRESENT); } } else { pageContext.removeAttribute(AVAILABLE_VALID_VALUE_PRESENT); out.print(" "); } } catch (Exception ioe) { throw new JspException("I/O Error : " + ioe.getMessage()); } //end try/catch return Tag.SKIP_BODY; }
From source file:org.jahia.taglibs.internal.uicomponents.DisplayLanguageCodeTag.java
public int doStartTag() { // Produce the HTML code try {//w w w.ja va2 s . c o m JspWriter out = pageContext.getOut(); StringBuilder str = new StringBuilder(); if (debug) { str.append("\n<!-- ======================================================================= -->\n"); str.append("<!-- The following HTML code is generated by 'DisplayLanguageCodeTag' taglib -->\n"); str.append("<!----------------------------------------------------------------------------->\n"); } if (!"".equals(_href)) { str.append("<a "); if (!"".equals(_style)) { str.append("class=\""); str.append(_style); str.append("\" "); } str.append("href=\""); str.append(_href); str.append("\">"); } Locale localeLangToDisplay = LanguageCodeConverters.languageCodeToLocale(_code); str.append(StringEscapeUtils.escapeHtml(localeLangToDisplay.getDisplayLanguage(localeLangToDisplay))); if (!"".equals(_href)) { str.append("</a>"); } if (debug) { str.append("\n<!-- ======================================================================= -->\n"); } out.print(str.toString()); } catch (IOException ioe) { logger.debug(ioe.toString()); } return SKIP_BODY; }
From source file:com.redhat.rhn.frontend.taglibs.ListDisplayTag.java
/** {@inheritDoc} */ @Override/*ww w . j ava2 s . c om*/ public int doStartTag() throws JspException { rowCnt = 0; numItemsChecked = 0; JspWriter out = null; showSetButtons = false; try { out = pageContext.getOut(); setupPageList(); // Now that we have setup the proper tag state we // need to return if this is an export render. if (isExport()) { return SKIP_PAGE; } String sortedColumn = getSortedColumn(); if (sortedColumn != null) { doSort(sortedColumn); } out.print("<div class=\"spacewalk-list "); out.println(type + "\""); if (tableId != null) { out.print(" id=\"" + tableId + "\""); } out.println(">"); /* * If pageList contains an index and pageList.size() (what we are * displaying on the page) is less than pageList.getTotalSize() (the * total number of items in the data result), render alphabar. This * prevents the alphabar from showing up on pages that show all of * the entries on a single page and is similar to how the perl code * behaves. */ StringWriter alphaBarContent = new StringWriter(); StringWriter paginationContent = new StringWriter(); pageContext.pushBody(alphaBarContent); if (getPageList().getIndex().size() > 0 && getPageList().size() < getPageList().getTotalSize()) { //renderViewAllLink(alphaBarContent); renderAlphabar(alphaBarContent); } pageContext.popBody(); pageContext.pushBody(paginationContent); if (isPaging()) { renderPagination(paginationContent, true); renderBoundsVariables(paginationContent); } pageContext.popBody(); int topAddonsContentLen = alphaBarContent.getBuffer().length() + paginationContent.getBuffer().length(); if (topAddonsContentLen > 0) { out.println("<div class=\"spacewalk-list-top-addons\">"); out.println("<div class=\"spacewalk-list-alphabar\">"); out.print(alphaBarContent.getBuffer().toString()); out.println("</div>"); out.print(paginationContent.getBuffer().toString()); out.println("</div>"); } out.print("<div class=\"panel panel-default\">"); renderPanelHeading(out); out.print("<table class=\"table table-striped\">"); // we render the pagination controls as an additional head out.println("<thead>"); out.println("\n<tr>"); if (getIterator() != null && getIterator().hasNext()) { // Push a new BodyContent writer onto the stack so that // we can buffer the body data. bodyContent = pageContext.pushBody(); return EVAL_BODY_INCLUDE; } return SKIP_BODY; } catch (IOException ioe) { throw new JspException("IO error writing to JSP file:", ioe); } }
From source file:com.redhat.rhn.frontend.taglibs.ColumnTag.java
/** * Renders the header element of the table. * @param out JspWriter to write to./*from w w w.ja v a2s. c om*/ * @param hdr Header to display. * @param arg Single argument for header l10n. * @throws IOException */ private void renderHeader(JspWriter out, String hdr, String arg) throws IOException { HtmlTag th = new HtmlTag("th"); if (usesRefactoredList) { if (!StringUtils.isEmpty(findUnpagedListDisplay().getTitle())) { setupAttribute(th, "class", "row-2"); } if (headerStyle != null) { setupAttribute(th, "style", headerStyle); } else { setupAttribute(th, "style", getStyle()); } } else { if (!StringUtils.isEmpty(findListDisplay().getTitle())) { setupAttribute(th, "class", "row-2"); if (headerStyle != null) { setupAttribute(th, "style", headerStyle); } else { setupAttribute(th, "style", getStyle()); } } } th.addBody(renderHeaderData(hdr, arg)); out.print(th.render()); }
From source file:jp.terasoluna.fw.web.taglib.WriteCodeCountTag.java
/** * ^O]Jn?\bh?B//from www . j a v a 2s .c o m * * <p> * T?[ubgReLXgR?[hXg??[_?[ * ??AR?[hXg???AR?[hXgvf? * p?B * R?[hXg???A0???B * </p> * * @return ???w?B? <code>EVAL_BODY_INCLUDE</code> * @throws JspException <code>JSP</code>O */ @Override public int doStartTag() throws JspException { if (log.isDebugEnabled()) { log.debug("doStartTag() called."); } JspWriter out = pageContext.getOut(); try { if ("".equals(id)) { // id??? log.error("id is required."); throw new JspTagException("id is required."); } // pageContext?AApplicationContext?B ServletContext sc = pageContext.getServletContext(); ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(sc); CodeListLoader loader = null; try { loader = (CodeListLoader) context.getBean(id); } catch (ClassCastException e) { //BeanCodeListLoaderOX??[ String errorMessage = "bean id:" + id + " is not instance of CodeListLoader."; log.error(errorMessage); throw new JspTagException(errorMessage, e); } // ?P?[ Locale locale = RequestUtils.getUserLocale((HttpServletRequest) pageContext.getRequest(), Globals.LOCALE_KEY); CodeBean[] codeBeanList = loader.getCodeBeans(locale); if (codeBeanList == null) { // codeBeanListnull??0?o?B if (log.isWarnEnabled()) { log.warn("Codebean is null. CodeListLoader(bean id:" + id + ")"); } out.print(0); } else { // ????R?[hXg?o?B out.print(codeBeanList.length); } return EVAL_BODY_INCLUDE; } catch (IOException ioe) { log.error("IOException caused."); throw new JspTagException(ioe.toString()); } }
From source file:org.opencms.workplace.CmsWidgetDialog.java
/** * Writes the dialog html code, only if the <code>{@link #ACTION_DEFAULT}</code> is set.<p> * /*from www . j a v a 2s . c o m*/ * @throws JspException if dialog actions fail * @throws IOException if writing to the JSP out fails, or in case of errors forwarding to the required result page */ public void writeDialog() throws IOException, JspException { if (isForwarded()) { return; } switch (getAction()) { case ACTION_CANCEL: case ACTION_ERROR: case ACTION_SAVE: break; case ACTION_DEFAULT: default: // ACTION: show dialog (default) setParamAction(DIALOG_SAVE); JspWriter out = getJsp().getJspContext().getOut(); out.print(defaultActionHtml()); } }
From source file:org.dspace.app.webui.jsptag.ItemTag.java
/** * Link to the item licence/* ww w .j a va2s . com*/ */ private void showLicence() throws IOException { JspWriter out = pageContext.getOut(); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); Bundle[] bundles = null; try { bundles = item.getBundles("LICENSE"); } catch (SQLException sqle) { throw new IOException(sqle.getMessage(), sqle); } out.println("<table align=\"center\" class=\"attentionTable\"><tr>"); out.println("<td class=\"attentionCell\"><p><strong>" + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.itemprotected") + "</strong></p>"); for (int i = 0; i < bundles.length; i++) { Bitstream[] bitstreams = bundles[i].getBitstreams(); for (int k = 0; k < bitstreams.length; k++) { out.print("<div align=\"center\" class=\"standard\">"); out.print("<strong><a target=\"_blank\" href=\""); out.print(request.getContextPath()); out.print("/retrieve/"); out.print(bitstreams[k].getID() + "/"); out.print(UIUtil.encodeBitstreamName(bitstreams[k].getName(), Constants.DEFAULT_ENCODING)); out.print("\">" + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.viewlicence") + "</a></strong></div>"); } } out.println("</td></tr></table>"); }
From source file:edu.cornell.mannlib.vedit.tags.DynamicFieldsTag.java
public int doEndTag() throws JspException { try {/* w w w . j ava2s . c om*/ parseMarkup(); JspWriter out = pageContext.getOut(); HashMap values = null; try { FormObject foo = getFormObject(); List<DynamicField> dynfs = foo.getDynamicFields(); Iterator<DynamicField> dynIt = dynfs.iterator(); int i = 9899; while (dynIt.hasNext()) { DynamicField dynf = dynIt.next(); StringBuffer genTaName = new StringBuffer().append("_").append(dynf.getTable()).append("_"); genTaName.append("-1").append("_"); Iterator pparamIt = dynf.getRowTemplate().getParameterMap().keySet().iterator(); while (pparamIt.hasNext()) { String key = (String) pparamIt.next(); String value = (String) dynf.getRowTemplate().getParameterMap().get(key); byte[] valueInBase64 = Base64.encodeBase64(value.getBytes()); genTaName.append(key).append(":").append(new String(valueInBase64)).append(";"); } String preWithVars = new String(preMarkup); preWithVars = strReplace(preWithVars, type + "NN", Integer.toString(i)); preWithVars = strReplace(preWithVars, "\\$genTaName", genTaName.toString()); preWithVars = strReplace(preWithVars, "\\$fieldName", dynf.getName()); out.print(preWithVars); Iterator<DynamicFieldRow> rowIt = dynf.getRowList().iterator(); while (rowIt.hasNext()) { ++i; DynamicFieldRow row = rowIt.next(); if (row.getValue() == null) row.setValue(""); if (row.getValue().length() > 0) { StringBuffer taName = new StringBuffer().append("_").append(dynf.getTable()) .append("_"); taName.append(row.getId()).append("_"); Iterator paramIt = row.getParameterMap().keySet().iterator(); while (paramIt.hasNext()) { String key = (String) paramIt.next(); String value = (String) row.getParameterMap().get(key); byte[] valueInBase64 = Base64.encodeBase64(value.getBytes()); taName.append(key).append(":").append(new String(valueInBase64)).append(";"); } if (row.getValue().length() > 0) { String templateWithVars = new String(templateMarkup); templateWithVars = strReplace(templateWithVars, type + "NN", Integer.toString(i)); templateWithVars = strReplace(templateWithVars, "\\$taName", taName.toString()); templateWithVars = strReplace(templateWithVars, "\\$\\$", row.getValue()); out.print(templateWithVars); } } } out.print(postMarkup); } // output the row template for the javascript to clone out.println("<!-- row template inserted by DynamicFieldsTag -->"); String hiddenTemplatePreMarkup = new String(preMarkup); // bit of a hack to hide the template from the user: hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup, "display\\:none\\;", ""); hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup, "display\\:block\\;", ""); hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup, "display\\:inline\\;", ""); hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup, "style\\=\\\"", "style=\"display:none;"); out.print(hiddenTemplatePreMarkup); String hiddenTemplateTemplateMarkup = new String(templateMarkup); hiddenTemplateTemplateMarkup = strReplace(hiddenTemplateTemplateMarkup, "\\$\\$", ""); out.print(hiddenTemplateTemplateMarkup); out.print(postMarkup); } catch (Exception e) { System.out.println("DynamicFieldsTag could not get the form object"); } } catch (Exception ex) { throw new JspException(ex.getMessage()); } return SKIP_BODY; }
From source file:no.kantega.publishing.admin.content.InputScreenRenderer.java
/** * Lager inputskjermbilde ved g gjennom alle attributter *///from w ww . ja va2 s .c o m public void generateInputScreen() throws IOException, SystemException, ServletException { JspWriter out = pageContext.getOut(); ServletRequest request = pageContext.getRequest(); Map<String, List<ValidationError>> fieldErrors = new HashMap<>(); ValidationErrors errors = (ValidationErrors) request.getAttribute("errors"); if (errors != null) { for (ValidationError error : errors.getErrors()) { if (error.getField() != null && error.getField().length() > 0) { List<ValidationError> errorsForField = fieldErrors.get(error.getField()); if (errorsForField == null) { errorsForField = new ArrayList<>(); fieldErrors.put(error.getField(), errorsForField); } errorsForField.add(error); } } } ContentTemplate template = null; if (attributeType == AttributeDataType.CONTENT_DATA) { template = contentTemplateAO.getTemplateById(content.getContentTemplateId(), true); } else if (attributeType == AttributeDataType.META_DATA && content.getMetaDataTemplateId() > 0) { template = MetadataTemplateCache.getTemplateById(content.getContentTemplateId(), true); } String globalHelpText = null; if (template != null) { globalHelpText = template.getHelptext(); } if (globalHelpText != null && globalHelpText.length() > 0) { out.print( "<div id=\"TemplateGlobalHelpText\" class=\"ui-state-highlight\">" + globalHelpText + "</div>"); } request.setAttribute("content", content); int tabIndex = 100; // Tab index for attribute List<Attribute> attributes = content.getAttributes(attributeType); for (Attribute attribute : attributes) { tabIndex = renderAttribute(out, request, fieldErrors, attribute, tabIndex); } request.setAttribute("maxTabindex", Math.max(tabIndex, 500)); }
From source file:gov.nih.nci.ncicb.cadsr.common.jsp.tag.handler.SecureIconDisplay.java
public int doStartTag() throws javax.servlet.jsp.JspException { HttpServletRequest req;//from w w w . j av a 2s . com JspWriter out; try { Form form = null; if (formScope.equals(CaDSRConstants.SESSION_SCOPE)) { form = (Form) pageContext.getSession().getAttribute(formId); } else if (formScope.equals(CaDSRConstants.PAGE_SCOPE)) { form = (Form) pageContext.getAttribute(formId); } if (form == null) throw new JspException("Secure icon: no form object in any scope "); Context userContext = form.getContext(); NCIUser nciUser = (NCIUser) pageContext.getSession().getAttribute(USER_KEY); req = (HttpServletRequest) pageContext.getRequest(); out = pageContext.getOut(); //// GF29128 D.An, 20130729. String un = (String) req.getSession().getAttribute("myUsername"); if (un == null) un = "viewer"; ////System.out.println( request.getSession().getAttribute("myUsername") ); String targetStr = ""; if (target != null) targetStr = "target=\"" + target + "\" "; if (hasPrivilege(role, formType, nciUser, form) //// GF29128 D.An, 20130729. && !un.equals("viewer")) { String hrefVal = null; if (confirmMessageKey != null) hrefVal = getConfirmMethod(getHrefUrl(req, form)); else hrefVal = getHrefUrl(req, form); out.print("<a href=\"" + hrefVal + "\" " + targetStr + "/><img src=\"" + urlPrefix + activeImageSource + "\" border=0 alt='" + altMessage + "'></a>"); } else { if (inactiveImageSource != null) out.print("<img src=\"" + urlPrefix + inactiveImageSource + "\"border=0>"); } } catch (IOException ioe) { throw new JspException("I/O Error : " + ioe.getMessage()); } //end try/catch return Tag.SKIP_BODY; }