List of usage examples for javax.servlet.jsp JspWriter print
abstract public void print(Object obj) throws IOException;
From source file:org.dspace.app.webui.jsptag.ItemTag.java
/** * List links to collections if information is available *//*from w ww . j a va 2s.c o m*/ private void listCollections() throws IOException { JspWriter out = pageContext.getOut(); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); if (collections != null) { out.print("<tr><td class=\"metadataFieldLabel\">"); if (item.getHandle() == null) // assume workspace item { out.print(LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.submitted")); } else { out.print(LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.appears")); } out.print("</td><td class=\"metadataFieldValue\">"); for (int i = 0; i < collections.length; i++) { out.print("<a href=\""); out.print(request.getContextPath()); out.print("/handle/"); out.print(collections[i].getHandle()); out.print("\">"); out.print(collections[i].getMetadata("name")); out.print("</a><br/>"); } out.println("</td></tr>"); } }
From source file:net.duckling.ddl.web.tag.LinkTag.java
public int doEndTag() { try {//from w w w . j a v a 2s. c o m if (!mOverrideAbsolute) { VWBContainer container = vwbcontext.getContainer(); mAbsolute = "absolute".equals(container.getProperty(KeyConstants.PREF_REFER_STYLE)); } JspWriter out = pageContext.getOut(); String url = figureOutURL(); url = chooseURLScheme(url); StringBuffer sb = new StringBuffer(20); sb.append((mClass != null) ? "class=\"" + mClass + "\" " : ""); sb.append((mStyle != null) ? "style=\"" + mStyle + "\" " : ""); sb.append((mTarget != null) ? "target=\"" + mTarget + "\" " : ""); sb.append((mTitle != null) ? "title=\"" + mTitle + "\" " : ""); sb.append((mRel != null) ? "rel=\"" + mRel + "\" " : ""); sb.append((mAccesskey != null) ? "accesskey=\"" + mAccesskey + "\" " : ""); switch (m_format) { case URL: out.print(url); break; default: case ANCHOR: out.print("<a " + sb.toString() + " href=\"" + url + "\">"); break; } // Add any explicit body content. This is not the intended use // of LinkTag, but happens to be the way it has worked previously. if (mBodyContent != null) { String linktext = mBodyContent.getString().trim(); out.write(linktext); } // Finish off by closing opened anchor if (m_format == ANCHOR) { out.print("</a>"); } } catch (Exception e) { // Yes, we want to catch all exceptions here, including // RuntimeExceptions LOG.error("Tag failed", e); } return EVAL_PAGE; }
From source file:org.opencms.workplace.list.A_CmsListDialog.java
/** * Writes the dialog html code, only if the <code>{@link #ACTION_DEFAULT}</code> is set.<p> * /*from w ww. j a va2 s . co m*/ * @throws IOException if writing to the JSP out fails, or in case of errros forwarding to the required result page */ public void writeDialog() throws IOException { if (isForwarded()) { return; } if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_START_WRITE_LIST_1, getListId())); } JspWriter out = getJsp().getJspContext().getOut(); out.print(defaultActionHtml()); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_END_WRITE_LIST_1, getListId())); } }
From source file:com.xhsoft.framework.common.page.WebappPageTag.java
/** * <p>Description: build up goto text area and print</p> * @param request /*from w w w . j a v a2 s .c o m*/ * @param pageNo * @param totalPages * @return void * @author wenzhi * @version 1.0 * @exception JspException */ @SuppressWarnings("unused") private void buildGoto(HttpServletRequest request, int pageNo, int totalPages) throws JspException { try { JspWriter out = pageContext.getOut(); if (StringUtils.isEmpty(pageSizeList)) { pageSizeList = INIT_PAGE_SIZE_LIST; } String[] pageSizes = pageSizeList.split(","); String rand = UUID.randomUUID().toString(); String outString = "<input name=\"gotoText" + rand + "\" type=\"text\" size=\"5\" value=\"" + pageNo + "\" onkeydown=\"return gotoPage(this.value,'" + pageNo + "','" + totalPages + "','" + targets + "');\">" + "<input type=\"button\" name=\"go\" value=\"GO\" class=\"button2\" onclick=\"return gotoPageDirect(dojo.byId('gotoText" + rand + "').value,'" + pageNo + "','" + totalPages + "','" + targets + "');\">"; out.print(outString); } catch (Exception e) { throw new JspException(e); } }
From source file:org.dspace.app.webui.jsptag.ItemTag.java
/** * List bitstreams in the item//from w ww .j av a 2s . c o m */ private void listBitstreams() throws IOException { JspWriter out = pageContext.getOut(); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); out.print("<table align=\"center\" class=\"miscTable\"><tr>"); out.println("<td class=\"evenRowEvenCol\"><p><strong>" + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.files") + "</strong></p>"); try { Bundle[] bundles = item.getBundles("ORIGINAL"); boolean filesExist = false; for (Bundle bnd : bundles) { filesExist = bnd.getBitstreams().length > 0; if (filesExist) { break; } } // if user already has uploaded at least one file if (!filesExist) { out.println("<p>" + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.files.no") + "</p>"); } else { boolean html = false; String handle = item.getHandle(); Bitstream primaryBitstream = null; Bundle[] bunds = item.getBundles("ORIGINAL"); Bundle[] thumbs = item.getBundles("THUMBNAIL"); // if item contains multiple bitstreams, display bitstream // description boolean multiFile = false; Bundle[] allBundles = item.getBundles(); for (int i = 0, filecount = 0; (i < allBundles.length) && !multiFile; i++) { filecount += allBundles[i].getBitstreams().length; multiFile = (filecount > 1); } // check if primary bitstream is html if (bunds[0] != null) { Bitstream[] bits = bunds[0].getBitstreams(); for (int i = 0; (i < bits.length) && !html; i++) { if (bits[i].getID() == bunds[0].getPrimaryBitstreamID()) { html = bits[i].getFormat().getMIMEType().equals("text/html"); primaryBitstream = bits[i]; } } } out.println("<table cellpadding=\"6\"><tr><th id=\"t1\" class=\"standard\">" + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.file") + "</th>"); if (multiFile) { out.println("<th id=\"t2\" class=\"standard\">" + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.description") + "</th>"); } out.println("<th id=\"t3\" class=\"standard\">" + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.filesize") + "</th><th id=\"t4\" class=\"standard\">" + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.fileformat") + "</th></tr>"); // if primary bitstream is html, display a link for only that one to // HTMLServlet if (html) { // If no real Handle yet (e.g. because Item is in workflow) // we use the 'fake' Handle db-id/1234 where 1234 is the // database ID of the item. if (handle == null) { handle = "db-id/" + item.getID(); } out.print("<tr><td headers=\"t1\" class=\"standard\">"); out.print("<a target=\"_blank\" href=\""); out.print(request.getContextPath()); out.print("/html/"); out.print(handle + "/"); out.print(UIUtil.encodeBitstreamName(primaryBitstream.getName(), Constants.DEFAULT_ENCODING)); out.print("\">"); out.print(primaryBitstream.getName()); out.print("</a>"); if (multiFile) { out.print("</td><td headers=\"t2\" class=\"standard\">"); String desc = primaryBitstream.getDescription(); out.print((desc != null) ? desc : ""); } out.print("</td><td headers=\"t3\" class=\"standard\">"); out.print(UIUtil.formatFileSize(primaryBitstream.getSize())); out.print("</td><td headers=\"t4\" class=\"standard\">"); out.print(primaryBitstream.getFormatDescription()); out.print("</td><td class=\"standard\"><a target=\"_blank\" href=\""); out.print(request.getContextPath()); out.print("/html/"); out.print(handle + "/"); out.print(UIUtil.encodeBitstreamName(primaryBitstream.getName(), Constants.DEFAULT_ENCODING)); out.print("\">" + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.view") + "</a></td></tr>"); } else { for (int i = 0; i < bundles.length; i++) { Bitstream[] bitstreams = bundles[i].getBitstreams(); for (int k = 0; k < bitstreams.length; k++) { // Skip internal types if (!bitstreams[k].getFormat().isInternal()) { // Work out what the bitstream link should be // (persistent // ID if item has Handle) String bsLink = "<a target=\"_blank\" href=\"" + request.getContextPath(); if ((handle != null) && (bitstreams[k].getSequenceID() > 0)) { bsLink = bsLink + "/bitstream/" + item.getHandle() + "/" + bitstreams[k].getSequenceID() + "/"; } else { bsLink = bsLink + "/retrieve/" + bitstreams[k].getID() + "/"; } bsLink = bsLink + UIUtil.encodeBitstreamName(bitstreams[k].getName(), Constants.DEFAULT_ENCODING) + "\">"; out.print("<tr><td headers=\"t1\" class=\"standard\">"); out.print(bsLink); out.print(bitstreams[k].getName()); out.print("</a>"); if (multiFile) { out.print("</td><td headers=\"t2\" class=\"standard\">"); String desc = bitstreams[k].getDescription(); out.print((desc != null) ? desc : ""); } out.print("</td><td headers=\"t3\" class=\"standard\">"); out.print(UIUtil.formatFileSize(bitstreams[k].getSize())); out.print("</td><td headers=\"t4\" class=\"standard\">"); out.print(bitstreams[k].getFormatDescription()); out.print("</td><td class=\"standard\" align=\"center\">"); // is there a thumbnail bundle? if ((thumbs.length > 0) && showThumbs) { String tName = bitstreams[k].getName() + ".jpg"; String tAltText = LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.thumbnail"); Bitstream tb = thumbs[0].getBitstreamByName(tName); if (tb != null) { String myPath = request.getContextPath() + "/retrieve/" + tb.getID() + "/" + UIUtil.encodeBitstreamName(tb.getName(), Constants.DEFAULT_ENCODING); out.print(bsLink); out.print("<img src=\"" + myPath + "\" "); out.print("alt=\"" + tAltText + "\" /></a><br />"); } } out.print(bsLink + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.view") + "</a></td></tr>"); } } } } out.println("</table>"); } } catch (SQLException sqle) { throw new IOException(sqle.getMessage(), sqle); } out.println("</td></tr></table>"); }
From source file:com.xhsoft.framework.common.page.PageTag.java
/** * <p>Description:build up selecter and print</p> * @param request // w w w .j a v a2 s.com * @param limit * @return void * @author wenzhi * @version 1.0 * @exception JspException */ private void buildSelecter(HttpServletRequest request, int limit) throws JspException { try { JspWriter out = pageContext.getOut(); if (StringUtils.isEmpty(pageSizeList)) { pageSizeList = INIT_PAGE_SIZE_LIST; } String[] pageSizes = pageSizeList.split(","); String outString = "?<select name=\"pageSizeSelect\" onchange=\"setLimit(this.value,'" + targets + "')\">"; for (int i = 0; i < pageSizes.length; i++) { if (limit == Integer.parseInt(pageSizes[i])) { outString += "<option selected value=\"" + pageSizes[i] + "\">" + pageSizes[i] + "</option>"; } else { outString += "<option value=\"" + pageSizes[i] + "\">" + pageSizes[i] + "</option>"; } } outString += "</select>"; out.print(outString); } catch (Exception e) { throw new JspException(e); } }
From source file:com.xhsoft.framework.common.page.WebappPageTag.java
/** * <p>Description: build up selecter and print</p> * @param request //from w ww . j a v a 2 s. c o m * @param limit * @return void * @author wenzhi * @version 1.0 * @exception JspException */ @SuppressWarnings("unused") private void buildSelecter(HttpServletRequest request, int limit) throws JspException { try { JspWriter out = pageContext.getOut(); if (StringUtils.isEmpty(pageSizeList)) { pageSizeList = INIT_PAGE_SIZE_LIST; } String[] pageSizes = pageSizeList.split(","); String outString = "?<select name=\"pageSizeSelect\" onchange=\"setLimit(this.value,'" + targets + "')\">"; for (int i = 0; i < pageSizes.length; i++) { if (limit == Integer.parseInt(pageSizes[i])) { outString += "<option selected value=\"" + pageSizes[i] + "\">" + pageSizes[i] + "</option>"; } else { outString += "<option value=\"" + pageSizes[i] + "\">" + pageSizes[i] + "</option>"; } } outString += "</select>"; out.print(outString); } catch (Exception e) { throw new JspException(e); } }
From source file:com.xhsoft.framework.common.page.PageTag.java
/** * <p>Description:build up goto text area and print</p> * @param request //w w w . j av a 2s . c o m * @param pageNo * @param totalPages * @return void * @author wenzhi * @version 1.0 * @exception Exception */ private void buildGoto(HttpServletRequest request, int pageNo, int totalPages) throws JspException { try { JspWriter out = pageContext.getOut(); if (StringUtils.isEmpty(pageSizeList)) { pageSizeList = INIT_PAGE_SIZE_LIST; } @SuppressWarnings("unused") String[] pageSizes = pageSizeList.split(","); String rand = UUID.randomUUID().toString(); String outString = "<input name=\"gotoText" + rand + "\" type=\"text\" size=\"5\" value=\"" + pageNo + "\" onkeydown=\"return gotoPage(this.value,'" + pageNo + "','" + totalPages + "','" + targets + "');\">" + "<input type=\"button\" name=\"go\" value=\"GO\" class=\"button2\" onclick=\"return gotoPageDirect(dojo.byId('gotoText" + rand + "').value,'" + pageNo + "','" + totalPages + "','" + targets + "');\">"; out.print(outString); } catch (Exception e) { throw new JspException(e); } }
From source file:org.opencms.frontend.templateone.CmsTemplateBean.java
/** * Builds the main html output for the template foot and includes all subelements depending on the settings.<p> * * @throws IOException if writing the output fails * @throws JspException if including an element fails *//*from www.ja v a2 s . com*/ public void buildHtmlBodyEnd() throws IOException, JspException { m_properties.put(PARAM_LAYOUT, getLayout()); // close content column JspWriter out = getJspContext().getOut(); String elementName = FOLDER_ELEMENTS + "body_end.jsp"; out.print(getTemplateParts().includePart(elementName, "1", getLayout(), this)); if (!showPrintVersion()) { // build the side info box include(getExtensionModuleFileUri("elements/info_side.jsp"), null, m_properties); } // close main content row out.print(getTemplateParts().includePart(elementName, "2", getLayout(), this)); if (!showPrintVersion()) { // build the foot links row getProperties().put(PARAM_HELPURI, getConfigurationValue("help.uri", PROPERTY_VALUE_NONE)); getProperties().put(PARAM_LOGINURI, getConfigurationValue("login.uri", PROPERTY_VALUE_NONE)); include(FOLDER_ELEMENTS + "foot_links.jsp", null, m_properties); boolean showMenus = Boolean.valueOf(getConfigurationValue("headnav.menus", CmsStringUtil.TRUE)) .booleanValue(); if (showHeadNavigation() && showMenus) { // create the head navigation dhtml menus if (getProperties().get(CmsTemplateNavigation.PARAM_HEADNAV_MENUDEPTH) == null) { getProperties().put(PARAM_SITE, getRequestContext().getSiteRoot()); getProperties().put(CmsTemplateNavigation.PARAM_STARTFOLDER, getStartFolder()); getProperties().put(CmsTemplateNavigation.PARAM_HEADNAV_FOLDER, getNavigationStartFolder()); getProperties().put(CmsTemplateNavigation.PARAM_HEADNAV_MENUDEPTH, getConfigurationValue("headnav.menudepth", "1")); getProperties().put(CmsTemplateNavigation.PARAM_SHOWMENUS, getConfigurationValue("headnav.menus", CmsStringUtil.TRUE)); getProperties().put(CmsTemplateNavigation.PARAM_HEADNAV_MANUAL, getConfigurationValue("headnav.manual", CmsStringUtil.FALSE)); } include(FOLDER_ELEMENTS + "nav_head_menus.jsp", null, m_properties); } } else { // include the page information m_properties.put(CmsTemplateBean.PARAM_URI, getRequestContext().getUri()); include(CmsWorkplace.VFS_PATH_MODULES + MODULE_NAME + "/pages/imprint.html", "content", m_properties); } // close body and html out.print(getTemplateParts().includePart(elementName, "3", getLayout(), this)); }
From source file:de.u808.simpleinquest.web.tags.HitsNavigationTag.java
public void doTag() throws JspException { PageContext pageContext = (PageContext) getJspContext(); JspWriter out = pageContext.getOut(); try {/*from ww w . jav a 2s . c o m*/ boolean isFirstPage = search.getPageIndex() == 0; boolean isLastPage = search.getPageIndex() == search.getPageCount() - 1; if (!isFirstPage) { out.println("<a href=\"search.htm?searchString=" + search.getSearchString() + "&pageIndex=0\"> "); } out.println("<img src=\"/SimpleInquest/img/start.gif\" alt=\"Erste Seite\"/>"); if (!isFirstPage) { out.println("</a>"); out.println("<a href=\"search.htm?searchString=" + search.getSearchString() + "&pageIndex=" + (search.getPageIndex() - 1) + "\"> "); } out.println("<img src=\"/SimpleInquest/img/left.gif\" alt=\"Vorherige Seite\"/>"); if (!isFirstPage) { out.println("</a>"); } for (int i = 0; i < search.getPageCount(); i++) { if (i != search.getPageIndex()) { out.println("<a href=\"search.htm?searchString=" + search.getSearchString() + "&pageIndex=" + i + "\"> " + (i + 1) + "</a>"); } else { out.print(i + 1); } } if (!isLastPage) { out.println("<a href=\"search.htm?searchString=" + search.getSearchString() + "&pageIndex=" + (search.getPageIndex() + 1) + "\"> "); } out.println("<img src=\"/SimpleInquest/img/right.gif\" alt=\"Folgende Seite\"/>"); if (!isLastPage) { out.println("</a>"); out.println("<a href=\"search.htm?searchString=" + search.getSearchString() + "&pageIndex=" + (search.getPageCount() - 1) + "\"> "); } out.println("<img src=\"/SimpleInquest/img/end.gif\" alt=\"Letzte Seite\"/>"); if (!isLastPage) { out.println("</a>"); } } catch (Exception e) { log.error("Tag error", e); } }