List of usage examples for javax.servlet.jsp JspWriter println
abstract public void println(Object x) throws IOException;
From source file:jp.terasoluna.fw.web.taglib.TagUtil.java
/** * PageContextJspWriter?AweLXg?o?B// ww w . j a v a 2s . c om * ?s?B * * @param pageContext y?[WReLXg * @param text ?oeLXg * @throws JspException * I/OG?[???IOExceptionbvO */ public static void writeln(PageContext pageContext, String text) throws JspException { JspWriter writer = pageContext.getOut(); try { writer.println(text); } catch (IOException e) { throw new JspException(e); } }
From source file:com.cyberway.issue.util.TextUtils.java
/** * Utility method for writing a (potentially large) String to a JspWriter, * escaping it for HTML display, without constructing another large String * of the whole content. //from w w w .j a va 2 s. c om * @param s String to write * @param out destination JspWriter * @throws IOException */ public static void writeEscapedForHTML(String s, JspWriter out) throws IOException { BufferedReader reader = new BufferedReader(new StringReader(s)); String line; while ((line = reader.readLine()) != null) { out.println(StringEscapeUtils.escapeHtml(line)); } }
From source file:de.iteratec.iteraplan.presentation.tags.TagUtils.java
/** * This method will print the literal (if given) or else the value of the key * /*from w w w .j a v a 2 s. co m*/ * @param ctx * @param literal * @param key * @throws JspException * @throws IOException */ public static void insertMessage(PageContext ctx, String literal, String key) throws JspException, IOException { JspWriter w = ctx.getOut(); if (literal != null && literal.length() != 0) { w.println(literal); } MessageTag messageTag = new MessageTag(); messageTag.doStartTag(); messageTag.setPageContext(ctx); messageTag.setKey(key); messageTag.doEndTag(); }
From source file:com.day.cq.wcm.foundation.forms.ValidationHelper.java
/** * Write java script client code for a regexp. * @deprecated Use {@link FieldHelper#writeClientRegexpText(SlingHttpServletRequest, SlingHttpServletResponse, FieldDescription, String)} *//*from w ww. j a va 2 s .com*/ @Deprecated public static void writeRegexpText(final SlingHttpServletRequest request, final Resource resource, final String regexp, final JspWriter out) throws IOException { final String id = ValidationHelper.getFormElementQualifier(request, resource); final String name = FormsHelper.getParameterName(resource); out.println("{ var result=false;"); out.print("var pattern = "); out.print(regexp); out.print("; var t = pattern.exec("); out.print(id); out.print(".value);"); out.println("if (t) {"); out.println("var len = "); out.print(id); out.print(".value.length;"); out.println("var pattlen = t[0].length;"); out.println("result = (pattlen == len); "); out.println("}"); out.println("if ( !result ) {"); out.print("cq5forms_showMsg('"); out.print(StringEscapeUtils.escapeEcmaScript(FormsHelper.getFormId(request))); out.print("','"); out.print(StringEscapeUtils.escapeEcmaScript(name)); out.print("','"); out.print(StringEscapeUtils.escapeEcmaScript(ValidationHelper.getConstraintMessage(resource))); out.print("');"); out.println("return false; } }"); }
From source file:de.iteratec.iteraplan.presentation.tags.TagUtils.java
public static void insertImage(PageContext ctx, String image, int width, int height) throws IOException { JspWriter w = ctx.getOut(); String alt = ""; w.print("<img src=\""); w.print(ctx.getServletContext().getContextPath()); w.print(image);/*from w w w .j ava2s .c om*/ w.println("\" style=\"float: right;\" width=\"" + width + "\" height=\"" + height + "\" alt=\"" + alt + "\" />"); }
From source file:io.undertow.test.jsp.expression.ExpressionJspTestCase.java
public static void testIIllegalState(PageContext pageContext, JspWriter out) throws Exception { assert pageContext != null; ELContext elContext = pageContext.getELContext(); assert elContext != null; JspApplicationContext jaContext = JspFactory.getDefaultFactory() .getJspApplicationContext(pageContext.getServletContext()); assert jaContext != null; try {//w w w . j a v a 2 s .com jaContext.addELResolver(new CompositeELResolver()); out.println("addELResolver call succeeded. Test FAILED."); } catch (IllegalStateException ise) { out.println("Test PASSED"); } }
From source file:dk.netarkivet.archive.webinterface.BitpreserveFileState.java
/** * Print a table row with a file name and a checkbox to request more info. * * @param out The stream to print to.// w w w. j av a 2 s . co m * @param filename The name of the file. * @param rowCount The rowcount, used for styling rows. * @param locale The current locale for labels. * @throws IOException On trouble writing to stream. */ public static void printFileName(JspWriter out, String filename, int rowCount, Locale locale) throws IOException { ArgumentNotValid.checkNotNull(out, "JspWriter out"); ArgumentNotValid.checkNotNullOrEmpty(filename, "String filename"); ArgumentNotValid.checkNotNull(locale, "Locale locale"); out.println("<tr class=\"" + HTMLUtils.getRowClass(rowCount) + "\">"); out.println(HTMLUtils.makeTableElement(filename)); out.print("<td>"); out.print(makeCheckbox(Constants.GET_INFO_COMMAND, filename)); out.print(I18N.getString(locale, "get.info")); out.println("</td>"); out.println("</tr>"); }
From source file:dk.netarkivet.archive.webinterface.BitpreserveFileState.java
/** * Print checkboxes for changing state for files. This will print two checkboxes for changing a number of * checkboxes, one for getting more info, one for reestablishing missing files. This method assumes the file * toggleCheckboxes.js to be available in the directory with the page this method is called from. * * @param out The stream to print the checkboxes to. * @param locale The locale of the labels. * @param numberOfMissingCheckboxes The total possible number of missing checkboxes. * @param numberOfUploadableCheckboxes The total possible number of reestablish checkboxes. * @throws IOException On trouble printing the checkboxes. *//*from w ww.ja v a2 s . c om*/ public static void printToggleCheckboxes(JspWriter out, Locale locale, int numberOfMissingCheckboxes, int numberOfUploadableCheckboxes) throws IOException { // Print the javascript needed. ArgumentNotValid.checkNotNull(out, "JspWriter out"); ArgumentNotValid.checkNotNull(locale, "Locale locale"); out.println("<script type=\"text/javascript\" language=\"javascript\"" + " src=\"toggleCheckboxes.js\"></script>"); // Add checkbox to toggle multiple "fileinfo" checkboxes printMultipleToggler(out, Constants.GET_INFO_COMMAND, numberOfMissingCheckboxes, "change.infobox.for.0.files", locale); // Add checkbox to toggle multiple "reupload" checkboxes if (numberOfUploadableCheckboxes > 0) { printMultipleToggler(out, Constants.ADD_COMMAND, numberOfUploadableCheckboxes, "change.0.may.be.added", locale); } }
From source file:dk.netarkivet.archive.webinterface.BitpreserveFileState.java
/** * Print a file state table for a file. This will present the state of the file in admin data and all bitarchives. * * @param out The stream to print to./* w w w. jav a 2s . c om*/ * @param fs The file state for the file. * @param locale The locale to print labels in. * @throws IOException On trouble printing to a stream. */ public static void printFileState(JspWriter out, PreservationState fs, Locale locale) throws IOException { ArgumentNotValid.checkNotNull(out, "JspWriter out"); ArgumentNotValid.checkNotNull(fs, "FilePreservationState fs"); ArgumentNotValid.checkNotNull(locale, "Locale locale"); // Table headers for info table out.println("<table>"); out.print(HTMLUtils.makeTableRow(HTMLUtils.makeTableHeader(I18N.getString(locale, "replica")), HTMLUtils.makeTableHeader(I18N.getString(locale, "admin.state")), HTMLUtils.makeTableHeader(I18N.getString(locale, "checksum")))); // Admin data info printFileStateForAdminData(out, fs, locale); // Info for all bitarchives for (Replica l : Replica.getKnown()) { printFileStateForBitarchive(out, l, fs, locale); } out.println("</table>"); }
From source file:com.day.cq.wcm.foundation.forms.ValidationHelper.java
/** * Write java script client code for a required check. * @deprecated Use {@link FieldHelper#writeClientRequiredCheck(SlingHttpServletRequest, SlingHttpServletResponse, FieldDescription)} *//*from ww w . j a va 2 s . c o m*/ @Deprecated public static void writeRequiredCheck(final SlingHttpServletRequest request, final Resource resource, final JspWriter out) throws IOException { final String formId = FormsHelper.getFormId(request); final String name = FormsHelper.getParameterName(resource); if (FormsHelper.isRequired(resource)) { final String qualifier = getFormElementQualifier(request, resource); out.print("if (cq5forms_isEmpty("); out.print(qualifier); out.print(")) {cq5forms_showMsg('"); out.print(StringEscapeUtils.escapeEcmaScript(formId)); out.print("','"); out.print(StringEscapeUtils.escapeEcmaScript(name)); out.print("','"); out.print(StringEscapeUtils.escapeEcmaScript(ValidationHelper.getRequiredMessage(resource))); out.println("'); return false; }"); } }