Author: doogie
Date: Mon Jun 29 17:00:44 2009 New Revision: 789384 URL: http://svn.apache.org/viewvc?rev=789384&view=rev Log: Some more string optimizations. Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRendererImage.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java?rev=789384&r1=789383&r2=789384&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java Mon Jun 29 17:00:44 2009 @@ -166,7 +166,7 @@ if (UtilValidate.isNotEmpty(style) || UtilValidate.isNotEmpty(alignStyle)) { writer.append(" class=\""); if (UtilValidate.isNotEmpty(style)) { - writer.append(style + " "); + writer.append(style).append(" "); } if (UtilValidate.isNotEmpty(alignStyle)) { writer.append(alignStyle); @@ -175,7 +175,7 @@ } String toolTip = menuItem.getTooltip(context); if (UtilValidate.isNotEmpty(toolTip)) { - writer.append(" title=\"" + toolTip + "\""); + writer.append(" title=\"").append(toolTip).append("\""); } writer.append(">"); @@ -242,24 +242,24 @@ writer.append("<div"); String menuId = modelMenu.getId(); if (UtilValidate.isNotEmpty(menuId)) { - writer.append(" id=\"" + menuId + "\""); + writer.append(" id=\"").append(menuId).append("\""); } else { // TODO: Remove else after UI refactor - allow both id and style String menuContainerStyle = modelMenu.getMenuContainerStyle(context); if (UtilValidate.isNotEmpty(menuContainerStyle)) { - writer.append(" class=\"" + menuContainerStyle + "\""); + writer.append(" class=\"").append(menuContainerStyle).append("\""); } } String menuWidth = modelMenu.getMenuWidth(); // TODO: Eliminate embedded styling after refactor if (UtilValidate.isNotEmpty(menuWidth)) { - writer.append(" style=\"width:" + menuWidth + ";\""); + writer.append(" style=\"width:").append(menuWidth).append(";\""); } writer.append(">"); appendWhitespace(writer); String menuTitle = modelMenu.getTitle(context); if (UtilValidate.isNotEmpty(menuTitle)) { - writer.append("<h2>" + menuTitle + "</h2>"); + writer.append("<h2>").append(menuTitle).append("</h2>"); appendWhitespace(writer); } writer.append("<ul>"); @@ -276,7 +276,7 @@ public void renderMenuClose(Appendable writer, Map<String, Object> context, ModelMenu modelMenu) throws IOException { String fillStyle = modelMenu.getFillStyle(); if (UtilValidate.isNotEmpty(fillStyle)) { - writer.append("<div class=\"" + fillStyle + "\"> </div>"); + writer.append("<div class=\"").append(fillStyle).append("\"> </div>"); } //String menuContainerStyle = modelMenu.getMenuContainerStyle(context); writer.append(" </ul>"); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRendererImage.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRendererImage.java?rev=789384&r1=789383&r2=789384&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRendererImage.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRendererImage.java Mon Jun 29 17:00:44 2009 @@ -48,7 +48,7 @@ public String buildDivStr(ModelMenuItem menuItem, Map<String, Object> context) throws IOException { - String imgStr = "<img src=\""; + StringBuilder imgStr = new StringBuilder("<img src=\""); String contentId = menuItem.getAssociatedContentId(context); GenericDelegator delegator = (GenericDelegator)request.getAttribute("delegator"); GenericValue webSitePublishPoint = null; @@ -66,17 +66,15 @@ String medallionLogoStr = webSitePublishPoint.getString("medallionLogo"); StringWriter buf = new StringWriter(); appendContentUrl(buf, medallionLogoStr); - imgStr += buf.toString(); + imgStr.append(buf.toString()); //Debug.logInfo("in HtmlMenuRendererImage, imgStr:" + imgStr,""); String cellWidth = menuItem.getCellWidth(); - imgStr += "\""; - String widthStr = ""; + imgStr.append("\""); if (UtilValidate.isNotEmpty(cellWidth)) - widthStr = " width=\"" + cellWidth + "\" "; + imgStr.append(" width=\"").append(cellWidth).append("\" "); - imgStr += widthStr; - imgStr += " border=\"0\" />"; - return imgStr; + imgStr.append(" border=\"0\" />"); + return imgStr.toString(); } } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java?rev=789384&r1=789383&r2=789384&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java Mon Jun 29 17:00:44 2009 @@ -104,7 +104,7 @@ writer.append("', '"); writer.append(rh.makeLink(request, response, autoUpdateTarget)); writer.append("', '"); - writer.append("', '" + container.getAutoUpdateInterval() + "');</script>"); + writer.append("', '").append(container.getAutoUpdateInterval()).append("');</script>"); appendWhitespace(writer); } writer.append("<div"); @@ -134,11 +134,11 @@ writer.append("<hr"); String className = separator.getStyle(context); if (UtilValidate.isNotEmpty(className)) { - writer.append(" class=\"" + className + "\""); + writer.append(" class=\"").append(className).append("\""); } String idName = separator.getId(context); if (UtilValidate.isNotEmpty(idName)) { - writer.append(" id=\"" + idName + "\""); + writer.append(" id=\"").append(idName).append("\""); } writer.append("/>"); appendWhitespace(writer); @@ -192,26 +192,26 @@ if (collapsed) { writer.append("collapsed\"><a "); if (javaScriptEnabled) { - writer.append("onclick=\"javascript:toggleScreenlet(this, '" + collapsibleAreaId + "', '" + expandToolTip + "', '" + collapseToolTip + "');\""); + writer.append("onclick=\"javascript:toggleScreenlet(this, '").append(collapsibleAreaId).append("', '").append(expandToolTip).append("', '").append(collapseToolTip).append("');\""); } else { requestParameters.put(screenlet.getPreferenceKey(context) + "_collapsed", "false"); String queryString = UtilHttp.urlEncodeArgs(requestParameters); - writer.append("href=\"" + request.getRequestURI() + "?" + queryString + "\""); + writer.append("href=\"").append(request.getRequestURI()).append("?").append(queryString).append("\""); } if (UtilValidate.isNotEmpty(expandToolTip)) { - writer.append(" title=\"" + expandToolTip + "\""); + writer.append(" title=\"").append(expandToolTip).append("\""); } } else { writer.append("expanded\"><a "); if (javaScriptEnabled) { - writer.append("onclick=\"javascript:toggleScreenlet(this, '" + collapsibleAreaId + "', '" + expandToolTip + "', '" + collapseToolTip + "');\""); + writer.append("onclick=\"javascript:toggleScreenlet(this, '").append(collapsibleAreaId).append("', '").append(expandToolTip).append("', '").append(collapseToolTip).append("');\""); } else { requestParameters.put(screenlet.getPreferenceKey(context) + "_collapsed", "true"); String queryString = UtilHttp.urlEncodeArgs(requestParameters); - writer.append("href=\"" + request.getRequestURI() + "?" + queryString + "\""); + writer.append("href=\"").append(request.getRequestURI()).append("?").append(queryString).append("\""); } if (UtilValidate.isNotEmpty(collapseToolTip)) { - writer.append(" title=\"" + collapseToolTip + "\""); + writer.append(" title=\"").append(collapseToolTip).append("\""); } } writer.append("> </a></li>"); @@ -236,7 +236,7 @@ appendWhitespace(writer); writer.append("<div"); if (UtilValidate.isNotEmpty(collapsibleAreaId)) { - writer.append(" id=\"" + collapsibleAreaId + "\""); + writer.append(" id=\"").append(collapsibleAreaId).append("\""); if (collapsed) { writer.append(" style=\"display: none;\""); } @@ -330,37 +330,37 @@ // The current screenlet title bar navigation syling requires rendering // these links in reverse order // Last button - writer.append("<li class=\"" + modelForm.getPaginateLastStyle()); + writer.append("<li class=\"").append(modelForm.getPaginateLastStyle()); if (highIndex < listSize) { writer.append("\"><a href=\""); int page = (listSize / viewSize) - 1; linkText = prepLinkText + page + anchor; // - make the link writer.append(rh.makeLink(request, response, linkText)); - writer.append("\">" + modelForm.getPaginateLastLabel(context) + "</a>"); + writer.append("\">").append(modelForm.getPaginateLastLabel(context)).append("</a>"); } else { // disabled button - writer.append(" disabled\">" + modelForm.getPaginateLastLabel(context)); + writer.append(" disabled\">").append(modelForm.getPaginateLastLabel(context)); } writer.append("</li>"); appendWhitespace(writer); // Next button - writer.append("<li class=\"" + modelForm.getPaginateNextStyle()); + writer.append("<li class=\"").append(modelForm.getPaginateNextStyle()); if (highIndex < listSize) { writer.append("\"><a href=\""); linkText = prepLinkText + (viewIndex + 1) + anchor; // - make the link writer.append(rh.makeLink(request, response, linkText)); - writer.append("\">" + modelForm.getPaginateNextLabel(context) + "</a>"); + writer.append("\">").append(modelForm.getPaginateNextLabel(context)).append("</a>"); } else { // disabled button - writer.append(" disabled\">" + modelForm.getPaginateNextLabel(context)); + writer.append(" disabled\">").append(modelForm.getPaginateNextLabel(context)); } writer.append("</li>"); appendWhitespace(writer); if (listSize > 0) { writer.append("<li>"); - writer.append((lowIndex + 1) + " - " + (lowIndex + actualPageSize ) + " " + ofLabel + " " + listSize); + writer.append(Integer.toString(lowIndex + 1)).append(" - ").append(Integer.toString(lowIndex + actualPageSize )).append(" ").append(ofLabel).append(" ").append(Integer.toString(listSize)); writer.append("</li>"); appendWhitespace(writer); } @@ -371,10 +371,10 @@ linkText = prepLinkText + (viewIndex - 1) + anchor; // - make the link writer.append(rh.makeLink(request, response, linkText)); - writer.append("\">" + modelForm.getPaginatePreviousLabel(context) + "</a>"); + writer.append("\">").append(modelForm.getPaginatePreviousLabel(context)).append("</a>"); } else { // disabled button - writer.append(" disabled\">" + modelForm.getPaginatePreviousLabel(context)); + writer.append(" disabled\">").append(modelForm.getPaginatePreviousLabel(context)); } writer.append("</li>"); appendWhitespace(writer); @@ -384,9 +384,9 @@ writer.append("\"><a href=\""); linkText = prepLinkText + 0 + anchor; writer.append(rh.makeLink(request, response, linkText)); - writer.append("\">" + modelForm.getPaginateFirstLabel(context) + "</a>"); + writer.append("\">").append(modelForm.getPaginateFirstLabel(context)).append("</a>"); } else { - writer.append(" disabled\">" + modelForm.getPaginateFirstLabel(context)); + writer.append(" disabled\">").append(modelForm.getPaginateFirstLabel(context)); } writer.append("</li>"); appendWhitespace(writer); @@ -642,7 +642,7 @@ if (UtilValidate.isNotEmpty(editRequest) && "true".equals(enableEditValue)) { writer.append("<div"); - writer.append(" class=\"" + editContainerStyle + "\"> "); + writer.append(" class=\"").append(editContainerStyle).append("\"> "); appendWhitespace(writer); } } @@ -735,8 +735,11 @@ ServletContext ctx = (ServletContext) request.getAttribute("servletContext"); RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_"); String urlString = rh.makeLink(request, response, editRequest, false, false, false); - String linkString = "<a href=\"" + urlString + "\">" + editMode + "</a>"; - writer.append(linkString); + writer.append("<a href=\""); + writer.append(rh.makeLink(request, response, editRequest, false, false, false)); + writer.append("\">"); + writer.append(editMode); + writer.append("</a>"); } if (UtilValidate.isNotEmpty(editContainerStyle)) { writer.append("</div>"); @@ -747,25 +750,24 @@ public void renderContentFrame(Appendable writer, Map<String, Object> context, ModelScreenWidget.Content content) throws IOException { - String dataResourceId = content.getDataResourceId(context); -// String urlString = "/content/control/ViewSimpleContent?dataResourceId=" + dataResourceId; - String urlString = "/ViewSimpleContent?dataResourceId=" + dataResourceId; - - String width = content.getWidth(); - String widthString=" width=\"" + width + "\""; - String height = content.getHeight(); - String heightString=" height=\"" + height + "\""; - String border = content.getBorder(); - String borderString = (UtilValidate.isNotEmpty(border)) ? " border=\"" + border + "\"" : ""; HttpServletRequest request = (HttpServletRequest) context.get("request"); HttpServletResponse response = (HttpServletResponse) context.get("response"); if (request != null && response != null) { ServletContext ctx = (ServletContext) request.getAttribute("servletContext"); RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_"); - String fullUrlString = rh.makeLink(request, response, urlString, true, false, false); - String linkString = "<iframe src=\"" + fullUrlString + "\" " + widthString + heightString + borderString + " />"; - writer.append(linkString); + String dataResourceId = content.getDataResourceId(context); +// String urlString = "/content/control/ViewSimpleContent?dataResourceId=" + dataResourceId; + String urlString = "/ViewSimpleContent?dataResourceId=" + dataResourceId; + + writer.append("<iframe src=\"").append(rh.makeLink(request, response, urlString, true, false, false)).append("\" "); + writer.append(" width=\"").append(content.getWidth()).append("\""); + writer.append(" height=\"").append(content.getHeight()).append("\""); + String border = content.getBorder(); + if (UtilValidate.isNotEmpty(border)) { + writer.append(" border=\"").append(border).append("\""); + } + writer.append(" />"); } } @@ -778,7 +780,7 @@ String enableEditValue = (String)context.get(enableEditName); if (UtilValidate.isNotEmpty(editRequest) && "true".equals(enableEditValue)) { writer.append("<div"); - writer.append(" class=\"" + editContainerStyle + "\"> "); + writer.append(" class=\"").append(editContainerStyle).append("\"> "); appendWhitespace(writer); } @@ -869,9 +871,9 @@ */ ServletContext ctx = (ServletContext) request.getAttribute("servletContext"); RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_"); - String urlString = rh.makeLink(request, response, editRequest, false, false, false); - String linkString = "<a href=\"" + urlString + "\">" + editMode + "</a>"; - writer.append(linkString); + writer.append("<a href=\""); + writer.append(rh.makeLink(request, response, editRequest, false, false, false)); + writer.append("\">").append(editMode).append("</a>"); } if (UtilValidate.isNotEmpty(editContainerStyle)) { writer.append("</div>"); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java?rev=789384&r1=789383&r2=789384&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java Mon Jun 29 17:00:44 2009 @@ -228,7 +228,7 @@ WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), link.getParameterList(), link.getPrefix(context), link.getFullPath(), link.getSecure(), link.getEncode(), req, res, context); } else if (prefix != null) { - writer.append(prefix + target); + writer.append(prefix).append(target); } else { writer.append(target); } |
Free forum by Nabble | Edit this page |