List of usage examples for javax.servlet.jsp JspWriter println
abstract public void println(Object x) throws IOException;
From source file:org.dspace.app.webui.jsptag.ItemTag.java
/** * List bitstreams in the item//from w w w.j a va 2 s.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:nl.strohalm.cyclos.taglibs.MenuTag.java
/** * Render the current div//from www . j a v a 2 s. com */ private void renderDiv(final Menu menu, final int index, final String divId) throws IOException, JspException { final JspWriter out = pageContext.getOut(); final String className = getClassName(menu); out.print("<li id='" + divId + "'class='" + className + "'"); String url = menu.getUrl(); if (StringUtils.isNotEmpty(url)) { url = StringEscapeUtils.escapeHtml(url); if (url.contains("?")) { url += "&"; } else { url += "?"; } url += "fromMenu=true"; out.print(" linkURL=\"" + url + "\""); final String confirmationKey = menu.getConfirmationKey(); if (StringUtils.isNotEmpty(confirmationKey)) { out.print(" confirmationMessage=\"" + StringEscapeUtils.escapeHtml(messageHelper.message(confirmationKey)) + "\""); } } out.print(">"); out.print("<span class=\"" + className + "Bullet\"></span>"); out.print("<span class=\"" + className + "Text\">"); final String displayName = menu.getLabel(); out.print(EscapeHTMLTag.escape(displayName, true)); out.println("</span>"); if (menu.getParent() == null) { out.println("<script>menuCount++;</script>"); } }
From source file:org.kuali.mobility.tags.PageTag.java
public void doTag() throws JspException { PageContext pageContext = (PageContext) getJspContext(); HttpServletRequest hsr = (HttpServletRequest) pageContext.getRequest(); Cookie cks[] = hsr.getCookies();/* w ww .j a v a 2 s . c o m*/ if (cks != null) { for (Cookie c : cks) { if (c.getName().equals("jqmHeader")) { jqmHeader = c.getValue(); //LOG.info("---jqmHeader: " + jqmHeader); } } } ServletContext servletContext = pageContext.getServletContext(); WebApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(servletContext); setAuthMapper((AuthenticationMapper) ac.getBean("authenticationMapper")); CoreService coreService = (CoreService) ac.getBean("coreService"); Properties kmeProperties = (Properties) ac.getBean("kmeProperties"); Locale locale = RequestContextUtils.getLocale((HttpServletRequest) pageContext.getRequest()); MessageSource ms = (MessageSource) ac.getBean("messageSource"); String msgCatString = null; User user = (User) pageContext.getSession().getAttribute(AuthenticationConstants.KME_USER_KEY); String contextPath = servletContext.getContextPath(); JspWriter out = pageContext.getOut(); try { out.println("<!DOCTYPE html>"); if (getAppcacheEnabled().isEmpty()) { setAppcacheEnabled(kmeProperties.getProperty("appcache.enabled", "true")); } LOG.info("param.appcacheEnabled: " + getAppcacheEnabled()); if (!appcacheEnabled.equals("false")) { LOG.debug("Appcache Enabled"); out.println("<html manifest=\"" + contextPath + "/" + (StringUtils.isEmpty(getAppcacheFilename()) ? "kme.appcache" : getAppcacheFilename().trim()) + "\">"); } else { LOG.debug("Appcache Disabled"); out.println("<html>"); } out.println("<head>"); out.println("<title>" + getTitle() + "</title>"); out.println( "<link href=\"" + kmeProperties.getProperty("favico.url", "http://www.kuali.org/favicon.ico") + "\" rel=\"icon\" />"); out.println( "<link href=\"" + kmeProperties.getProperty("favico.url", "http://www.kuali.org/favicon.ico") + "\" rel=\"shortcut icon\" />"); out.println("<link rel=\"apple-touch-icon\" href=\"" + contextPath + "/touch-icon-iphone.png\"/>"); out.println("<link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"" + contextPath + "/touch-icon-ipad.png\"/>"); out.println("<link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"" + contextPath + "/touch-icon-iphone-retina.png\"/>"); out.println("<link rel=\"apple-touch-icon\" sizes=\"144x144\" href=\"" + contextPath + "/touch-icon-ipad-retina.png\"/>"); out.println("<link href=\"" + contextPath + "/css/jquery.mobile.css\" rel=\"stylesheet\" type=\"text/css\" />"); out.println("<link href=\"" + contextPath + "/css/jquery-mobile-fluid960.css\" rel=\"stylesheet\" type=\"text/css\" />"); out.println("<link href=\"" + contextPath + "/css/kme.css\" rel=\"stylesheet\" type=\"text/css\" />"); out.println("<link href=\"" + contextPath + "/css/institution.css\" rel=\"stylesheet\" type=\"text/css\" />"); addTheme(); // Attach all CSS files for (String cssFile : getCssFilenames()) { out.println("<link href=\"" + contextPath + "/css/" + cssFile + ".css\" rel=\"stylesheet\" type=\"text/css\" />"); } out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/jquery.js\"></script>"); out.println( "<script type=\"text/javascript\" src=\"" + contextPath + "/js/jquery.cookie.js\"></script>"); out.println( "<script type=\"text/javascript\" src=\"" + contextPath + "/js/ServerDetails.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/custom.js\"></script>"); out.println( "<script type=\"text/javascript\" src=\"" + contextPath + "/js/jquery.mobile.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/jquery.tmpl.js\"></script>"); out.println( "<script type=\"text/javascript\" src=\"" + contextPath + "/js/jquery.validate.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/jquery.validate.ready.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/jquery.templates.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/jquery.transit.min.js\"></script>"); out.println( "<script type=\"text/javascript\" src=\"" + contextPath + "/js/BrowserDetect.js\"></script>"); if (this.isNative()) { out.println( "<script type=\"text/javascript\" src=\"" + contextPath + "/js/PushConfig.js\"></script>"); } // out.println("<script src=\"http://jsconsole.com/remote.js?2EA94DB3-FD2F-4FF8-B41E-AB2B9A064544\"></script>"); if (isPlatform(Device.TYPE_IOS)) { if (isPhoneGap("1.4.1")) { out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/phonegap-1.4.1.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/ChildBrowser.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/barcodescanner.js\"></script>"); // out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/Connection.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/PushHandler.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/Badge.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/applicationPreferences.js\"></script>"); } else if (isPhoneGap("1.7.0")) { out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/1.7.0/cordova-1.7.0.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/1.7.0/ChildBrowser.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/1.7.0/barcodescanner.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/1.7.0/ActionSheet.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/1.7.0/Badge.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/1.7.0/LocalNotifications.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/1.7.0/Notifications.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/1.7.0/PrintPlugin.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/1.7.0/applicationPreferences.js\"></script>"); } else if (isPhoneGap("2.2.0")) { out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/2.2.0/cordova-2.2.0.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/2.2.0/ActionSheet.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/2.2.0/applicationPreferences.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/2.2.0/AudioStreamer.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/2.2.0/Badge.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/2.2.0/barcodescanner.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/2.2.0/ChildBrowser.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/PushHandler.js\"></script>"); } else if (isPhoneGap("2.3.0")) { out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/2.3.0/cordova-2.3.0.js\"></script>"); } else if (isPhoneGap("2.4.0")) { out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/2.4.0/cordova-2.4.0.js\"></script>"); } else if (isPhoneGap("2.5.0")) { out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/2.5.0/cordova-2.5.0.js\"></script>"); } else if (isPhoneGap("2.6.0")) { out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/2.6.0/cordova-2.6.0.js\"></script>"); } else if (isPhoneGap("2.7.0")) { out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/2.7.0/cordova-2.7.0.js\"></script>"); } else if (isPhoneGap("2.8.1")) { out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/2.8.1/cordova.js\"></script>"); } } else if (isPlatform(Device.TYPE_ANDROID)) { if (isPhoneGap("2.2.0")) { out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/android/2.2.0/cordova-2.2.0.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/android/2.2.0/childbrowser.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/android/2.2.0/barcodescanner.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/android/2.2.0/statusbarnotification.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/android/2.2.0/datePickerPlugin.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/android/2.2.0/applicationPreferences.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/android/2.2.0/AudioStreamer.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/android/2.2.0/GCMPlugin.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/android/2.2.0/CORDOVA_GCM_script.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/android/PushHandler.js\"></script>"); } else { out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/android/phonegap-" + getPhonegap() + ".js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/android/childbrowser.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/android/barcodescanner.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/android/statusbarnotification.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/android/C2DMPlugin.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/android/PG_C2DM_script.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/android/PushHandler.js\"></script>"); } } else if (isPlatform(Device.TYPE_BLACKBERRY)) { if (isPhoneGap("2.2.0")) { out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/blackberry/2.2.0/cordova-2.2.0.js\"></script>"); out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/blackberry/2.2.0/kme-application.js\"></script>"); } } else if (isPlatform(Device.TYPE_WINDOWS)) { if (isPhoneGap("2.2.0")) { out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/windowsMobile/2.2.0/cordova-2.2.0.js\"></script>"); } } /* Google Analytics */ String profileId = coreService.findGoogleAnalyticsProfileId().trim(); if (!disableGoogleAnalytics && profileId.length() > 0) { String profileDomain = coreService.getGoogleAnalyticsProfileDomain().trim(); if (coreService.isGoogleUniversalAnalytics() && !profileDomain.isEmpty()) { out.println("<script type=\"text/javascript\">"); out.println("(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){"); out.println("(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),"); out.println("m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)"); out.println("})(window,document,'script','//www.google-analytics.com/analytics.js','ga');"); out.println("ga('create', '" + profileId + "', '" + profileDomain + "'); "); out.println("ga('send', 'pageview');"); out.println("</script>"); } else { out.println("<script type=\"text/javascript\">"); out.println("var _gaq = _gaq || [];"); out.println("_gaq.push(['_setAccount', '" + profileId + "']);"); out.println("_gaq.push(['_trackPageview']);"); out.println("(function() {"); out.println( "var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;"); out.println( "ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';"); out.println( "var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);"); out.println("})();"); out.println("</script>"); } } if (isUsesGoogleMaps()) { if (getMapLocale() != null) { out.println( "<script type=\"text/javascript\" src=\"https://maps.google.com/maps/api/js?sensor=true&language=" + getMapLocale() + "\"></script>"); } else { out.println( "<script type=\"text/javascript\" src=\"https://maps.google.com/maps/api/js?sensor=true\"></script>"); } } // Now add all the javascripts for (String javascript : getJsFilenames()) { out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/" + javascript + ".js\"></script>"); } out.println( "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\">"); // out.println("<meta name=\"apple-mobile-web-app-capable\" content=\"yes\" />"); // out.println("<meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black\" />"); out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"); out.println("</head>"); if (getOnBodyLoad() != null) { out.println("<body onload='" + getOnBodyLoad() + "'>"); } else { out.println("<body>"); } out.println("<div data-role=\"page\" id=\"" + getId() + "\">"); LOG.info("----" + jqmHeader); if (getJqmHeader() != null && getJqmHeader().equals("hide")) { LOG.info("---- Hide Header"); out.println("<div data-role=\"header\" style=\"display:none\">"); } else if (getJqmHeader() != null && getJqmHeader().equals("fixed")) { LOG.info("---- Fixed Header"); out.println("<div data-role=\"header\" data-position=\"fixed\">"); } else { LOG.info("---- Show Header"); out.println("<div data-role=\"header\">"); } if (isLoginButton() || getAuthMapper().getLoginURL() != null) { if (user == null || user.isPublicUser()) { msgCatString = ms.getMessage("shared.login", null, "Login", locale); out.println("<a href=\"" + (getLoginButtonURL() != null ? getLoginButtonURL() : (getAuthMapper().getLoginURL() != null ? getAuthMapper().getLoginURL() : contextPath + "/login")) + "\" data-role=\"button\" data-icon=\"lock\">" + msgCatString + "</a>"); } else { msgCatString = ms.getMessage("shared.logout", null, "Logout", locale); out.println("<a href=\"" + (getLogoutButtonURL() != null ? getLogoutButtonURL() : (getAuthMapper().getLogoutURL() != null ? getAuthMapper().getLogoutURL() : contextPath + "/logout")) + "\" data-role=\"button\" data-icon=\"unlock\">" + msgCatString + "</a>"); } } if (isBackButton()) { msgCatString = ms.getMessage("shared.back", null, "Back", locale); // out.println("<a href=\"" + (getBackButtonURL() != null ? getBackButtonURL() : "javascript: history.go(-1)") + "\" class=\"ui-btn-left\" data-icon=\"back\" data-iconpos=\"notext\">" + msgCatString + "</a>"); boolean showButton = true; if (null == this.getPhonegap() || "".equalsIgnoreCase(getPhonegap())) { // showButton = true; } else { if (null != kmeProperties) { StringBuilder builder = new StringBuilder("shim.backbutton."); builder.append(this.getPlatform().toLowerCase()); if (kmeProperties.containsKey(builder.toString()) && "false".equalsIgnoreCase(kmeProperties.getProperty(builder.toString()))) { showButton = false; } } } if (showButton) { out.println("<a href=\"" + ((getBackButtonURL() != null && StringUtils.isNotBlank(getBackButtonURL())) ? getBackButtonURL() : "javascript: history.go(-1)") + "\" class=\"ui-btn-left\" data-icon=\"back\" data-iconpos=\"notext\">" + msgCatString + "</a>"); } } out.println("<h1>" + getTitle() + "</h1>"); if (isPreferencesButton()) { if (null != kmeProperties && "true".equalsIgnoreCase(kmeProperties.getProperty("home.preferences.enabled", "true"))) { msgCatString = ms.getMessage("shared.preferences", null, "Preferences", locale); out.println("<a href=\"" + (getPreferencesButtonURL() != null ? getPreferencesButtonURL() : contextPath + "/preferences") + "\" class=\"ui-btn-right\" data-icon=\"gear\" data-iconpos=\"notext\">" + msgCatString + "</a>"); } } if (isHomeButton()) { msgCatString = ms.getMessage("shared.home", null, "Home", locale); // out.println("<a href=\"" + contextPath + "/home\" class=\"ui-btn-right\" data-icon=\"home\" data-iconpos=\"notext\">" + msgCatString + "</a>"); boolean homeButton = true; if (null == this.getPhonegap() || "".equalsIgnoreCase(getPhonegap())) { // showButton = true; } else { if (null != kmeProperties) { StringBuilder builder = new StringBuilder("shim.homebutton."); builder.append(this.getPlatform().toLowerCase()); if (kmeProperties.containsKey(builder.toString()) && "false".equalsIgnoreCase(kmeProperties.getProperty(builder.toString()))) { homeButton = false; } } } if (homeButton) { out.println("<a href=\"" + contextPath + "/home\" class=\"ui-btn-right\" data-icon=\"home\" data-iconpos=\"notext\">" + msgCatString + "</a>"); } } out.println("</div>"); getJspBody().invoke(out); out.println("</div>"); out.println("</body>"); out.println("</html>"); } catch (Exception e) { LOG.error(e.getMessage(), e); } }
From source file:org.broadleafcommerce.core.web.catalog.taglib.SearchFilterItemTag.java
private void doProductMultiSelect(JspWriter out, List<Product> products) throws JspException, IOException { BeanToPropertyValueTransformer valueTransformer = new BeanToPropertyValueTransformer(property, true); BeanToPropertyValueTransformer displayTransformer; if (propertyDisplay != null) { displayTransformer = new BeanToPropertyValueTransformer(propertyDisplay, true); } else {//from w w w .ja v a 2 s . co m displayTransformer = valueTransformer; } HashMap<Object, Integer> countMap = new HashMap<Object, Integer>(); HashMap<Object, Object> valueDisplayMap = new HashMap<Object, Object>(); for (Product product : products) { Object value = valueTransformer.transform(product); Object display = displayTransformer.transform(product); valueDisplayMap.put(value, display); Integer integer = countMap.get(value); if (integer == null) { countMap.put(value, new Integer(1)); } else { countMap.put(value, new Integer(integer + 1)); } } String propertyCss = property.replaceAll("[\\.\\[\\]]", "_"); out.println("<ul class='searchFilter-" + propertyCss + "'>"); for (Object value : countMap.keySet()) { Object display = valueDisplayMap.get(value); out.println("<li value='" + value + "'><input type=\"checkbox\" class=\"searchFilter-" + propertyCss + "Checkbox\" name=\"" + property + "\" value=\"" + value + "\"/> " + "<span class='searchFilter-" + propertyCss + "Display'>" + display + "</span>" + " <span class='searchFilter" + propertyCss + "-count'>(" + countMap.get(value).toString() + ")</span></li>"); } out.println("</ul>"); out.println("<script>" + " var " + propertyCss + "Checked = 0;\r\n" + " $('.searchFilter-" + propertyCss + "Checkbox').click(function() {\r\n " + " var value = $(this).attr('value');\r\n" + " var checkbox = $(this).find(':checkbox');\r\n" + " if (" + propertyCss + "Checked == 0) {\r\n" + " $('.searchFilter-" + propertyCss + " li').each(function(){$(this).addClass('searchFilterDisabledSelect')});\r\n" + " $(this).removeClass('searchFilterDisabledSelect');\r\n" + " checkbox.attr('checked',true);\r\n" + " " + propertyCss + "Checked++;\r\n" + " } else if (checkbox.attr('checked') == true) {\r\n" + " $(this).addClass('searchFilterDisabledSelect');\r\n" + " if (" + propertyCss + "Checked == 1) {\r\n" + " // unchecking the only checked category, so reactivate all categories\r\n" + " $('.searchFilter-" + propertyCss + " li').each(function(){$(this).removeClass('searchFilterDisabledSelect')});\r\n" + " } \r\n" + " checkbox.attr('checked',false);\r\n" + " " + propertyCss + "Checked--;\r\n" + " } else {\r\n" + " $(this).removeClass('searchFilterDisabledSelect');\r\n" + " checkbox.attr('checked',true);\r\n" + " " + propertyCss + "Checked++;\r\n" + " }\r\n" + " updateSearchFilterResults();\r\n" + " } );" + " $('.searchFilter-" + propertyCss + "Display').click(function() {\r\n " + " var value = $(this).attr('value');\r\n" + " var liObj = $(this).parent(); \r\n" + " var checkbox = liObj.find(':checkbox');\r\n" + " if (" + propertyCss + "Checked == 0) {\r\n" + " $('.searchFilter-" + propertyCss + " li').each(function(){liObj.addClass('searchFilterDisabledSelect')});\r\n" + " liObj.removeClass('searchFilterDisabledSelect');\r\n" + " checkbox.attr('checked',true);\r\n" + " " + propertyCss + "Checked++;\r\n" + " } else if (checkbox.attr('checked') == true) {\r\n" + " liObj.addClass('searchFilterDisabledSelect');\r\n" + " if (" + propertyCss + "Checked == 1) {\r\n" + " // unchecking the only checked category, so reactivate all categories\r\n" + " $('.searchFilter-" + propertyCss + " li').each(function(){liObj.removeClass('searchFilterDisabledSelect')});\r\n" + " } \r\n" + " checkbox.attr('checked',false);\r\n" + " " + propertyCss + "Checked--;\r\n" + " } else {\r\n" + " liObj.removeClass('searchFilterDisabledSelect');\r\n" + " checkbox.attr('checked',true);\r\n" + " " + propertyCss + "Checked++;\r\n" + " }\r\n" + " updateSearchFilterResults();\r\n" + " } );" + "</script>"); }
From source file:com.redhat.rhn.frontend.taglibs.ListDisplayTag.java
private void renderExport(JspWriter out) throws IOException { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); StringBuilder page = new StringBuilder((String) request.getAttribute("requestedUri")); page.append("?" + RequestContext.LIST_DISPLAY_EXPORT + "=1"); if (request.getQueryString() != null) { page.append("&" + request.getQueryString()); }/* ww w. jav a2s . c om*/ IconTag i = new IconTag("item-download-csv"); out.println("<div class=\"spacewalk-csv-download\"><a href=\"" + page + "\">" + i.render() + LocalizationService.getInstance().getMessage("listdisplay.csv") + "</a></div>"); }
From source file:org.dspace.app.webui.jsptag.ItemTag.java
/** * Render an item in the given style/* ww w . j a v a 2s .com*/ */ private void render() throws IOException, SQLException, DCInputsReaderException { JspWriter out = pageContext.getOut(); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); Context context = UIUtil.obtainContext(request); Locale sessionLocale = UIUtil.getSessionLocale(request); String configLine = styleSelection.getConfigurationForStyle(style); if (configLine == null) { configLine = defaultFields; } out.println("<center><table class=\"itemDisplayTable\">"); /* * Break down the configuration into fields and display them * * FIXME?: it may be more efficient to do some processing once, perhaps * to a more efficient intermediate class, but then it would become more * difficult to reload the configuration "on the fly". */ StringTokenizer st = new StringTokenizer(configLine, ","); while (st.hasMoreTokens()) { String field = st.nextToken().trim(); boolean isDate = false; boolean isLink = false; boolean isResolver = false; boolean isNoBreakLine = false; boolean isDisplay = false; String style = null; Matcher fieldStyleMatcher = fieldStylePatter.matcher(field); if (fieldStyleMatcher.matches()) { style = fieldStyleMatcher.group(1); } String browseIndex; try { browseIndex = getBrowseField(field); } catch (BrowseException e) { log.error(e); browseIndex = null; } // Find out if the field should rendered with a particular style if (style != null) { isDate = style.contains("date"); isLink = style.contains("link"); isNoBreakLine = style.contains("nobreakline"); isDisplay = style.equals("inputform"); isResolver = style.contains("resolver") || urn2baseurl.keySet().contains(style); field = field.replaceAll("\\(" + style + "\\)", ""); } // Get the separate schema + element + qualifier String[] eq = field.split("\\."); String schema = eq[0]; String element = eq[1]; String qualifier = null; if (eq.length > 2 && eq[2].equals("*")) { qualifier = Item.ANY; } else if (eq.length > 2) { qualifier = eq[2]; } // check for hidden field, even if it's configured.. if (MetadataExposure.isHidden(context, schema, element, qualifier)) { continue; } // FIXME: Still need to fix for metadata language? DCValue[] values = item.getMetadata(schema, element, qualifier, Item.ANY); if (values.length > 0) { out.print("<tr><td class=\"metadataFieldLabel\">"); String label = null; try { label = I18nUtil.getMessage("metadata." + (style != null ? style + "." : "") + field, context); } catch (MissingResourceException e) { // if there is not a specific translation for the style we // use the default one label = LocaleSupport.getLocalizedMessage(pageContext, "metadata." + field); } out.print(label); out.print(": </td><td class=\"metadataFieldValue\">"); //If the values are in controlled vocabulary and the display value should be shown if (isDisplay) { List<String> displayValues = new ArrayList<String>(); displayValues = Util.getControlledVocabulariesDisplayValueLocalized(item, values, schema, element, qualifier, sessionLocale); if (displayValues != null && !displayValues.isEmpty()) { for (int d = 0; d < displayValues.size(); d++) { out.print(displayValues.get(d)); if (d < displayValues.size() - 1) out.print(" <br/>"); } } out.print("</td>"); continue; } for (int j = 0; j < values.length; j++) { if (values[j] != null && values[j].value != null) { if (j > 0) { if (isNoBreakLine) { String separator = ConfigurationManager .getProperty("webui.itemdisplay.nobreakline.separator"); if (separator == null) { separator = "; "; } out.print(separator); } else { out.print("<br />"); } } if (isLink) { out.print("<a href=\"" + values[j].value + "\">" + Utils.addEntities(values[j].value) + "</a>"); } else if (isDate) { DCDate dd = new DCDate(values[j].value); // Parse the date out.print(UIUtil.displayDate(dd, false, false, (HttpServletRequest) pageContext.getRequest())); } else if (isResolver) { String value = values[j].value; if (value.startsWith("http://") || value.startsWith("https://") || value.startsWith("ftp://") || value.startsWith("ftps://")) { // Already a URL, print as if it was a regular link out.print("<a href=\"" + value + "\">" + Utils.addEntities(value) + "</a>"); } else { String foundUrn = null; if (!style.equals("resolver")) { foundUrn = style; } else { for (String checkUrn : urn2baseurl.keySet()) { if (value.startsWith(checkUrn)) { foundUrn = checkUrn; } } } if (foundUrn != null) { if (value.startsWith(foundUrn + ":")) { value = value.substring(foundUrn.length() + 1); } String url = urn2baseurl.get(foundUrn); out.print("<a href=\"" + url + value + "\">" + Utils.addEntities(values[j].value) + "</a>"); } else { out.print(value); } } } else if (browseIndex != null) { String argument, value; if (values[j].authority != null && values[j].confidence >= MetadataAuthorityManager .getManager() .getMinConfidence(values[j].schema, values[j].element, values[j].qualifier)) { argument = "authority"; value = values[j].authority; } else { argument = "value"; value = values[j].value; } out.print("<a class=\"" + ("authority".equals(argument) ? "authority " : "") + browseIndex + "\"" + "href=\"" + request.getContextPath() + "/browse?type=" + browseIndex + "&" + argument + "=" + URLEncoder.encode(value, "UTF-8") + "\">" + Utils.addEntities(values[j].value) + "</a>"); } else { out.print(Utils.addEntities(values[j].value)); } } } out.println("</td></tr>"); } } listCollections(); out.println("</table></center><br/>"); listBitstreams(); if (ConfigurationManager.getBooleanProperty("webui.licence_bundle.show")) { out.println("<br/><br/>"); showLicence(); } }
From source file:com.redhat.rhn.frontend.taglibs.UnpagedListDisplayTag.java
/** {@inheritDoc} */ public int doEndTag() throws JspException { JspWriter out = null; try {/*from ww w . j a va 2 s.c om*/ if (getPageList().isEmpty()) { return EVAL_PAGE; } if (isExport()) { ExportWriter eh = createExportWriter(); String[] columns = StringUtils.split(this.getExportColumns(), ','); eh.setColumns(Arrays.asList(columns)); ServletExportHandler seh = new ServletExportHandler(eh); pageContext.getOut().clear(); pageContext.getOut().clearBuffer(); pageContext.getResponse().reset(); seh.writeExporterToOutput((HttpServletResponse) pageContext.getResponse(), getPageList()); return SKIP_PAGE; } // Get the JSPWriter that the body used, then pop the // bodyContent, so that we can get the real JspWriter with getOut. BodyContent body = getBodyContent(); pageContext.popBody(); out = pageContext.getOut(); if (body != null) { String bodyString = body.getString(); out.println(bodyString); } // Rely on content to have emitted a tbody tag somewhere out.println("</tbody>"); out.println("</table>\n"); out.println("</div>\n"); out.println("</div>\n"); setNumberOfColumns(0); setColumnCount(0); setCurrRow(0); } catch (IOException e) { throw new JspException("IO error" + e.getMessage()); } finally { pageContext.setAttribute("current", null); } return EVAL_PAGE; }
From source file:org.opencms.setup.CmsUpdateBean.java
/** * Generates the output for step 1 of the setup wizard.<p> * //from ww w. j a va2s.c om * @param out the JSP print stream * @throws IOException in case errors occur while writing to "out" */ public void prepareUpdateStep1bOutput(JspWriter out) throws IOException { m_oldLoggingDBOffset = m_newLoggingDBOffset; m_newLoggingDBOffset = m_dbUpdateThread.getLoggingThread().getMessages().size(); if (isInitialized()) { for (int i = m_oldLoggingDBOffset; i < m_newLoggingDBOffset; i++) { String str = m_dbUpdateThread.getLoggingThread().getMessages().get(i).toString(); str = CmsEncoder.escapeWBlanks(str, CmsEncoder.ENCODING_UTF_8); out.println("output[" + (i - m_oldLoggingDBOffset) + "] = \"" + str + "\";"); } } else { out.println("output[0] = 'ERROR';"); } boolean threadFinished = m_dbUpdateThread.isFinished(); boolean allWritten = m_oldLoggingDBOffset >= m_dbUpdateThread.getLoggingThread().getMessages().size(); out.println("function initThread() {"); if (isInitialized()) { out.print("send();"); if (threadFinished && allWritten) { out.println("setTimeout('top.display.finish()', 1000);"); } else { int timeout = 5000; if (getUpdateDBThread().getLoggingThread().getMessages().size() < 20) { timeout = 2000; } out.println("setTimeout('location.reload()', " + timeout + ");"); } } out.println("}"); }
From source file:com.redhat.rhn.frontend.taglibs.ListDisplayTag.java
/** {@inheritDoc} */ @Override/*from w w w . j a v a 2s .co m*/ public int doStartTag() throws JspException { rowCnt = 0; numItemsChecked = 0; JspWriter out = null; showSetButtons = false; try { out = pageContext.getOut(); setupPageList(); // Now that we have setup the proper tag state we // need to return if this is an export render. if (isExport()) { return SKIP_PAGE; } String sortedColumn = getSortedColumn(); if (sortedColumn != null) { doSort(sortedColumn); } out.print("<div class=\"spacewalk-list "); out.println(type + "\""); if (tableId != null) { out.print(" id=\"" + tableId + "\""); } out.println(">"); /* * If pageList contains an index and pageList.size() (what we are * displaying on the page) is less than pageList.getTotalSize() (the * total number of items in the data result), render alphabar. This * prevents the alphabar from showing up on pages that show all of * the entries on a single page and is similar to how the perl code * behaves. */ StringWriter alphaBarContent = new StringWriter(); StringWriter paginationContent = new StringWriter(); pageContext.pushBody(alphaBarContent); if (getPageList().getIndex().size() > 0 && getPageList().size() < getPageList().getTotalSize()) { //renderViewAllLink(alphaBarContent); renderAlphabar(alphaBarContent); } pageContext.popBody(); pageContext.pushBody(paginationContent); if (isPaging()) { renderPagination(paginationContent, true); renderBoundsVariables(paginationContent); } pageContext.popBody(); int topAddonsContentLen = alphaBarContent.getBuffer().length() + paginationContent.getBuffer().length(); if (topAddonsContentLen > 0) { out.println("<div class=\"spacewalk-list-top-addons\">"); out.println("<div class=\"spacewalk-list-alphabar\">"); out.print(alphaBarContent.getBuffer().toString()); out.println("</div>"); out.print(paginationContent.getBuffer().toString()); out.println("</div>"); } out.print("<div class=\"panel panel-default\">"); renderPanelHeading(out); out.print("<table class=\"table table-striped\">"); // we render the pagination controls as an additional head out.println("<thead>"); out.println("\n<tr>"); if (getIterator() != null && getIterator().hasNext()) { // Push a new BodyContent writer onto the stack so that // we can buffer the body data. bodyContent = pageContext.pushBody(); return EVAL_BODY_INCLUDE; } return SKIP_BODY; } catch (IOException ioe) { throw new JspException("IO error writing to JSP file:", ioe); } }
From source file:com.redhat.rhn.frontend.taglibs.UnpagedListDisplayTag.java
/** {@inheritDoc} */ public int doStartTag() throws JspException { rowCnt = 0;//w w w. j a va 2 s .com JspWriter out = null; try { out = pageContext.getOut(); setupPageList(); // Now that we have setup the proper tag state we // need to return if this is an export render. if (isExport()) { return SKIP_PAGE; } String sortedColumn = getSortedColumn(); if (sortedColumn != null) { doSort(sortedColumn); } out.print("<div class=\"spacewalk-list\">"); out.print("<div class=\"panel panel-default\">"); renderPanelHeading(out); /* If the type is list, we must set the width explicitly. Otherwise, * it shouldn't matter */ if (getType().equals("list")) { out.print("<table class=\"table table-striped\""); } else if (getType().equals("treeview")) { out.print("<table class=\"table table-striped\" id=\"channel-list\""); } else { out.print("<table class=\"" + getType() + "\""); } /*if (isTransparent()) { out.print(" style=\"border-bottom: 1px solid #ffffff;\" "); }*/ out.println(">"); out.println("<thead>"); out.println("<tr>"); if (getIterator() != null && getIterator().hasNext()) { // Push a new BodyContent writer onto the stack so that // we can buffer the body data. bodyContent = pageContext.pushBody(); return EVAL_BODY_INCLUDE; } return SKIP_BODY; } catch (IOException ioe) { throw new JspException("IO error writing to JSP file:", ioe); } }