Author: nbelaevski
Date: 2007-11-20 08:29:51 -0500 (Tue, 20 Nov 2007)
New Revision: 4101
Added:
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java
Modified:
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
Log:
orderingList refactored
Modified:
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java
===================================================================
---
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java 2007-11-20
13:04:33 UTC (rev 4100)
+++
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java 2007-11-20
13:29:51 UTC (rev 4101)
@@ -102,16 +102,15 @@
}
public Object saveState(FacesContext faces) {
- Object[] state = new Object[6];
+ Object[] state = new Object[5];
state[0] = super.saveState(faces);
- state[1] = saveIterationState();
- state[2] = saveAttachedState(faces, validators);
- state[3] = saveAttachedState(faces, validator);
+ state[1] = saveAttachedState(faces, validators);
+ state[2] = saveAttachedState(faces, validator);
- state[4] = this.value;
- state[5] = localValueSet ? Boolean.TRUE : Boolean.FALSE;
+ state[3] = this.value;
+ state[4] = localValueSet ? Boolean.TRUE : Boolean.FALSE;
return state;
}
@@ -120,13 +119,12 @@
Object[] state = (Object[]) object;
super.restoreState(faces, state[0]);
- restoreIterationState(state[1]);
- validators = (List) restoreAttachedState(faces, state[2]);
- validator = (MethodBinding) restoreAttachedState(faces, state[3]);
+ validators = (List) restoreAttachedState(faces, state[1]);
+ validator = (MethodBinding) restoreAttachedState(faces, state[2]);
- value = state[4];
- localValueSet = ((Boolean) state[5]).booleanValue();
+ value = state[3];
+ localValueSet = ((Boolean) state[4]).booleanValue();
}
protected DataComponentState createComponentState() {
Modified:
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
===================================================================
---
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java 2007-11-20
13:04:33 UTC (rev 4100)
+++
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java 2007-11-20
13:29:51 UTC (rev 4101)
@@ -1,7 +1,6 @@
package org.richfaces.component;
import java.io.IOException;
-import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
@@ -20,6 +19,7 @@
import javax.faces.component.UIComponentBase;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.el.EvaluationException;
@@ -38,14 +38,12 @@
import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.renderkit.OrderingListRendererBase;
public abstract class UIOrderingList extends UIOrderingBaseComponent {
- public static final class ValueHolder implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 3380476273566115599L;
+ public static final class ValueHolder {
private Collection selection;
private boolean selectionSet;
@@ -1014,4 +1012,5 @@
public abstract int getListHeight();
public abstract void setListHeight(int listHeight);
+
}
Added:
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java
===================================================================
---
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java
(rev 0)
+++
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java 2007-11-20
13:29:51 UTC (rev 4101)
@@ -0,0 +1,338 @@
+/**
+ *
+ */
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.UIOrderingBaseComponent;
+import org.richfaces.component.UIOrderingList;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public abstract class OrderingComponentRendererBase extends AbstractRowsRenderer {
+
+ protected final static String SHOW_LABELS_ATTRIBUTE_NAME =
"showButtonLabels";
+
+ protected final static String ATTRIBUTE_CE_ONHEADERCLICK = "onheaderclick";
+
+ protected final static String CONTROL_TYPE_LINK = "link";
+
+ protected final static String CONTROL_TYPE_BUTTON = "button";
+
+ protected final static String CONTROL_TYPE_NONE = "none";
+
+ protected final static String ATTRIBUTE_CONTROLS_TYPE = "controlsType";
+
+ protected static abstract class ControlsHelper {
+ private String name;
+
+ private String bundlePropertyName;
+
+ private String imageURI;
+
+ private String facetName;
+
+ private String styleClassName;
+
+ private String idSuffix;
+
+ String customEvent;
+
+ String styleFromAttribute;
+
+ private String buttonStyleClass;
+
+ boolean enable;
+
+ private String defaultText;
+
+ private String labelAttributeName;
+
+ public abstract boolean isRendered(FacesContext context, UIOrderingList list);
+
+ public ControlsHelper(String name, String bundlePropertyName, String defaultText,
String imageURI,
+ String facetName, String styleClassName, String styleFromAttribute, String
buttonStyleClass,
+ String idSuffix, String customEvent, boolean isEnable, String labelAttributeName) {
+ super();
+ this.name = name;
+ this.bundlePropertyName = bundlePropertyName;
+ this.defaultText = defaultText;
+ this.imageURI = imageURI;
+ this.facetName = facetName;
+ this.styleClassName = styleClassName;
+ this.styleFromAttribute = styleFromAttribute;
+ this.idSuffix = idSuffix;
+ this.customEvent = customEvent;
+ this.buttonStyleClass = buttonStyleClass;
+ this.enable = isEnable;
+ this.labelAttributeName = labelAttributeName;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getBundlePropertyName() {
+ return bundlePropertyName;
+ }
+
+ public String getImageURI() {
+ return imageURI;
+ }
+
+ public String getFacetName() {
+ return facetName;
+ }
+
+ public String getStyleClassName() {
+ return styleClassName;
+ }
+
+ public String getIdSuffix() {
+ return idSuffix;
+ }
+
+ public String getCustomEvent() {
+ return customEvent;
+ }
+
+ public String getStyleFromAttribute() {
+ return styleFromAttribute;
+ }
+
+ public String getButtonStyleClass() {
+ return buttonStyleClass;
+ }
+
+ public boolean isEnable() {
+ return enable;
+ }
+
+ public String getDefaultText() {
+ return defaultText;
+ }
+
+ public String getLabelAttributeName() {
+ return labelAttributeName;
+ }
+ }
+
+ private final String bundleName;
+
+ public OrderingComponentRendererBase(String bundleName) {
+ super();
+
+ this.bundleName = bundleName;
+ }
+
+ public void encodeCaption(FacesContext context, UIComponent component)
+ throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ UIComponent facetEl = component.getFacet(OrderingListRendererBase.FACET_CAPTION);
+ boolean renderFacet = ((facetEl != null) && facetEl.isRendered());
+ String captionAttr = (String)
component.getAttributes().get(OrderingListRendererBase.ATTRIBUTE_CAPTION_LABEL);
+
+ if (renderFacet || (captionAttr != null)) {
+ writer.startElement(HTML.DIV_ELEM, component);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, "ol_label ol_out_label
rich-ordering-list-caption", null);
+ if (renderFacet) {
+ renderChild(context, facetEl);
+ } else {
+ writer.write(captionAttr);
+ }
+ writer.endElement(HTML.DIV_ELEM);
+ }
+
+ }
+
+ public void encodeHeader(FacesContext context, UIOrderingBaseComponent component)
+ throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ //UIComponent header = orderingList.getHeader();
+ Iterator headers = component.columns();
+
+ if (headers.hasNext()) {
+ writer.startElement("thead", component);
+ String headerClass = (String) component.getAttributes().get("headerClass");
+
+ writer.startElement("tr", component);
+ encodeStyleClass(writer, null, "rich-table-header", null, headerClass);
+ encodeHeaderFacets(context, writer, headers, "ol_col
rich-table-header-cell", headerClass, "header", "th",
component);
+
+ writer.endElement("tr");
+ }
+ writer.endElement("thead");
+ }
+
+ protected void renderDefaultControl(FacesContext context,
+ UIOrderingList orderingList, ResponseWriter writer,
+ boolean useFacet, OrderingComponentRendererBase.ControlsHelper helper, String
clientId, ResourceBundle bundle, boolean enabled)
+ throws IOException {
+ UIComponent facet = orderingList.getFacet(helper.getFacetName());
+ String customEvent = null;
+ Map attributes = orderingList.getAttributes();
+ if (helper.customEvent != null) {
+ customEvent = (String) attributes.get(helper.customEvent);
+ }
+
+ String styleFromAttribute = (String) attributes
+ .get(helper.styleFromAttribute);
+ String currentStyle = helper.getStyleClassName();
+
+ if (styleFromAttribute != null) {
+ currentStyle = styleFromAttribute.concat(currentStyle);
+ }
+
+ writer.startElement(HTML.DIV_ELEM, orderingList);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, clientId + helper.getIdSuffix(), null);
//FIXME:
+ writer.writeAttribute(HTML.class_ATTRIBUTE, "ol_button_border " + (enabled ?
"ol_control_shown" : "ol_control_hidden") + currentStyle, null);
+ if (!useFacet) {
+
+ writer.startElement(HTML.DIV_ELEM, orderingList);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, helper.getButtonStyleClass(), null);
+ if (helper.enable) {
+ writer.writeAttribute(HTML.onmouseover_ATTRIBUTE,
"this.className='ol_button_light'", null);
+ writer.writeAttribute(HTML.onmousedown_ATTRIBUTE,
"this.className='ol_button_press'", null);
+ writer.writeAttribute(HTML.onmouseup_ATTRIBUTE,
"this.className='ol_button'", null);
+ writer.writeAttribute(HTML.onmouseout_ATTRIBUTE,
"this.className='ol_button'", null);
+ }
+
+ writer.startElement(HTML.DIV_ELEM, orderingList);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, "ol_button_content", null);
+
+ }
+
+ if (customEvent != null) {
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE, customEvent,null);
+ }
+
+ if (useFacet) {
+ renderChild(context, facet);
+ } else {
+ writer.startElement(HTML.IMG_ELEMENT, orderingList);
+ writer.writeAttribute(HTML.width_ATTRIBUTE, "15", null);
+ writer.writeAttribute(HTML.height_ATTRIBUTE, "15", null);
+ writer.writeAttribute(HTML.border_ATTRIBUTE, "0", null);
+ writer.writeAttribute(HTML.alt_ATTRIBUTE, helper.getFacetName(),
+ null);
+ writer.writeAttribute(HTML.src_ATTRIBUTE, getResource(
+ helper.getImageURI()).getUri(context, null), null);
+
+ writer.endElement(HTML.IMG_ELEMENT);
+
+ if (Boolean.TRUE.equals(attributes.get(SHOW_LABELS_ATTRIBUTE_NAME))) {
+ String label = (String) attributes.get(helper.getLabelAttributeName());
+
+ if (label == null && bundle != null) {
+ try {
+ label = bundle.getString(helper.getBundlePropertyName());
+ } catch (MissingResourceException e) {
+
+ }
+ }
+
+ if (label == null) {
+ label = helper.getDefaultText();
+ }
+
+ writer.writeText(label, null);
+ }
+ }
+ // writer.writeAttribute(HTML.id_ATTRIBUTE, clientId +
+ // helper.getIdSuffix(), null);
+
+ // writer.writeAttribute(HTML.class_ATTRIBUTE, currentStyle, null);
+
+ if (!useFacet) {
+ writer.endElement(HTML.DIV_ELEM);
+ writer.endElement(HTML.DIV_ELEM);
+ }
+ writer.endElement(HTML.DIV_ELEM);
+ }
+
+ protected void encodeHeaderFacets(FacesContext context, ResponseWriter writer,
+ Iterator headers, String skinCellClass,
+ String headerClass, String facetName, String element, UIOrderingBaseComponent
orderingList)
+ throws IOException {
+ while (headers.hasNext()) {
+ UIComponent column = (UIComponent) headers.next();
+ String classAttribute = facetName + "Class";
+ String columnHeaderClass = (String) column.getAttributes().get(classAttribute);
+
+ writer.startElement(element, column);
+ if (!headers.hasNext()) {
+ skinCellClass = "ol_endcol rich-table-header-cell-end";
+ }
+ encodeStyleClass(writer, null, skinCellClass, headerClass, columnHeaderClass);
+ getUtils().encodeAttribute(context, column, "colspan");
+ writer.startElement("div", column);
+ writer.writeAttribute("style", "overflow:hidden;white-space:
nowrap;", null);
+ String onHeaderClickEvent = (String)
orderingList.getAttributes().get(ATTRIBUTE_CE_ONHEADERCLICK);
+ if (onHeaderClickEvent != null) {
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE, onHeaderClickEvent, null);
+ }
+
+ UIComponent facet = column.getFacet(facetName);
+ if (facet != null && facet.isRendered()) {
+ renderChild(context, facet);
+ } else {
+ writer.write(" ");
+ }
+
+ writer.endElement("div");
+ writer.endElement(element);
+ }
+ }
+
+ protected void encodeControlFacet(FacesContext context,
+ UIOrderingList orderingList, OrderingComponentRendererBase.ControlsHelper helper,
+ String clientId, ResponseWriter writer, boolean enabled) throws IOException {
+ Locale locale = null;
+
+ UIViewRoot viewRoot = context.getViewRoot();
+ if (viewRoot != null) {
+ locale = viewRoot.getLocale();
+ }
+
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ ResourceBundle bundle = null;
+
+ if (locale != null) {
+ try {
+ bundle = ResourceBundle.getBundle(bundleName, locale, contextClassLoader);
+ } catch (MissingResourceException e) {
+
+ }
+ }
+
+ Map attributes = orderingList.getAttributes();
+ UIComponent facet = orderingList.getFacet(helper.getFacetName());
+ boolean useFacet = (facet != null && facet.isRendered());
+ String controlType = (String) attributes.get(ATTRIBUTE_CONTROLS_TYPE);
+
+ if (CONTROL_TYPE_NONE.equals(controlType)) {
+ if (useFacet) {
+ renderChild(context, facet);
+ }
+ } else {
+ renderDefaultControl(context, orderingList, writer, useFacet,
+ helper, clientId, bundle ,enabled);
+ }
+ }
+
+
+}
Modified:
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
===================================================================
---
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-11-20
13:04:33 UTC (rev 4100)
+++
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-11-20
13:29:51 UTC (rev 4101)
@@ -3,14 +3,10 @@
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -26,8 +22,12 @@
import org.richfaces.renderkit.html.images.OrderingListIconUp;
import org.richfaces.renderkit.html.images.OrderingListIconUpDisabled;
-public abstract class OrderingListRendererBase extends AbstractRowsRenderer {
+public abstract class OrderingListRendererBase extends OrderingComponentRendererBase {
+ public OrderingListRendererBase() {
+ super(MESSAGE_BUNDLE_NAME);
+ }
+
private static final String MESSAGE_BUNDLE_NAME =
OrderingListRendererBase.class.getPackage().getName() + "OrderingList";
private final static Character ACTIVITY_MARKER = new Character('a');
@@ -52,18 +52,8 @@
private final static String FACET_DIS_DOWN = "downControlDisabled";
- private final static String FACET_CAPTION = "caption";
+ public final static String FACET_CAPTION = "caption";
- private final static String CONTROL_TYPE_LINK = "link";
-
- private final static String CONTROL_TYPE_BUTTON = "button";
-
- private final static String CONTROL_TYPE_NONE = "none";
-
- private final static String SHOW_LABELS_ATTRIBUTE_NAME = "showButtonLabels";
-
- private final static String ATTRIBUTE_CONTROLS_TYPE = "controlsType";
-
private final static String ATTRIBUTE_CE_ONORDERCHANGED = "onorderchanged";
private final static String ATTRIBUTE_CE_ONTOPCLICK = "ontopclick";
@@ -74,10 +64,8 @@
private final static String ATTRIBUTE_CE_ONBOTTOMCLICK = "onbottomclick";
- private final static String ATTRIBUTE_CE_ONHEADERCLICK = "onheaderclick";
+ public final static String ATTRIBUTE_CAPTION_LABEL = "captionLabel";
- private final static String ATTRIBUTE_CAPTION_LABEL = "captionLabel";
-
private final static String ATTRIBUTE_CLASS_TOP_CONTROL = "topControlClass";
private final static String ATTRIBUTE_CLASS_BOTTOM_CONTROL =
"bottomControlClass";
@@ -108,102 +96,8 @@
private final static String ATTRIBUTE_CLASS_BUTTON = "ol_button";
private final static String ATTRIBUTE_CLASS_BUTTON_DISABLED =
"ol_button_disabled";
- protected static abstract class ControlsHelper {
- private String name;
-
- private String bundlePropertyName;
-
- private String imageURI;
-
- private String facetName;
-
- private String styleClassName;
-
- private String idSuffix;
-
- private String customEvent;
-
- private String styleFromAttribute;
-
- private String buttonStyleClass;
-
- private boolean enable;
-
- private String defaultText;
-
- private String labelAttributeName;
-
- public abstract boolean isRendered(FacesContext context, UIOrderingList list);
-
- public ControlsHelper(String name, String bundlePropertyName, String defaultText,
String imageURI,
- String facetName, String styleClassName, String styleFromAttribute, String
buttonStyleClass,
- String idSuffix, String customEvent, boolean isEnable, String
labelAttributeName) {
- super();
- this.name = name;
- this.bundlePropertyName = bundlePropertyName;
- this.defaultText = defaultText;
- this.imageURI = imageURI;
- this.facetName = facetName;
- this.styleClassName = styleClassName;
- this.styleFromAttribute = styleFromAttribute;
- this.idSuffix = idSuffix;
- this.customEvent = customEvent;
- this.buttonStyleClass = buttonStyleClass;
- this.enable = isEnable;
- this.labelAttributeName = labelAttributeName;
- }
-
- public String getName() {
- return name;
- }
-
- public String getBundlePropertyName() {
- return bundlePropertyName;
- }
-
- public String getImageURI() {
- return imageURI;
- }
-
- public String getFacetName() {
- return facetName;
- }
-
- public String getStyleClassName() {
- return styleClassName;
- }
-
- public String getIdSuffix() {
- return idSuffix;
- }
-
- public String getCustomEvent() {
- return customEvent;
- }
-
- public String getStyleFromAttribute() {
- return styleFromAttribute;
- }
-
- public String getButtonStyleClass() {
- return buttonStyleClass;
- }
-
- public boolean isEnable() {
- return enable;
- }
-
- public String getDefaultText() {
- return defaultText;
- }
-
- public String getLabelAttributeName() {
- return labelAttributeName;
- }
- };
-
- protected static final ControlsHelper[] HELPERS = new ControlsHelper[] {
- new ControlsHelper("top", "TOP_LABEL", DEFAULT_LABEL_TOP,
OrderingListIconTop.class.getName(), FACET_TOP,
+ protected static final OrderingComponentRendererBase.ControlsHelper[] HELPERS = new
OrderingComponentRendererBase.ControlsHelper[] {
+ new OrderingComponentRendererBase.ControlsHelper("top",
"TOP_LABEL", DEFAULT_LABEL_TOP, OrderingListIconTop.class.getName(), FACET_TOP,
" rich-ordering-control-top", ATTRIBUTE_CLASS_TOP_CONTROL,
ATTRIBUTE_CLASS_BUTTON,
CONTROL_ID_TOP, ATTRIBUTE_CE_ONTOPCLICK, true, "topControlLabel") {
@@ -212,7 +106,7 @@
}
},
- new ControlsHelper("disabledTop", "TOP_LABEL", DEFAULT_LABEL_TOP,
OrderingListIconTopDisabled.class.getName(), FACET_DIS_TOP,
+ new OrderingComponentRendererBase.ControlsHelper("disabledTop",
"TOP_LABEL", DEFAULT_LABEL_TOP, OrderingListIconTopDisabled.class.getName(),
FACET_DIS_TOP,
" rich-ordering-control-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL,
ATTRIBUTE_CLASS_BUTTON_DISABLED,
DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_TOP), null, false,
"topControlLabel") {
@@ -221,7 +115,7 @@
}
},
- new ControlsHelper("up", "UP_LABEL", DEFAULT_LABEL_UP,
OrderingListIconUp.class.getName(), FACET_UP,
+ new OrderingComponentRendererBase.ControlsHelper("up", "UP_LABEL",
DEFAULT_LABEL_UP, OrderingListIconUp.class.getName(), FACET_UP,
" rich-ordering-control-up", ATTRIBUTE_CLASS_UP_CONTROL,
ATTRIBUTE_CLASS_BUTTON,
CONTROL_ID_UP, ATTRIBUTE_CE_ONUPCLICK ,true, "upControlLabel") {
@@ -230,7 +124,7 @@
}
},
- new ControlsHelper("disabledUp", "UP_LABEL", DEFAULT_LABEL_UP,
OrderingListIconUpDisabled.class.getName(), FACET_DIS_UP,
+ new OrderingComponentRendererBase.ControlsHelper("disabledUp",
"UP_LABEL", DEFAULT_LABEL_UP, OrderingListIconUpDisabled.class.getName(),
FACET_DIS_UP,
" rich-ordering-control-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL,
ATTRIBUTE_CLASS_BUTTON_DISABLED,
DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_UP), null, false,
"upControlLabel") {
@@ -239,7 +133,7 @@
}
},
- new ControlsHelper("down", "DOWN_LABEL", DEFAULT_LABEL_DOWN,
OrderingListIconDown.class.getName(), FACET_DOWN,
+ new OrderingComponentRendererBase.ControlsHelper("down",
"DOWN_LABEL", DEFAULT_LABEL_DOWN, OrderingListIconDown.class.getName(),
FACET_DOWN,
" rich-ordering-control-down", ATTRIBUTE_CLASS_DOWN_CONTROL,
ATTRIBUTE_CLASS_BUTTON,
CONTROL_ID_DOWN, ATTRIBUTE_CE_ONDOWNCLICK, true, "downControlLabel")
{
@@ -248,7 +142,7 @@
}
},
- new ControlsHelper("disabledDown", "DOWN_LABEL",
DEFAULT_LABEL_DOWN, OrderingListIconDownDisabled.class.getName(), FACET_DIS_DOWN,
+ new OrderingComponentRendererBase.ControlsHelper("disabledDown",
"DOWN_LABEL", DEFAULT_LABEL_DOWN, OrderingListIconDownDisabled.class.getName(),
FACET_DIS_DOWN,
" rich-ordering-control-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL,
ATTRIBUTE_CLASS_BUTTON_DISABLED,
DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_DOWN), null, false,
"downControlLabel") {
@@ -257,7 +151,7 @@
}
},
- new ControlsHelper("bottom", "BOTTOM_LABEL", DEFAULT_LABEL_BOTTOM,
OrderingListIconBottom.class.getName(), FACET_BOTTOM,
+ new OrderingComponentRendererBase.ControlsHelper("bottom",
"BOTTOM_LABEL", DEFAULT_LABEL_BOTTOM, OrderingListIconBottom.class.getName(),
FACET_BOTTOM,
" rich-ordering-control-bottom", ATTRIBUTE_CLASS_BOTTOM_CONTROL,
ATTRIBUTE_CLASS_BUTTON,
CONTROL_ID_BOTTOM, ATTRIBUTE_CE_ONBOTTOMCLICK, true,
"bottomControlLabel") {
@@ -266,7 +160,7 @@
}
},
- new ControlsHelper("disabledBottom", "BOTTOM_LABEL",
DEFAULT_LABEL_BOTTOM, OrderingListIconBottomDisabled.class.getName(), FACET_DIS_BOTTOM,
+ new OrderingComponentRendererBase.ControlsHelper("disabledBottom",
"BOTTOM_LABEL", DEFAULT_LABEL_BOTTOM,
OrderingListIconBottomDisabled.class.getName(), FACET_DIS_BOTTOM,
" rich-ordering-control-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL,
ATTRIBUTE_CLASS_BUTTON_DISABLED,
DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_BOTTOM), null, false,
"bottomControlLabel") {
@@ -285,45 +179,6 @@
return true;
}
- public void encodeCaption(FacesContext context, UIOrderingList orderingList)
- throws IOException {
- ResponseWriter writer = context.getResponseWriter();
- UIComponent facetEl = orderingList.getFacet(FACET_CAPTION);
- boolean renderFacet = ((facetEl != null) && facetEl.isRendered());
- String captionAttr = (String)
orderingList.getAttributes().get(ATTRIBUTE_CAPTION_LABEL);
-
- if (renderFacet || (captionAttr != null)) {
- writer.startElement(HTML.DIV_ELEM, orderingList);
- writer.writeAttribute(HTML.class_ATTRIBUTE, "ol_label ol_out_label
rich-ordering-list-caption", null);
- if (renderFacet) {
- renderChild(context, facetEl);
- } else {
- writer.write(captionAttr);
- }
- writer.endElement(HTML.DIV_ELEM);
- }
-
- }
-
- public void encodeHeader(FacesContext context, UIOrderingList orderingList)
- throws IOException {
- ResponseWriter writer = context.getResponseWriter();
- //UIComponent header = orderingList.getHeader();
- Iterator headers = orderingList.columns();
-
- if (headers.hasNext()) {
- writer.startElement("thead", orderingList);
- String headerClass = (String)
orderingList.getAttributes().get("headerClass");
-
- writer.startElement("tr", orderingList);
- encodeStyleClass(writer, null, "rich-table-header", null, headerClass);
- encodeHeaderFacets(context, writer, headers, "ol_col
rich-table-header-cell", headerClass, "header", "th",
orderingList);
-
- writer.endElement("tr");
- }
- writer.endElement("thead");
- }
-
private static final ThreadLocal itemStates = new ThreadLocal();
public void encodeBegin(FacesContext context, UIComponent component)
@@ -382,162 +237,6 @@
}
}
- protected void encodeControlFacet(FacesContext context,
- UIOrderingList orderingList, ControlsHelper helper,
- String clientId, ResponseWriter writer, boolean enabled) throws IOException {
- Locale locale = null;
-
- UIViewRoot viewRoot = context.getViewRoot();
- if (viewRoot != null) {
- locale = viewRoot.getLocale();
- }
-
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
- ResourceBundle bundle = null;
-
- if (locale != null) {
- try {
- bundle = ResourceBundle.getBundle(MESSAGE_BUNDLE_NAME, locale, contextClassLoader);
- } catch (MissingResourceException e) {
-
- }
- }
-
- Map attributes = orderingList.getAttributes();
- UIComponent facet = orderingList.getFacet(helper.getFacetName());
- boolean useFacet = (facet != null && facet.isRendered());
- String controlType = (String) attributes.get(ATTRIBUTE_CONTROLS_TYPE);
-
- if (CONTROL_TYPE_NONE.equals(controlType)) {
- if (useFacet) {
- renderChild(context, facet);
- }
- } else {
- renderDefaultControl(context, orderingList, writer, useFacet,
- helper, clientId, bundle ,enabled);
- }
- }
-
- protected void renderDefaultControl(FacesContext context,
- UIOrderingList orderingList, ResponseWriter writer,
- boolean useFacet, ControlsHelper helper, String clientId, ResourceBundle bundle,
boolean enabled)
- throws IOException {
- UIComponent facet = orderingList.getFacet(helper.getFacetName());
- String customEvent = null;
- Map attributes = orderingList.getAttributes();
- if (helper.customEvent != null) {
- customEvent = (String) attributes.get(helper.customEvent);
- }
-
- String styleFromAttribute = (String) attributes
- .get(helper.styleFromAttribute);
- String currentStyle = helper.getStyleClassName();
-
- if (styleFromAttribute != null) {
- currentStyle = styleFromAttribute.concat(currentStyle);
- }
-
- writer.startElement(HTML.DIV_ELEM, orderingList);
- writer.writeAttribute(HTML.id_ATTRIBUTE, clientId + helper.getIdSuffix(), null);
//FIXME:
- writer.writeAttribute(HTML.class_ATTRIBUTE, "ol_button_border " + (enabled ?
"ol_control_shown" : "ol_control_hidden") + currentStyle, null);
- if (!useFacet) {
-
- writer.startElement(HTML.DIV_ELEM, orderingList);
- writer.writeAttribute(HTML.class_ATTRIBUTE, helper.getButtonStyleClass(), null);
- if (helper.enable) {
- writer.writeAttribute(HTML.onmouseover_ATTRIBUTE,
"this.className='ol_button_light'", null);
- writer.writeAttribute(HTML.onmousedown_ATTRIBUTE,
"this.className='ol_button_press'", null);
- writer.writeAttribute(HTML.onmouseup_ATTRIBUTE,
"this.className='ol_button'", null);
- writer.writeAttribute(HTML.onmouseout_ATTRIBUTE,
"this.className='ol_button'", null);
- }
-
- writer.startElement(HTML.DIV_ELEM, orderingList);
- writer.writeAttribute(HTML.class_ATTRIBUTE, "ol_button_content", null);
-
- }
-
- if (customEvent != null) {
- writer.writeAttribute(HTML.onclick_ATTRIBUTE, customEvent,null);
- }
-
- if (useFacet) {
- renderChild(context, facet);
- } else {
- writer.startElement(HTML.IMG_ELEMENT, orderingList);
- writer.writeAttribute(HTML.width_ATTRIBUTE, "15", null);
- writer.writeAttribute(HTML.height_ATTRIBUTE, "15", null);
- writer.writeAttribute(HTML.border_ATTRIBUTE, "0", null);
- writer.writeAttribute(HTML.alt_ATTRIBUTE, helper.getFacetName(),
- null);
- writer.writeAttribute(HTML.src_ATTRIBUTE, getResource(
- helper.getImageURI()).getUri(context, null), null);
-
- writer.endElement(HTML.IMG_ELEMENT);
-
- if (Boolean.TRUE.equals(attributes.get(SHOW_LABELS_ATTRIBUTE_NAME))) {
- String label = (String) attributes.get(helper.getLabelAttributeName());
-
- if (label == null && bundle != null) {
- try {
- label = bundle.getString(helper.getBundlePropertyName());
- } catch (MissingResourceException e) {
-
- }
- }
-
- if (label == null) {
- label = helper.getDefaultText();
- }
-
- writer.writeText(label, null);
- }
- }
- // writer.writeAttribute(HTML.id_ATTRIBUTE, clientId +
- // helper.getIdSuffix(), null);
-
- // writer.writeAttribute(HTML.class_ATTRIBUTE, currentStyle, null);
-
- if (!useFacet) {
- writer.endElement(HTML.DIV_ELEM);
- writer.endElement(HTML.DIV_ELEM);
- }
- writer.endElement(HTML.DIV_ELEM);
- }
-
- protected void encodeHeaderFacets(FacesContext context, ResponseWriter writer,
- Iterator headers, String skinCellClass,
- String headerClass, String facetName, String element, UIOrderingList
orderingList)
- throws IOException {
- while (headers.hasNext()) {
- UIComponent column = (UIComponent) headers.next();
- String classAttribute = facetName + "Class";
- String columnHeaderClass = (String) column.getAttributes().get(classAttribute);
-
- writer.startElement(element, column);
- if (!headers.hasNext()) {
- skinCellClass = "ol_endcol rich-table-header-cell-end";
- }
- encodeStyleClass(writer, null, skinCellClass, headerClass, columnHeaderClass);
- getUtils().encodeAttribute(context, column, "colspan");
- writer.startElement("div", column);
- writer.writeAttribute("style", "overflow:hidden;white-space:
nowrap;", null);
- String onHeaderClickEvent = (String)
orderingList.getAttributes().get(ATTRIBUTE_CE_ONHEADERCLICK);
- if (onHeaderClickEvent != null) {
- writer.writeAttribute(HTML.onclick_ATTRIBUTE, onHeaderClickEvent, null);
- }
-
- UIComponent facet = column.getFacet(facetName);
- if (facet != null && facet.isRendered()) {
- renderChild(context, facet);
- } else {
- writer.write(" ");
- }
-
- writer.endElement("div");
- writer.endElement(element);
- }
- }
-
public void encodeOneRow(FacesContext context, TableHolder holder)
throws IOException {
ResponseWriter writer = context.getResponseWriter();