List of usage examples for javax.servlet.jsp JspWriter write
public void write(int c) throws IOException
From source file:com.geemvc.taglib.form.LabelTagSupport.java
@Override protected void appendTagBody(JspWriter writer) throws JspException { StringWriter bodyWriter = null; try {//from ww w . ja v a 2s. c o m if (jspBody != null && label == null) { bodyWriter = new StringWriter(); jspBody.invoke(bodyWriter); label = bodyWriter.toString(); } if (label == null) { label = messageResolver.resolve(name, requestContext(), true); } if (label != null) writer.write(label); } catch (Throwable t) { throw new JspException(t); } finally { IOUtils.closeQuietly(bodyWriter); } }
From source file:com.geemvc.taglib.GeemvcTagSupport.java
protected void writeTag(JspWriter writer, String tagName, boolean hasTagBody, boolean closeTag) throws JspException { this.tagName = tagName; this.hasTagBody = hasTagBody; try {// w w w . j a v a2s .c o m writer.write(Char.LESS_THAN); writer.write(tagName); appendTagAttributes(writer); writeTagAttributes(writer); if (hasTagBody) { writer.write(Char.GREATER_THAN); appendTagBody(writer); } if (closeTag) writeCloseTag(writer, tagName, hasTagBody); } catch (Throwable t) { throw new JspException(t); } }
From source file:com.geemvc.taglib.GeemvcTagSupport.java
protected void writeTagAttributes(JspWriter writer) throws JspException { Set<Entry<String, Object>> attributes = dynamicAttributes.entrySet(); try {/* www .j av a 2s . c o m*/ for (Entry<String, Object> attr : attributes) { writer.write(Char.SPACE); writer.write(attr.getKey()); writer.write(Char.EQUALS); writer.write(Char.DOUBLE_QUOTE); writer.write(String.valueOf(attr.getValue())); writer.write(Char.DOUBLE_QUOTE); } } catch (Throwable t) { throw new JspException(t); } }
From source file:com.geemvc.taglib.form.LabelTagSupport.java
@Override protected void appendTagAttributes(JspWriter writer) throws JspException { try {/*from ww w.j a v a2 s .c o m*/ String forValue = (String) dynamicAttributes.get("for"); if (forValue == null) { String name = getName(); Object value = getValue(); if (name != null) forValue = toElementId(name, value == null ? null : String.valueOf(value)); } if (!Str.isEmpty(forValue)) { // Id attribute. writer.write(Char.SPACE); writer.write("for"); writer.write(Char.EQUALS); writer.write(Char.DOUBLE_QUOTE); writer.write(forValue); writer.write(Char.DOUBLE_QUOTE); } String classValue = (String) dynamicAttributes.get("class"); if (!Str.isEmpty(classValue)) { writer.write(Char.SPACE); writer.write("class"); writer.write(Char.EQUALS); writer.write(Char.DOUBLE_QUOTE); writer.write(classValue); writer.write(Char.DOUBLE_QUOTE); } } catch (Throwable t) { throw new JspException(t); } }
From source file:com.trenako.web.tags.PagerOptionsTags.java
@Override protected int writeTagContent(JspWriter jspWriter, String contextPath) throws JspException { try {// ww w . j a va 2 s . c om StringBuilder body = new StringBuilder(); body.append("\n<select id=\"items\" name=\"items\">"); for (int val : ITEMS_VALUES) { String label = messageSource.getMessage("pager.option.label", new Object[] { val }, val + " items", null); body.append("\n<option value=\"").append(val).append("\">").append(label).append("</option>"); } body.append("\n</select>"); jspWriter.write(form(div(body.toString()).cssClass("pull-right")).cssClass("well form-inline").build()); } catch (IOException e) { e.printStackTrace(); } return SKIP_BODY; }
From source file:org.jasig.schedassist.web.VisibleScheduleTag.java
/** * Render a single {@link AvailableBlock} with {@link AvailableStatus#BUSY}. * //w w w . j a v a 2s. c o m * @param servletContext * @param writer * @param event * @throws IOException */ protected void renderBusyBlock(final ServletContext servletContext, final JspWriter writer, final AvailableBlock event) throws IOException { SimpleDateFormat idFormat = CommonDateOperations.getDateTimeFormat(); SimpleDateFormat timeFormat = new SimpleDateFormat("h:mm a"); String busyTitle = getMessageSource().getMessage("busy.shortdescription", null, null); writer.write("<li id=\"" + idFormat.format(event.getStartTime()) + "\" class=\"busy\" title=\"" + busyTitle + "\">"); writer.write("<img src=\"" + getSilkIconPrefix(servletContext) + "delete.png\" alt=\"\"/> "); writer.write("<span id=\"" + idFormat.format(event.getStartTime()) + "-text\">"); writer.write(timeFormat.format(event.getStartTime())); writer.write(" - "); writer.write(timeFormat.format(event.getEndTime())); writer.write("</span>"); writer.write("</li>"); }
From source file:org.jasig.schedassist.portlet.VisibleScheduleTag.java
/** * Render a single {@link AvailableBlock} with {@link AvailableStatus#BUSY}. * // ww w . ja v a 2 s .c o m * @param writer * @param event * @throws IOException */ protected void renderBusyBlock(final JspWriter writer, final AvailableBlock event) throws IOException { SimpleDateFormat idFormat = CommonDateOperations.getDateTimeFormat(); SimpleDateFormat timeFormat = new SimpleDateFormat("h:mm a"); String busyTitle = getMessageSource().getMessage("busy.shortdescription", null, null); writer.write("<li id=\"" + idFormat.format(event.getStartTime()) + "\" class=\"busy\" title=\"" + busyTitle + "\">"); writer.write("<img src=\"" + getSilkIconPrefix() + "delete.png\" alt=\"\"/> "); writer.write("<span id=\"" + idFormat.format(event.getStartTime()) + "-text\">"); writer.write(timeFormat.format(event.getStartTime())); writer.write(" - "); writer.write(timeFormat.format(event.getEndTime())); writer.write("</span>"); writer.write("</li>"); }
From source file:dk.netarkivet.harvester.datamodel.H3HeritrixTemplate.java
@Override public void writeTemplate(JspWriter out) throws IOFailure { try {/*from ww w . j a v a 2 s . com*/ out.write(template); } catch (IOException e) { throw new IOFailure("Unable to write to JspWriter", e); } }
From source file:com.rsmart.certification.tool.tag.RsmartListScrollTag.java
/** * Default processing of the start tag returning EVAL_BODY_BUFFERED. * * @return EVAL_BODY_BUFFERED// w w w . ja v a 2 s. c om * @throws javax.servlet.jsp.JspException if an error occurred while processing this tag * @see javax.servlet.jsp.tagext.BodyTag#doStartTag */ protected int doStartTagInternal() throws Exception { JspWriter writer = pageContext.getOut(); try { if (listScroll == null) { listScroll = (ListScroll) pageContext.getRequest().getAttribute("listScroll"); } // don't print page if no items in list if (listScroll.getTotal() == 0) { LOG.debug("nothing in list, nothing to render..."); return EVAL_PAGE; } writer.write("<div "); if (className != null) { writer.write("class=\"" + className + "\""); } writer.write(">"); writer.write("<form name=\"listScrollForm\" >"); String htmlOptions = " "; if (showDropdown) { if (dropdownOptions != null) { String[] vals = dropdownOptions.split(";"); htmlOptions = "\n<select name=\"" + SCROLL_SIZE + "\" onchange=\"window.document.location=\'" + listUrl + "&" + ListScroll.STARTING_INDEX_TAG + "=" + (listScroll.getNextIndex() - listScroll.getPerPage()); htmlOptions += "&" + SCROLL_SIZE + "='+this.options[this.selectedIndex].value\">\n"; if (vals != null && vals.length > 0) { if (listScroll.getPerPage() == -1) { listScroll.setPerPage(getMinIntValue(vals)); } for (String val : vals) { if (val != null && ((val.trim().length()) > 0)) { int value = Integer.parseInt(val.trim()); String displayValue = String.valueOf(value); if (value == Integer.MAX_VALUE) { displayValue = resolveMessage(ALL_KEY); } htmlOptions += "<option value=\"" + value + "\" " + ((String.valueOf(listScroll.getPerPage()) .equalsIgnoreCase(String.valueOf(value))) ? ("selected") : ("")) + ">" + resolveMessage(SHOW_KEY) + " " + displayValue + "</option>\n"; } } htmlOptions += "</select>"; } } } int lastIndex = listScroll.getFirstItem() + listScroll.getPerPage() - 1; writer.write(" "); writer.write( resolveMessage(VIEWING_KEY, new String[] { String.valueOf(listScroll.getFirstItem()), String.valueOf( (lastIndex <= listScroll.getTotal()) ? (lastIndex) : (listScroll.getTotal())), String.valueOf(listScroll.getTotal()), })); writer.write(" "); writer.write("<br>"); writer.write("<input type=\"button\" value=\"" + resolveMessage("listscroll_first") + "\" onclick=\"window.document.location=\'"); writer.write(listUrl + "&" + ListScroll.STARTING_INDEX_TAG + "=0"); writer.write("\'\""); if (listScroll.getPrevIndex() == -1) { writer.write(" disabled=\"disabled\" "); } writer.write(" >"); writer.write("<input type=\"button\" value=\"" + resolveMessage("listscroll_previous") + "\" onclick=\"window.document.location=\'"); writer.write(listUrl + "&" + ListScroll.STARTING_INDEX_TAG + "=" + listScroll.getPrevIndex()); writer.write("\'\""); if (listScroll.getPrevIndex() == -1) { writer.write(" disabled=\"disabled\" "); } writer.write(" >"); writer.write(" "); writer.write(htmlOptions); writer.write(" "); writer.write("<input type=\"button\" value=\"" + resolveMessage("listscroll_next") + "\" onclick=\"window.document.location=\'"); writer.write(listUrl + "&" + ListScroll.STARTING_INDEX_TAG + "=" + listScroll.getNextIndex()); writer.write("\'\""); if (listScroll.getNextIndex() == -1) { writer.write(" disabled=\"disabled\" "); } writer.write(" >"); writer.write("<input type=\"button\" value=\"" + resolveMessage("listscroll_last") + "\" onclick=\"window.document.location=\'"); writer.write(listUrl + "&" + ListScroll.STARTING_INDEX_TAG + "=" + Integer.MAX_VALUE); writer.write("\'\""); if (listScroll.getNextIndex() == -1) { writer.write(" disabled=\"disabled\" "); } writer.write(" >"); writer.write("</form >"); writer.write("</div>"); writer.write("<br />"); // make the begin, end, and total available to the jsp page pageContext.setAttribute("list_scroll_begin_index", listScroll.getFirstItem()); pageContext.setAttribute("list_scroll_end_index", listScroll.getLastItem()); pageContext.setAttribute("list_scroll_total_index", listScroll.getTotal()); pageContext.setAttribute("list_scroll_page_size", listScroll.getPerPage()); } catch (IOException e) { LOG.error("", e); throw new JspException(e); } return EVAL_PAGE; }
From source file:org.jasig.schedassist.web.VisibleScheduleTag.java
/** * Render a single week./*from w w w . j a v a 2 s .co m*/ * * @param servletContext * @param writer * @param weekNumber * @param dailySchedules * @param scheduleBlockMap * @throws IOException */ protected void renderWeek(final ServletContext servletContext, final JspWriter writer, final int weekNumber, final SortedMap<Date, List<AvailableBlock>> dailySchedules, final SortedMap<AvailableBlock, AvailableStatus> scheduleBlockMap) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("begin renderWeek for " + weekNumber); } final boolean hasBlocks = doesWeekHaveBlocks(dailySchedules); if (hasBlocks) { final SimpleDateFormat headFormat = new SimpleDateFormat("EEE M/d"); writer.write("<div class=\"weekcontainer\" id=\"week" + weekNumber + "\">"); for (Map.Entry<Date, List<AvailableBlock>> entry : dailySchedules.entrySet()) { final Date day = entry.getKey(); final List<AvailableBlock> daySchedule = entry.getValue(); if (LOG.isDebugEnabled()) { LOG.debug("in renderWeek weeknumber: " + weekNumber + ", day: " + day); } if (daySchedule.size() > 0) { writer.write("<div class=\"weekday\">"); writer.write("<ul class=\"scheduleblocks\">"); writer.write("<li class=\"dayhead\">"); writer.write(headFormat.format(day)); writer.write("</li>"); for (AvailableBlock event : daySchedule) { AvailableStatus eventStatus = scheduleBlockMap.get(event); if (AvailableStatus.BUSY.equals(eventStatus)) { renderBusyBlock(servletContext, writer, event); } else if (AvailableStatus.FREE.equals(eventStatus)) { renderFreeBlock(servletContext, writer, event); } else if (AvailableStatus.ATTENDING.equals(eventStatus)) { renderAttendingBlock(servletContext, writer, event); } } writer.write("</ul>"); writer.write("</div> <!-- end weekday -->"); } } writer.write("</div> <!-- end weekcontainer -->"); } else { if (LOG.isDebugEnabled()) { LOG.debug("renderWeek has no blocks for weekNumber: " + weekNumber); } } }