List of usage examples for javax.servlet.jsp JspWriter println
abstract public void println(Object x) throws IOException;
From source file:org.broadleafcommerce.core.web.catalog.taglib.SearchFilterItemTag.java
private void doCategoryMultiSelect(JspWriter out, List<Category> categories) throws JspException, IOException { String propertyCss = property.replaceAll("[\\.\\[\\]]", "_"); out.println("<ul class='searchFilter-" + propertyCss + "'>"); for (Category category : categories) { String catUrl = getUrl(category); out.println("<li vaue='" + category.getName() + "'>" + catUrl); }/* ww w. j a v a2 s .c om*/ out.println("</ul>"); }
From source file:org.kuali.mobility.tags.LocalisedFieldTag.java
@Override public void doTag() throws JspException, IOException { PageContext pageContext = (PageContext) getJspContext(); ServletContext servletContext = pageContext.getServletContext(); WebApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(servletContext); final List<String> languages = (List) ac.getBean("supportedLanguages"); this.messageSource = (MessageSource) ac.getBean("messageSource"); final LocaleResolver localeResolver = (LocaleResolver) ac.getBean("localeResolver"); final Locale currentLocale = localeResolver.resolveLocale((HttpServletRequest) pageContext.getRequest()); final JspWriter out = pageContext.getOut(); final String label = getMessage(labelCode, currentLocale); out.println("<div data-role=\"l10nBox\" data-l10n-field=\"" + name + "\">"); out.println("<label>" + label + ": </label>"); this.writeHiddenInputCode(out); this.writeLanguageOptions(out, languages); this.writeLanguageInputs(out, languages); out.println("</div>"); super.doTag(); }
From source file:org.openmrs.web.taglib.ActiveListWidget.java
public int doStartTag() { UserContext userContext = Context.getUserContext(); Locale loc = userContext.getLocale(); DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, loc); Set<Concept> addConceptList = OpenmrsUtil.conceptSetHelper(addConcept); Set<Concept> removeConceptList = OpenmrsUtil.conceptSetHelper(removeConcept); List<Concept> otherConceptList = OpenmrsUtil.conceptListHelper(otherGroupedConcepts); boolean doObsGroups = otherConceptList.size() > 0; if (onDate == null) onDate = new Date(); // maps Concept to the date that became active Map<Concept, Obs> activeList = new HashMap<Concept, Obs>(); for (Obs o : observations) { // skip observations in the future if (OpenmrsUtil.compare(o.getObsDatetime(), onDate) > 0) continue; Concept c = o.getConcept();/*from ww w .j a v a2s . co m*/ Concept toDo = o.getValueCoded(); if (toDo == null) toDo = c; if (addConceptList.contains(o.getConcept())) { Date newActiveDate = o.getObsDatetime(); Obs tmp = activeList.get(c); Date currentActiveDate = tmp == null ? null : tmp.getObsDatetime(); if (currentActiveDate == null || newActiveDate.compareTo(currentActiveDate) < 0) activeList.put(toDo, o); } else if (removeConceptList.contains(o.getConcept())) { activeList.remove(toDo); } } List<Map.Entry<Concept, Obs>> ordered = new ArrayList<Map.Entry<Concept, Obs>>(activeList.entrySet()); Collections.sort(ordered, new Comparator<Map.Entry<Concept, Obs>>() { public int compare(Map.Entry<Concept, Obs> left, Map.Entry<Concept, Obs> right) { return left.getValue().getObsDatetime().compareTo(right.getValue().getObsDatetime()); } }); Map<Obs, Collection<Obs>> obsGroups = new HashMap<Obs, Collection<Obs>>(); if (doObsGroups) { ObsService os = Context.getObsService(); for (Obs o : activeList.values()) if (o.isObsGrouping()) obsGroups.put(o, o.getGroupMembers()); } StringBuilder sb = new StringBuilder(); String before = ""; String after = ""; String obsGroupHeader = ""; String beforeItem = ""; String afterItem = ""; String obsGroupItemSeparator = ""; if ("ol".equals(displayStyle) || "ul".equals(displayStyle)) { before = "<" + displayStyle + ">"; after = "</" + displayStyle + ">"; beforeItem = "<li>"; afterItem = "</li>"; obsGroupItemSeparator = ", "; } else if (displayStyle.startsWith("separator:")) { afterItem = displayStyle.substring(displayStyle.indexOf(":") + 1); obsGroupItemSeparator = " "; } else if ("table".equals(displayStyle)) { before = "<table>"; after = "</table>"; beforeItem = "<tr><td>"; afterItem = "</td></tr>"; obsGroupItemSeparator = "</td><td>"; if (doObsGroups) { StringBuilder s = new StringBuilder(); s.append("<tr><th></th>"); for (Concept c : otherConceptList) { ConceptName cn = c.getBestShortName(loc); s.append("<th><small>" + cn.getName() + "</small></th>"); } s.append("</tr>"); obsGroupHeader = s.toString(); } } else { throw new RuntimeException("Unknown displayStyle: " + displayStyle); } if (ordered.size() > 0) { sb.append(before); sb.append(obsGroupHeader); for (Map.Entry<Concept, Obs> e : ordered) { sb.append(beforeItem); sb.append(e.getKey().getName(loc, false).getName()); if (showDate) sb.append(" ").append(df.format(e.getValue().getObsDatetime())); if (doObsGroups) { Collection<Obs> obsGroup = obsGroups.get(e.getValue()); for (Concept c : otherConceptList) { sb.append(obsGroupItemSeparator); if (obsGroup != null) { for (Obs o : obsGroup) { if (c.equals(o.getConcept())) { sb.append(o.getValueAsString(loc)); break; } } } } } sb.append(afterItem); } sb.append(after); } try { JspWriter w = pageContext.getOut(); w.println(sb); } catch (IOException ex) { log.error("Error while writing to JSP", ex); } return SKIP_BODY; }
From source file:info.magnolia.cms.taglibs.util.SearchResultSnippetTag.java
/** * @see javax.servlet.jsp.tagext.TagSupport#doStartTag() *//*w ww . j a v a 2 s . co m*/ public int doStartTag() throws JspException { JspWriter out = this.pageContext.getOut(); try { Iterator iterator = getSnippets().iterator(); while (iterator.hasNext()) { out.println(iterator.next()); } } catch (IOException e) { // should never happen throw new NestableRuntimeException(e); } return EVAL_PAGE; }
From source file:dk.netarkivet.archive.webinterface.BatchGUI.java
/** * Method for creating the page for a batchjob. It contains the following informations: * <p>/* w ww .jav a 2 s. c o m*/ * <br/> * - Creates a line with the name of the batchjob.<br/> * - Write the description if the batchjob has a metadata resource annotation description of the batchjob class.<br/> * - The last run information, date and size of the error and output files. <br/> * - The arguments of the batchjob, with information if they have been defined in the resource annotations of the * class.<br/> * - Radio buttons for choosing the replica.<br/> * - Input box for regular expression for filenames to match.<br/> * - Execution button.<br/> * * @param context The context of the page. Must contains a class name of the batchjob. * @throws UnknownID If the class cannot be found. * @throws ArgumentNotValid If the context is null. * @throws IllegalState If the class is not an instance of FileBatchJob. * @throws ForwardedToErrorPage If the context does not contain the required information. * @throws IOFailure If there is problems with the JspWriter. */ @SuppressWarnings("rawtypes") public static void getPageForClass(PageContext context) throws UnknownID, ArgumentNotValid, IllegalState, ForwardedToErrorPage, IOFailure { ArgumentNotValid.checkNotNull(context, "PageContext context"); HTMLUtils.forwardOnEmptyParameter(context, Constants.BATCHJOB_PARAMETER); try { // Retrieve variables Locale locale = context.getResponse().getLocale(); ServletRequest request = context.getRequest(); String className = request.getParameter(Constants.BATCHJOB_PARAMETER); JspWriter out = context.getOut(); // retrieve the batch class and the constructor. Class c = getBatchClass(className); out.print(I18N.getString(locale, "batchpage;Name.of.batchjob", new Object[] {}) + ": <b>" + c.getName() + "</b><br/>\n"); out.print(getClassDescription(c, locale)); out.print(getPreviousRuns(c.getName(), locale)); // begin form out.println("<form method=\"post\" action=\"" + Constants.URL_BATCHJOB_EXECUTE + "?" + Constants.BATCHJOB_PARAMETER + "=" + className + "\">"); out.print(getHTMLarguments(c, locale)); out.print(getReplicaRadioButtons(locale)); out.print(getRegularExpressionInputBox(locale)); out.print(getSubmitButton(locale)); // end form out.print("</form>"); } catch (IOException e) { String errMsg = "Could not create page with batchjobs."; log.warn(errMsg, e); throw new IOFailure(errMsg, e); } }
From source file:de.u808.simpleinquest.web.tags.VersionInfoTag.java
@Override public void doTag() throws JspException, IOException { PageContext pageContext = (PageContext) getJspContext(); JspWriter out = pageContext.getOut(); try {// w ww .ja v a 2 s. c om String appServerHome = pageContext.getServletContext().getRealPath("/"); File manifestFile = new File(appServerHome, "META-INF/MANIFEST.MF"); Manifest mf = new Manifest(); mf.read(new FileInputStream(manifestFile)); Attributes atts = mf.getMainAttributes(); out.println("<span id=\"version\"> (Revision " + atts.getValue("Implementation-Version") + " Build " + atts.getValue("Implementation-Build") + " Built-By " + atts.getValue("Built-By") + ")</span>"); } catch (Exception e) { log.error("Tag error", e); } }
From source file:info.magnolia.templating.jsp.taglib.SearchResultSnippetTag.java
/** * @see javax.servlet.jsp.tagext.TagSupport#doStartTag() *///from w w w . j a va2s . co m @Override public int doStartTag() throws JspException { JspWriter out = this.pageContext.getOut(); try { Iterator iterator = getSnippets().iterator(); while (iterator.hasNext()) { out.println(iterator.next()); } } catch (IOException e) { // should never happen throw new NestableRuntimeException(e); } return EVAL_PAGE; }
From source file:org.hyperic.hq.ui.taglib.ConstantsTag.java
protected void die(JspWriter out, String err) throws JspException { if (failmode) { throw new JspException(err); } else {/*from w w w. ja v a 2 s . com*/ try { out.println("<!-- constants tag misconfigured -->"); } catch (java.io.IOException e) { // misconfigured and hosed, what a difficult // situation log.debug("constants tag misconfigured: ", e); } } }
From source file:com.silverpeas.tags.navigation.FilArianeTag.java
@Override public int doStartTag() throws JspException { try {/* w w w .jav a 2 s . c o m*/ JspWriter out = pageContext.getOut(); NodeDetail current = themetracker.getTopic(idCurrentTopic); String path = generateBreadcrumb(current); out.println(path); } catch (Exception e) { e.printStackTrace(); } return SKIP_BODY; }
From source file:nl.strohalm.cyclos.taglibs.MultiDropDownTag.java
@Override public int doEndTag() throws JspException { try {//from w w w . j a v a2 s. c om // Build the options object final StringBuilder options = new StringBuilder(); options.append('{'); options.append("'singleField':").append(singleField).append(','); options.append("'open':").append(open).append(','); options.append("'disabled':").append(disabled); if (size != null) { options.append(",'size':").append(size); } if (minWidth != null) { options.append(",'minWidth':").append(minWidth); } if (maxWidth != null) { options.append(",'maxWidth':").append(maxWidth); } if (emptyLabelKey != null) { emptyLabel = messageHelper.message(emptyLabelKey); } if (emptyLabel != null) { options.append(",'emptyLabel':\"").append(StringEscapeUtils.escapeJavaScript(emptyLabel)) .append('"'); } if (onchange != null) { options.append(",'onchange':\"").append(StringEscapeUtils.escapeJavaScript(onchange)).append('"'); } options.append('}'); // Write the rest of the script final JspWriter out = pageContext.getOut(); if (StringUtils.isNotEmpty(varName)) { out.print(varName + "="); } out.println("new MultiDropDown(" + divId + ", '" + name + "', " + divId + ".values, " + options + ")"); out.println("</script>"); return EVAL_PAGE; } catch (final IOException e) { throw new JspException(e); } finally { release(); } }