From 77190cd4189fa2b37e52a321e162107377a9cca9 Mon Sep 17 00:00:00 2001 From: Ariel Backenroth Date: Fri, 14 Sep 2007 20:32:00 +0000 Subject: [PATCH] Merged V2.1 to HEAD: 6706 Wizard pages more standards compliant git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6790 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../web/ui/common/PanelGenerator.java | 126 ++++++++++-------- .../org/alfresco/web/ui/common/Utils.java | 84 +++++++----- .../web/ui/common/component/UIActionLink.java | 29 ++-- .../web/ui/common/component/UIMenu.java | 15 +-- .../ui/common/component/UIStatusMessage.java | 32 ++--- .../common/renderer/ActionLinkRenderer.java | 42 +++--- .../common/renderer/BreadcrumbRenderer.java | 5 +- .../ui/common/renderer/ModeListRenderer.java | 55 ++++---- .../web/ui/repo/component/UIActions.java | 21 +-- .../web/ui/repo/component/UISidebar.java | 45 +++---- .../web/ui/repo/component/UISimpleSearch.java | 60 ++++----- .../org/alfresco/web/ui/repo/tag/PageTag.java | 117 ++++++++-------- source/web/jsp/parts/breadcrumb.jsp | 16 +-- source/web/jsp/parts/titlebar.jsp | 94 ++++++++----- source/web/jsp/wizard/container.jsp | 51 ++++--- 15 files changed, 403 insertions(+), 389 deletions(-) diff --git a/source/java/org/alfresco/web/ui/common/PanelGenerator.java b/source/java/org/alfresco/web/ui/common/PanelGenerator.java index 71a5617b05..04b5beae7f 100644 --- a/source/java/org/alfresco/web/ui/common/PanelGenerator.java +++ b/source/java/org/alfresco/web/ui/common/PanelGenerator.java @@ -60,26 +60,31 @@ public final class PanelGenerator generatePanelStart(out, contextPath, panel, bgColor, false); } - public static void generatePanelStart(Writer out, String contextPath, String panel, String bgColor, boolean dialog) + public static void generatePanelStart(final Writer out, + final String contextPath, + final String panel, + final String bgColor, + final boolean dialog) throws IOException { - out.write(""); + out.write("_01.gif' width='7' height='7' alt=''/>"); - out.write(""); + out.write("_02.gif' width='7' height='7' alt=''/>"); - out.write(""); + out.write(".gif' width='7' height='7' alt=''/>"); - out.write(""); + out.write("_06.gif' width='7' height='7' alt=''/>"); - out.write(""); + out.write("_07.gif' width='7' height='7' alt=''/>"); - out.write(""); + out.write("_08.gif' width='7' height='7' alt=''/>"); - out.write("
"); + out.write("
"); + out.write(";'>"); } - public static void generatePanelEnd(Writer out, String contextPath, String panel) + public static void generatePanelEnd(final Writer out, + final String contextPath, + final String panel) throws IOException { - out.write("
"); + out.write("_09.gif' width='7' height='7' alt=''/>"); } - public static void generateTitledPanelMiddle(Writer out, String contextPath, String titlePanel, - String contentPanel, String contentBgColor) throws IOException + public static void generateTitledPanelMiddle(final Writer out, + final String contextPath, + final String titlePanel, + final String contentPanel, + final String contentBgColor) + throws IOException { // generate the expanded part, just under the title - out.write(""); + out.write("_06.gif' width='7' height='7' alt=''/>"); - out.write(""); + out.write("_07.gif' width='7' height='7' alt=''/>"); - out.write(""); + out.write("_08.gif' width='7' height='7' alt=''/>"); - out.write(""); + out.write("_09.gif' width='7' height='7' alt=''/>"); - out.write(""); + out.write("; padding-top: 6px;'>"); } - public static void generateExpandedTitledPanelMiddle(Writer out, String contextPath, String titlePanel, - String expandedTitlePanel, String contentPanel, String contentBgColor) throws IOException + public static void generateExpandedTitledPanelMiddle(final Writer out, + final String contextPath, + final String titlePanel, + final String expandedTitlePanel, + final String contentPanel, + final String contentBgColor) + throws IOException { // generate the expanded part, just under the title - out.write(""); + out.write("_06.gif' width='7' height='7' alt=''/>"); - out.write(""); + out.write("_07.gif' width='7' height='7' alt=''/>"); - out.write(""); + out.write("_08.gif' height='7' alt=''/>"); - out.write(""); + out.write("_09.gif' width='7' height='7' alt=''/>"); - out.write(""); + out.write("; padding-top:6px;'>"); } public final static String BGCOLOR_WHITE = "#FFFFFF"; diff --git a/source/java/org/alfresco/web/ui/common/Utils.java b/source/java/org/alfresco/web/ui/common/Utils.java index 634d6fe968..1153e784d1 100644 --- a/source/java/org/alfresco/web/ui/common/Utils.java +++ b/source/java/org/alfresco/web/ui/common/Utils.java @@ -468,7 +468,7 @@ public final class Utils line = reader.readLine(); if (line != null) { - parsedContent.append("
"); + parsedContent.append("
"); } } @@ -898,49 +898,54 @@ public final class Utils * @param height Height in pixels * @param alt Optional alt/title text * @param onclick JavaScript onclick event handler code - * @param align Optional HTML alignment value + * @param verticalAlign Optional HTML alignment value * * @return Populated img tag */ - public static String buildImageTag(FacesContext context, String image, int width, int height, - String alt, String onclick, String align) + public static String buildImageTag(final FacesContext context, + final String image, + final int width, + final int height, + String alt, + final String onclick, + final String verticalAlign) { StringBuilder buf = new StringBuilder(200); - - buf.append("Utils.encode(alt);'); - + buf.append(" style='").append(style).append("'/>"); return buf.toString(); } @@ -983,35 +988,42 @@ public final class Utils * @param context FacesContext * @param image The local image path from the web folder with leading slash '/' * @param alt Optional alt/title text - * @param align Optional HTML alignment value + * @param verticalAlign Optional HTML alignment value * * @return Populated img tag */ - public static String buildImageTag(FacesContext context, String image, String alt, String align) + public static String buildImageTag(final FacesContext context, + final String image, + String alt, + final String verticalAlign) { - StringBuilder buf = new StringBuilder(128); - - buf.append("Utils.encode(alt);'); + buf.append(" style='").append(style).append("'/>"); return buf.toString(); } diff --git a/source/java/org/alfresco/web/ui/common/component/UIActionLink.java b/source/java/org/alfresco/web/ui/common/component/UIActionLink.java index 570b6f8117..47e12a1d2d 100644 --- a/source/java/org/alfresco/web/ui/common/component/UIActionLink.java +++ b/source/java/org/alfresco/web/ui/common/component/UIActionLink.java @@ -80,16 +80,17 @@ public class UIActionLink extends UICommand */ public Object saveState(FacesContext context) { - Object values[] = new Object[7]; // standard component attributes are saved by the super class - values[0] = super.saveState(context); - values[1] = this.padding; - values[2] = this.image; - values[3] = this.showLink; - values[4] = this.href; - values[5] = this.tooltip; - values[6] = this.target; - return (values); + return new Object[] + { + super.saveState(context), + this.padding, + this.image, + this.showLink, + this.href, + this.tooltip, + this.target + }; } @@ -158,15 +159,7 @@ public class UIActionLink extends UICommand this.padding = (Integer)vb.getValue(getFacesContext()); } - if (this.padding != null) - { - return this.padding.intValue(); - } - else - { - // return default - return 0; - } + return this.padding != null ? this.padding.intValue() : 0; } /** diff --git a/source/java/org/alfresco/web/ui/common/component/UIMenu.java b/source/java/org/alfresco/web/ui/common/component/UIMenu.java index ac88d045b9..212a6842f1 100644 --- a/source/java/org/alfresco/web/ui/common/component/UIMenu.java +++ b/source/java/org/alfresco/web/ui/common/component/UIMenu.java @@ -54,7 +54,7 @@ public class UIMenu extends SelfRenderingComponent */ public void encodeBegin(FacesContext context) throws IOException { - if (isRendered() == false) + if (!isRendered()) { return; } @@ -81,7 +81,7 @@ public class UIMenu extends SelfRenderingComponent // output image if (getAttributes().get("image") != null) { - out.write(Utils.buildImageTag(context, (String)getAttributes().get("image"), null, "absmiddle")); + out.write(Utils.buildImageTag(context, (String)getAttributes().get("image"), null, "middle")); } out.write(""); @@ -92,7 +92,7 @@ public class UIMenu extends SelfRenderingComponent // NOTE: the use of "*width:0px" is an IE6/7 specific hack to ensure that the CSS is processed // only by IE (which needs the width value) and _not_ FireFox which doesn't...! out.write("' style=\"position:absolute;display:none;padding-left:2px;*width:0px\">"); - out.write("
"); + out.write("
"); String field = getHiddenFieldName(); String leftValue = getClientId(context) + NamingContainer.SEPARATOR_CHAR + Integer.toString(ACTION_PREVIOUS); String leftOnclick = Utils.generateFormSubmit(context, this, field, leftValue); - out.write(Utils.buildImageTag(context, WebResources.IMAGE_MOVELEFT, 12, 12, null, leftOnclick, "absmiddle")); - out.write(""); + out.write(Utils.buildImageTag(context, WebResources.IMAGE_MOVELEFT, 12, 12, null, leftOnclick, "middle")); + out.write(""); // get messages for the component and crop the stack to the maximum history size Iterator msgIterator = context.getMessages(STATUS_MESSAGE); @@ -166,7 +166,7 @@ public class UIStatusMessage extends SelfRenderingComponent style = CSS_WARNING; } - out.write(Utils.buildImageTag(context, icon, null, "absmiddle")); + out.write(Utils.buildImageTag(context, icon, null, "middle")); out.write(" "); @@ -179,14 +179,14 @@ public class UIStatusMessage extends SelfRenderingComponent // Next Message icon image - clicking shows next message String rightValue = getClientId(context) + NamingContainer.SEPARATOR_CHAR + Integer.toString(ACTION_NEXT); String rightOnclick = Utils.generateFormSubmit(context, this, field, rightValue); - out.write(Utils.buildImageTag(context, WebResources.IMAGE_MOVERIGHT, 12, 12, null, rightOnclick, "absmiddle")); + out.write(Utils.buildImageTag(context, WebResources.IMAGE_MOVERIGHT, 12, 12, null, rightOnclick, "middle")); out.write("
"); if (panel != null) { PanelGenerator.generatePanelEnd(out, - context.getExternalContext().getRequestContextPath(), - panel); + context.getExternalContext().getRequestContextPath(), + panel); } } diff --git a/source/java/org/alfresco/web/ui/common/renderer/ActionLinkRenderer.java b/source/java/org/alfresco/web/ui/common/renderer/ActionLinkRenderer.java index b3ca689c7d..dfc83485b2 100644 --- a/source/java/org/alfresco/web/ui/common/renderer/ActionLinkRenderer.java +++ b/source/java/org/alfresco/web/ui/common/renderer/ActionLinkRenderer.java @@ -133,7 +133,7 @@ public class ActionLinkRenderer extends BaseRenderer if (padding != 0) { // TODO: make this width value a property! - out.write("
"); + out.write(""); } - out.write("
"); } // if we are not show the text link, then the image is the clickable element @@ -142,7 +142,7 @@ public class ActionLinkRenderer extends BaseRenderer renderActionLinkAnchor(context, out, link); } - out.write(Utils.buildImageTag(context, image, (String)link.getValue(), "absmiddle")); + out.write(Utils.buildImageTag(context, image, (String)link.getValue(), "middle")); if (link.getShowLink() == false) { @@ -152,9 +152,9 @@ public class ActionLinkRenderer extends BaseRenderer { if (padding != 0) { - out.write(""); } // else the text is the clickable element @@ -183,10 +183,12 @@ public class ActionLinkRenderer extends BaseRenderer * @param context * @param link */ - private void renderActionLinkAnchor(FacesContext context, Writer out, UIActionLink link) + private void renderActionLinkAnchor(final FacesContext context, + final Writer out, + final UIActionLink link) throws IOException { - Map attrs = link.getAttributes(); + final Map attrs = link.getAttributes(); // generate the href link - output later in the process depending on various rendering options if (link.getHref() == null) @@ -202,7 +204,11 @@ public class ActionLinkRenderer extends BaseRenderer { // generate JavaScript to set a hidden form field and submit // a form which request attributes that we can decode - out.write(Utils.generateFormSubmit(context, link, Utils.getActionHiddenFieldName(context, link), link.getClientId(context), getParameterComponents(link))); + out.write(Utils.generateFormSubmit(context, + link, + Utils.getActionHiddenFieldName(context, link), + link.getClientId(context), + getParameterComponents(link))); } out.write('"'); @@ -227,31 +233,32 @@ public class ActionLinkRenderer extends BaseRenderer // output href 'target' attribute if supplied if (link.getTarget() != null) { - out.write(" target=\""); + out.write(" target='"); out.write(link.getTarget()); - out.write("\""); + out.write("'"); } } // common link attributes if (attrs.get("id") != null) { - out.write(" id=\""); + out.write(" id='"); out.write((String)attrs.get("id")); - out.write("\""); + out.write("'"); } boolean appliedStyle = false; if (attrs.get("style") != null) { - out.write(" style=\""); + out.write(" style='"); out.write((String)attrs.get("style")); - out.write('"'); + out.write("'"); appliedStyle = true; } if (attrs.get("styleClass") != null) { - out.write(" class="); + out.write(" class='"); out.write((String)attrs.get("styleClass")); + out.write("'"); appliedStyle = true; } if (appliedStyle == false && link.getShowLink() == true && link.getImage() != null && link.getPadding() == 0) @@ -261,9 +268,9 @@ public class ActionLinkRenderer extends BaseRenderer } if (link.getTooltip() != null) { - out.write(" title=\""); + out.write(" title='"); out.write(Utils.encode(link.getTooltip())); - out.write('"'); + out.write("'"); } out.write('>'); } @@ -376,8 +383,9 @@ public class ActionLinkRenderer extends BaseRenderer } if (attrs.get("styleClass") != null) { - out.write(" class="); + out.write(" class=\""); out.write((String)attrs.get("styleClass")); + out.write('"'); } out.write('>'); out.write(Utils.encode(link.getValue().toString())); diff --git a/source/java/org/alfresco/web/ui/common/renderer/BreadcrumbRenderer.java b/source/java/org/alfresco/web/ui/common/renderer/BreadcrumbRenderer.java index 0ed43f74d9..02ae143a9d 100644 --- a/source/java/org/alfresco/web/ui/common/renderer/BreadcrumbRenderer.java +++ b/source/java/org/alfresco/web/ui/common/renderer/BreadcrumbRenderer.java @@ -134,8 +134,9 @@ public class BreadcrumbRenderer extends BaseRenderer } if (bc.getAttributes().get("styleClass") != null) { - buf.append(" class=") - .append(bc.getAttributes().get("styleClass")); + buf.append(" class=\"") + .append(bc.getAttributes().get("styleClass")) + .append('"'); } if (bc.getAttributes().get("tooltip") != null) { diff --git a/source/java/org/alfresco/web/ui/common/renderer/ModeListRenderer.java b/source/java/org/alfresco/web/ui/common/renderer/ModeListRenderer.java index 566d324266..8bd3d219d3 100644 --- a/source/java/org/alfresco/web/ui/common/renderer/ModeListRenderer.java +++ b/source/java/org/alfresco/web/ui/common/renderer/ModeListRenderer.java @@ -87,17 +87,17 @@ public class ModeListRenderer extends BaseRenderer Map attrs = list.getAttributes(); - if (list.isMenu() == false) + if (!list.isMenu()) { // start outer table container the list items - out.write("'); // horizontal rendering outputs a single row with each item as a column cell - if (list.isHorizontal() == true) + if (list.isHorizontal()) { out.write(""); } @@ -107,21 +107,21 @@ public class ModeListRenderer extends BaseRenderer { // each row is an inner table with a single row and 2 columns // first column contains an icon if present, second column contains text - if (list.isHorizontal() == false) + if (!list.isHorizontal()) { out.write(""); } - out.write(""); - if (list.isHorizontal() == false) + if (!list.isHorizontal()) { out.write(""); } @@ -142,12 +142,12 @@ public class ModeListRenderer extends BaseRenderer { // render as a pop-up menu // TODO: show the image set for the individual item if available? - out.write("
"); // output icon column if (list.getIconColumnWidth() != 0) { - out.write(""); + out.write(""); } // output title label @@ -132,7 +132,7 @@ public class ModeListRenderer extends BaseRenderer out.write(Utils.encode(list.getLabel())); out.write("
"); + out.write("
"); String selectedImage = (String)attrs.get("selectedImage"); if (selectedImage != null) { out.write(""); } @@ -177,7 +177,7 @@ public class ModeListRenderer extends BaseRenderer UIListItem item = (UIListItem)iter.next(); // if selected render as the label - if (item.getValue().equals(list.getValue()) == true) + if (item.getValue().equals(list.getValue())) { label = item.getLabel(); break; @@ -185,13 +185,13 @@ public class ModeListRenderer extends BaseRenderer } } } - else if (child instanceof UIListItem && child.isRendered() == true) + else if (child instanceof UIListItem && child.isRendered()) { // found a valid UIListItem child to render UIListItem item = (UIListItem)child; // if selected render as the label - if (item.getValue().equals(list.getValue()) == true) + if (item.getValue().equals(list.getValue())) { label = item.getLabel(); break; @@ -214,7 +214,7 @@ public class ModeListRenderer extends BaseRenderer // output image if (list.getMenuImage() != null) { - out.write(Utils.buildImageTag(context, list.getMenuImage(), null, "absmiddle")); + out.write(Utils.buildImageTag(context, list.getMenuImage(), null, "middle")); } out.write("
"); - out.write(Utils.buildImageTag(context, selectedImage, null, "absmiddle")); + out.write(Utils.buildImageTag(context, selectedImage, null, "middle")); out.write("
"); @@ -222,10 +222,10 @@ public class ModeListRenderer extends BaseRenderer // output the hidden DIV section to contain the menu item table out.write(""); @@ -333,7 +332,7 @@ public class ModeListRenderer extends BaseRenderer out.write("
"); + out.write("
"); // if the "selectedImage" property is set and this item is selected then show it if (selected == true && selectedImage != null) diff --git a/source/java/org/alfresco/web/ui/repo/component/UIActions.java b/source/java/org/alfresco/web/ui/repo/component/UIActions.java index 51eda4061f..85efcc4872 100644 --- a/source/java/org/alfresco/web/ui/repo/component/UIActions.java +++ b/source/java/org/alfresco/web/ui/repo/component/UIActions.java @@ -599,15 +599,7 @@ public class UIActions extends SelfRenderingComponent this.showLink = (Boolean)vb.getValue(getFacesContext()); } - if (this.showLink != null) - { - return this.showLink.booleanValue(); - } - else - { - // return default - return true; - } + return this.showLink != null ? this.showLink.booleanValue() : true; } /** @@ -631,14 +623,7 @@ public class UIActions extends SelfRenderingComponent this.verticalSpacing = (Integer)vb.getValue(getFacesContext()); } - if (this.verticalSpacing != null) - { - return this.verticalSpacing; - } - else - { - return 0; - } + return this.verticalSpacing != null ? this.verticalSpacing : 0; } /** @@ -667,7 +652,7 @@ public class UIActions extends SelfRenderingComponent */ private static String createUniqueId() { - return "_id_" + Short.toString(++id); + return "id_" + Short.toString(++id); } // ------------------------------------------------------------------------------ diff --git a/source/java/org/alfresco/web/ui/repo/component/UISidebar.java b/source/java/org/alfresco/web/ui/repo/component/UISidebar.java index 759b894e0a..d3cf9b9b44 100644 --- a/source/java/org/alfresco/web/ui/repo/component/UISidebar.java +++ b/source/java/org/alfresco/web/ui/repo/component/UISidebar.java @@ -78,11 +78,8 @@ public class UISidebar extends SelfRenderingComponent @Override public Object saveState(FacesContext context) { - Object values[] = new Object[8]; // standard component attributes are saved by the super class - values[0] = super.saveState(context); - values[1] = this.activePlugin; - return values; + return new Object[] { super.saveState(context), this.activePlugin }; } @SuppressWarnings("unchecked") @@ -93,20 +90,20 @@ public class UISidebar extends SelfRenderingComponent ResponseWriter out = context.getResponseWriter(); - out.write("
"); + out.write("