List of usage examples for javax.servlet.jsp JspWriter write
public void write(int c) throws IOException
From source file:com.ultrapower.eoms.common.plugin.ecside.tag.MappingTag.java
@Override public int doStartTag() throws JspException { try {/* w ww . j ava2s . c o m*/ Object propertyValue = getValue(); if (propertyValue != null) { propertyValue = ExpressionEvaluatorManager.evaluate("result", propertyValue.toString(), Object.class, this, pageContext); } if (mappingItem!=null ){ Object mappingMap=pageContext.findAttribute((String)mappingItem); Object outValue=null; if (mappingMap instanceof Map){ Map itemsMap=(Map)mappingMap; outValue=itemsMap.get(propertyValue); if (outValue==null && mappingDefaultKey!=null){ outValue=itemsMap.get(mappingDefaultKey); } } if (outValue==null){ outValue=mappingDefaultValue; } propertyValue=outValue; } JspWriter w = pageContext.getOut(); if (propertyValue == null || (propertyValue != null && propertyValue instanceof String && StringUtils.isBlank((String)propertyValue))) { w.write(""); }else{ w.write((String)propertyValue); } } catch (Exception e) { throw new JspException("MappingTag.doStartTag() Problem: " + ExceptionUtils.formatStackTrace(e)); } return SKIP_BODY; }
From source file:com.googlecode.jtiger.modules.ecside.tag.MappingTag.java
public int doStartTag() throws JspException { try {// ww w .j av a 2 s .com Object propertyValue = getValue(); if (propertyValue != null) { propertyValue = ExpressionEvaluatorManager.evaluate("result", propertyValue.toString(), Object.class, this, pageContext); } if (mappingItem != null) { Object mappingMap = pageContext.findAttribute((String) mappingItem); Object outValue = null; if (mappingMap instanceof Map) { Map itemsMap = (Map) mappingMap; outValue = itemsMap.get(propertyValue); if (outValue == null && mappingDefaultKey != null) { outValue = itemsMap.get(mappingDefaultKey); } } if (outValue == null) { outValue = mappingDefaultValue; } propertyValue = outValue; } JspWriter w = pageContext.getOut(); if (propertyValue == null || (propertyValue != null && propertyValue instanceof String && StringUtils.isBlank((String) propertyValue))) { w.write(""); } else { w.write((String) propertyValue); } } catch (Exception e) { throw new JspException("MappingTag.doStartTag() Problem: " + ExceptionUtils.formatStackTrace(e)); } return SKIP_BODY; }
From source file:com.capgemini.b2bassets.storefront.renderer.CMSLinkComponentRenderer.java
@Override public void renderComponent(final PageContext pageContext, final CMSLinkComponentModel component) throws ServletException, IOException { try {//from w w w . j a va 2s . co m final String url = getUrl(component); final String encodedUrl = UrlSupport.resolveUrl(url, null, pageContext); final JspWriter out = pageContext.getOut(); if (StringUtils.isNotBlank(component.getLinkName()) && StringUtils.isBlank(encodedUrl)) { // <span class="empty-nav-item">${component.linkName}</span> out.write("<span class=\"empty-nav-item\">"); out.write(component.getLinkName()); out.write("</span>"); } else { // <a href="${encodedUrl}" ${component.styleAttributes} title="${component.linkName}" // ${component.target == null || component.target == 'SAMEWINDOW' ? '' : 'target="_blank"'}>${component.linkName}</a> out.write("<a href=\""); out.write(encodedUrl); out.write("\" "); // Write additional attributes onto the link if (component.getStyleAttributes() != null) { out.write(component.getStyleAttributes()); } if (StringUtils.isNotBlank(component.getLinkName())) { out.write(" title=\""); out.write(component.getLinkName()); out.write("\" "); } if (component.getTarget() != null && !LinkTargets.SAMEWINDOW.equals(component.getTarget())) { out.write(" target=\"_blank\""); } out.write(">"); if (StringUtils.isNotBlank(component.getLinkName())) { out.write(component.getLinkName()); } out.write("</a>"); } } catch (final JspException e) { if (LOG.isDebugEnabled()) { LOG.debug(e); } } }
From source file:com.redhat.rhn.frontend.taglibs.RequiredFieldTag.java
/** * {@inheritDoc}// w w w .ja va2 s. co m */ @Override public int doStartTag() throws JspException { // <bean:message key="cobbler.snippet.name"/> // <span class="required-form-field">*</span> LocalizationService ls = LocalizationService.getInstance(); JspWriter writer = pageContext.getOut(); try { if (!StringUtils.isBlank(key)) { String msg = ls.getMessage(key); if (msg.endsWith(":")) { msg = msg.substring(0, msg.length() - 1); } writer.write(msg); } return EVAL_BODY_INCLUDE; } catch (IOException e) { throw new JspException(e); } }
From source file:info.magnolia.cms.taglibs.util.ImgTag.java
/** * @param out/*from w w w. ja v a2 s . c o m*/ * @throws IOException */ private void writeAttributes(JspWriter out, Map attributes) throws IOException { for (Iterator iter = attributes.keySet().iterator(); iter.hasNext();) { String name = (String) iter.next(); String value = (String) attributes.get(name); out.write(name); out.write("=\""); out.write(value); out.write("\" "); } }
From source file:com.siberhus.web.ckeditor.tags.OfmBaseUrlTagHandler.java
@Override public void doTag() throws JspException, IOException { HttpServletRequest request = (HttpServletRequest) getPageContext().getRequest(); String bUrl = PathUtils.getBaseUrl(request, space, type); JspWriter writer = getJspContext().getOut(); CkeditorConfig config = CkeditorConfigurationHolder.config(); String userDefinedBaseUrl = config.upload().baseurl(request); if (StringUtils.isNotBlank(userDefinedBaseUrl)) { bUrl = PathUtils.checkSlashes(userDefinedBaseUrl, "L- R+", true) + PathUtils.checkSlashes(bUrl, "R-", true); writer.write(bUrl); } else {/*from www . jav a2 s. c om*/ bUrl = PathUtils.checkSlashes(bUrl, "R-", false); writer.write(getPageContext().getServletContext().getContextPath() + "/" + bUrl); } }
From source file:com.trenako.web.tags.CategoriesListTags.java
@Override protected int writeTagContent(JspWriter jspWriter, String contextPath) throws JspException { Assert.notNull(getBrand(), "Brand is required"); this.contextPath = contextPath; try {/*from w w w.j a v a 2 s.c om*/ if (getBrand().getScales() == null || getBrand().getScales().size() == 0) { jspWriter.write(snippet(div().cssClass("row-fluid")).build()); return SKIP_BODY; } List<HtmlTag> rows = new ArrayList<HtmlTag>(); int numOfScales = getBrand().getScales().size(); int numOfRows = (int) Math.ceil(numOfScales / (double) getColumns()); String[] scales = (String[]) getBrand().getScales().toArray(new String[numOfScales]); for (int row = 0; row < numOfRows; row++) { HtmlTag[] cols = new HtmlTag[getColumns()]; for (int col = 0; col < getColumns(); col++) { int n = col + (getColumns() * row); if (scales.length > n) { String slug = scales[n]; Scale scale = service.findBySlug(slug); if (scale == null) { continue; } cols[col] = div(buildScale(scale)).cssClass(spanClass()); } // pad the rows with empty columns else { cols[col] = div().cssClass(spanClass()); } } rows.add(div(cols).cssClass("row-fluid")); } jspWriter.write(snippet(tags(rows)).build()); } catch (IOException e) { e.printStackTrace(); } return SKIP_BODY; }
From source file:info.magnolia.cms.taglibs.util.TableTag.java
/** * @param out//w w w.j a v a 2s .c o m * @throws IOException */ private void writeAttributes(JspWriter out, Map attributes) throws IOException { for (Iterator iter = attributes.keySet().iterator(); iter.hasNext();) { String name = (String) iter.next(); String value = (String) attributes.get(name); if (StringUtils.isNotBlank(value)) { out.write(name); out.write("=\""); out.write(value); out.write("\" "); } } }
From source file:org.springmodules.validation.bean.annotation.javascript.taglib.BeanAnnotationValidateTag.java
public int doEndTag() throws JspException { if (cotvc == null) { findConverter();/*from w w w . ja v a 2s .c o m*/ } try { if (commandObj == null) { // favour commandObj over command name commandObj = this.pageContext.getAttribute(commandName, PageContext.REQUEST_SCOPE); if (commandName == null || commandObj == null) { logger.error("Command object not found"); return EVAL_PAGE; } } JspWriter out = pageContext.getOut(); Locale locale = getRequestContext().getLocale(); WebApplicationContext webApplicationContext = getRequestContext().getWebApplicationContext(); MessageSourceAccessor messages = new MessageSourceAccessor(webApplicationContext, locale); out.write("<script type=\"text/javascript\" id=\"" + commandName + "ValangValidator\">\n"); cotvc.writeJS(commandName, commandObj, globalVar, validateOnSubmit, out, messages); out.write("\n</script>"); return EVAL_PAGE; } catch (IOException e) { throw new JspException("Could not write validation rules", e); } }
From source file:com.geemvc.taglib.GeemvcTagSupport.java
protected void writeCloseTag(JspWriter writer, String tagName, boolean hasTagBody) throws JspException { try {//from w ww.j a va 2s . c om if (hasTagBody) { writer.write(Char.LESS_THAN); writer.write(Char.SLASH); writer.write(tagName); writer.write(Char.GREATER_THAN); } else { writer.write(Char.SPACE); writer.write(Char.SLASH); writer.write(Char.GREATER_THAN); } } catch (Throwable t) { throw new JspException(t); } }