Author: abelevich
Date: 2011-01-27 05:26:27 -0500 (Thu, 27 Jan 2011)
New Revision: 21258
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableTogglerRendererBase.java
Log:
RF-9725 Sub table toggle control: attributes collapseIcon and expandIcon don't work
-The icon is applied when only one attribute is set.
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableTogglerRendererBase.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableTogglerRendererBase.java 2011-01-27
09:47:10 UTC (rev 21257)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableTogglerRendererBase.java 2011-01-27
10:26:27 UTC (rev 21258)
@@ -98,6 +98,10 @@
}
}
+ private boolean isEmpty(String value) {
+ return (value == null || value.trim().length() == 0);
+ }
+
protected void encodeControl(FacesContext context, ResponseWriter writer,
AbstractCollapsibleSubTableToggler control,
boolean expanded, boolean visible) throws IOException {
String state = getState(expanded);
@@ -114,8 +118,6 @@
writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, styleClass, null);
writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, style, null);
- boolean encodeDefault = true;
-
UIComponent controlFacet = control.getFacet(state);
if (controlFacet != null && controlFacet.isRendered()) {
@@ -125,24 +127,28 @@
controlFacet.getAttributes().put(HtmlConstants.STYLE_ATTRIBUTE,
facetStyle);
}
controlFacet.encodeAll(context);
- encodeDefault = false;
}
String expandIcon = control.getExpandIcon();
+ if (isEmpty(expandIcon)) {
+ expandIcon =
context.getApplication().getResourceHandler().createResource(UP_ICON_URL).getRequestPath();
+ } else {
+ expandIcon = RenderKitUtils.getResourceURL(expandIcon, context);
+ }
+
String collapseIcon = control.getCollapseIcon();
+ if (isEmpty(collapseIcon)) {
+ collapseIcon =
context.getApplication().getResourceHandler().createResource(DOWN_ICON_URL).getRequestPath();
+ } else {
+ collapseIcon = RenderKitUtils.getResourceURL(collapseIcon, context);
+ }
- if ((expandIcon != null && collapseIcon != null)
- && (expandIcon.trim().length() > 0 &&
collapseIcon.trim().length() > 0)) {
-
- String image = expanded ? expandIcon : collapseIcon;
- image = RenderKitUtils.getResourceURL(image, context);
- if (image != null && image.trim().length() > 0) {
- writer.startElement(HtmlConstants.IMG_ELEMENT, control);
- writer.writeAttribute(HtmlConstants.SRC_ATTRIBUTE, image, null);
- writer.writeAttribute(HtmlConstants.ALT_ATTRIBUTE, "", null);
- writer.endElement(HtmlConstants.IMG_ELEMENT);
- }
- encodeDefault = false;
+ String image = expanded ? expandIcon : collapseIcon;
+ if (image != null && image.trim().length() > 0) {
+ writer.startElement(HtmlConstants.IMG_ELEMENT, control);
+ writer.writeAttribute(HtmlConstants.SRC_ATTRIBUTE, image, null);
+ writer.writeAttribute(HtmlConstants.ALT_ATTRIBUTE, "", null);
+ writer.endElement(HtmlConstants.IMG_ELEMENT);
}
String label = expanded ? control.getExpandLabel() : control.getCollapseLabel();
@@ -151,22 +157,8 @@
writer.writeAttribute(HtmlConstants.HREF_ATTR,
"javascript:void(0);", null);
writer.writeText(label, null);
writer.endElement(HtmlConstants.A_ELEMENT);
- encodeDefault = false;
}
- if (encodeDefault) {
- expandIcon =
context.getApplication().getResourceHandler().createResource(UP_ICON_URL).getRequestPath();
- collapseIcon =
context.getApplication().getResourceHandler().createResource(DOWN_ICON_URL).getRequestPath();
-
- String image = expanded ? expandIcon : collapseIcon;
- if (image != null && image.trim().length() > 0) {
- writer.startElement(HtmlConstants.IMG_ELEMENT, control);
- writer.writeAttribute(HtmlConstants.SRC_ATTRIBUTE, image, null);
- writer.writeAttribute(HtmlConstants.ALT_ATTRIBUTE, "", null);
- writer.endElement(HtmlConstants.IMG_ELEMENT);
- }
- }
-
writer.endElement(HtmlConstants.SPAN_ELEM);
}