Author: abelevich
Date: 2008-03-12 14:04:36 -0400 (Wed, 12 Mar 2008)
New Revision: 6769
Modified:
trunk/ui/pickList/src/main/java/org/richfaces/picklist/util/PickListUtils.java
trunk/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java
Log:
http://jira.jboss.com/jira/browse/RF-2361
Modified: trunk/ui/pickList/src/main/java/org/richfaces/picklist/util/PickListUtils.java
===================================================================
---
trunk/ui/pickList/src/main/java/org/richfaces/picklist/util/PickListUtils.java 2008-03-12
17:35:00 UTC (rev 6768)
+++
trunk/ui/pickList/src/main/java/org/richfaces/picklist/util/PickListUtils.java 2008-03-12
18:04:36 UTC (rev 6769)
@@ -1,281 +1,160 @@
package org.richfaces.picklist.util;
-import java.io.Serializable;
import java.lang.reflect.Array;
-import java.util.Collections;
-import java.util.HashSet;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Set;
import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.UISelectMany;
-import javax.faces.component.UISelectOne;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
-import javax.faces.convert.ConverterException;
import javax.faces.model.SelectItem;
import org.ajax4jsf.util.SelectUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
-
-
-
public class PickListUtils {
-
- private static final Log log = LogFactory.getLog(PickListUtils.class);
- public static final Object NOTHING = new Serializable() {};
- public static Converter findUISelectManyConverter(FacesContext context, UISelectMany
component) {
-
- Converter converter = component.getConverter();
-
- if (converter != null) return converter;
- //Try to find out by value binding
- ValueExpression ve = component.getValueExpression("value");
- if (ve == null) return null;
+ private static final Log log = LogFactory.getLog(PickListUtils.class);
- Class valueType = ve.getType(context.getELContext());
- if (valueType == null) return null;
+ public static Converter findUISelectManyConverter(FacesContext context, UISelectMany
component) {
- if (List.class.isAssignableFrom(valueType)) {
- List selectItems = SelectUtils.getSelectItems(context, component);
+ Converter converter = component.getConverter();
+ if (converter != null) {
+ return converter;
+ }
- if (selectItems != null && selectItems.size() > 0) {
- SelectItem selectItem = (SelectItem) selectItems.get(0);
- Class listComponentType = selectItem.getValue().getClass();
-
- if (!(String.class.equals(listComponentType))) {
- try {
- return context.getApplication().createConverter(listComponentType);
- }
- catch (FacesException e) {
- log.error("No Converter for type " + listComponentType.getName() + "
found", e);
- return null;
- }
- }
- }
+ ValueExpression ve = component.getValueExpression("value");
+ if (ve == null) {
+ return null;
+ }
+ Class valueType = ve.getType(context.getELContext());
+ if (valueType == null) {
+ return null;
+ }
+
+ if (List.class.isAssignableFrom(valueType)) {
+ List selectItems = SelectUtils.getSelectItems(context, component);
+ if (selectItems != null && selectItems.size() > 0) {
+ SelectItem selectItem = (SelectItem) selectItems.get(0);
+ Class listComponentType = selectItem.getValue().getClass();
+ if (!(String.class.equals(listComponentType))) {
+ try {
+ return context.getApplication().createConverter(listComponentType);
+ } catch (FacesException e) {
+ log.error("No Converter for type " + listComponentType.getName() + "
found", e);
return null;
+ }
}
+ }
+ return null;
+ }
- if (!valueType.isArray()) {
- throw new IllegalArgumentException("ValueBinding for UISelectMany : must be of
type List or Array");
- }
+ if (!valueType.isArray()) {
+ throw new IllegalArgumentException("ValueBinding for UISelectMany : must be of
type List or Array");
+ }
- Class arrayComponentType = valueType.getComponentType();
- if (String.class.equals(arrayComponentType)) return null; //No converter needed for
String type
- if (Object.class.equals(arrayComponentType)) return null; //There is no converter
for Object class
+ Class arrayComponentType = valueType.getComponentType();
+ if (String.class.equals(arrayComponentType))
+ return null;
+ if (Object.class.equals(arrayComponentType))
+ return null;
- try {
- return context.getApplication().createConverter(arrayComponentType);
- } catch (FacesException e) {
- log.error("No Converter for type " + arrayComponentType.getName() + "
found", e);
- return null;
- }
- }
-
- public static Converter findUISelectManyConverterFailsafe(FacesContext facesContext,
UIComponent uiComponent) {
- Converter converter;
- try {
- converter = findUISelectManyConverter(
- facesContext, (UISelectMany) uiComponent);
- }
- catch (FacesException e) {
- log.error("Error finding Converter for component with id "
- + uiComponent.getClientId(facesContext), e);
- converter = null;
- }
- return converter;
+ try {
+ return context.getApplication().createConverter(arrayComponentType);
+ } catch (FacesException e) {
+ log.error("No Converter for type " + arrayComponentType.getName() + "
found", e);
+ return null;
+ }
}
-
- public static Set getSubmittedOrSelectedValuesAsSet(boolean selectMany, UIComponent
uiComponent, FacesContext facesContext, Converter converter) {
- Set lookupSet;
- if (selectMany) {
- UISelectMany uiSelectMany = (UISelectMany) uiComponent;
- lookupSet = getSubmittedValuesAsSet(facesContext, uiComponent, converter,
uiSelectMany);
- if (lookupSet == null) {
- lookupSet = getSelectedValuesAsSet(facesContext, uiComponent, converter,
uiSelectMany);
- }
- }
- else {
- UISelectOne uiSelectOne = (UISelectOne) uiComponent;
- Object lookup = uiSelectOne.getSubmittedValue();
- if (lookup == null) {
- lookup = uiSelectOne.getValue();
- String lookupString = getConvertedStringValue(facesContext, uiComponent,
converter, lookup);
- lookupSet = Collections.singleton(lookupString);
- }
- else if (NOTHING.equals(lookup)) {
- lookupSet = Collections.EMPTY_SET;
- }
- else {
- lookupSet = Collections.singleton(lookup);
- }
- }
- return lookupSet;
+ public static Converter findUISelectManyConverterFailsafe(FacesContext facesContext,
UIComponent uiComponent) {
+ Converter converter;
+ try {
+ converter = findUISelectManyConverter(facesContext, (UISelectMany) uiComponent);
+ } catch (FacesException e) {
+ log.error("Error finding Converter for component with id " +
uiComponent.getClientId(facesContext), e);
+ converter = null;
+ }
+ return converter;
}
-
- public static Set getSubmittedValuesAsSet(FacesContext context, UIComponent component,
Converter converter, UISelectMany uiSelectMany) {
- Object submittedValues = uiSelectMany.getSubmittedValue();
- if (submittedValues == null) {
- return null;
- }
-
- if(converter != null) {
- converter = new PassThroughAsStringConverter(converter);
- }
- return internalSubmittedOrSelectedValuesAsSet(context, component, converter,
uiSelectMany, submittedValues);
+ public static List getValuesList(UIComponent uiComponent, FacesContext facesContext,
Converter converter) {
+ List lookupList = null;
+ if (uiComponent instanceof UISelectMany) {
+ UISelectMany uiSelectMany = (UISelectMany) uiComponent;
+ lookupList = getSelectValuesList(facesContext, uiComponent, converter,
uiSelectMany);
+ }
+ return lookupList;
}
-
- private static class PassThroughAsStringConverter implements Converter {
- private final Converter converter;
- public PassThroughAsStringConverter(Converter converter) {
- this.converter = converter;
- }
+ public static List getSelectValuesList(FacesContext context, UIComponent component,
Converter converter, UISelectMany uiSelectMany) {
+ Object selectedValues = uiSelectMany.getValue();
+ return internalSelectValuesList(context, component, converter, uiSelectMany,
selectedValues);
+ }
- public Object getAsObject(FacesContext context, UIComponent component,
- String value) throws ConverterException {
- return converter.getAsObject(context, component, value);
- }
+ private static List internalSelectValuesList(FacesContext context, UIComponent
component, Converter converter, UISelectMany uiSelectMany, Object values) {
+ List valuesList = new ArrayList();
- public String getAsString(FacesContext context, UIComponent component, Object
value) throws ConverterException {
- return (String)value;
- }
+ if (values == null || "".equals(values)) {
+ return valuesList;
+
+ } else if (values instanceof Object[]) {
+
+ Object[] ar = (Object[]) values;
+ if (ar.length == 0) {
+ return valuesList;
+ }
+ valuesList = new ArrayList();
+ for (int i = 0; i < ar.length; i++) {
+ valuesList.add(getConvertedStringValue(context, component, converter, ar[i]));
+ }
+ return valuesList;
+
+ } else if (values.getClass().isArray()) {
+
+ int len = Array.getLength(values);
+ valuesList = new ArrayList();
+ for (int i = 0; i < len; i++) {
+ valuesList.add(getConvertedStringValue(context, component, converter, Array.get(values,
i)));
+ }
+ return valuesList;
+
+ } else if (values instanceof List) {
+
+ List lst = (List) values;
+ if (lst.size() == 0) {
+ return lst;
+ } else {
+ valuesList = new ArrayList();
+ for (Iterator i = lst.iterator(); i.hasNext();) {
+ valuesList.add(getConvertedStringValue(context, component, converter, i.next()));
+ }
+ return valuesList;
+ }
+
+ } else {
+ throw new IllegalArgumentException("Value of UISelectMany component : is not of
type Array or List");
}
-
- public static Set getSelectedValuesAsSet(FacesContext context, UIComponent component,
Converter converter, UISelectMany uiSelectMany) {
- Object selectedValues = uiSelectMany.getValue();
- return internalSubmittedOrSelectedValuesAsSet(context, component, converter,
uiSelectMany, selectedValues);
- }
-
- private static Set internalSubmittedOrSelectedValuesAsSet(FacesContext context,
UIComponent component, Converter converter, UISelectMany uiSelectMany,Object values) {
-
- if (values == null || "".equals(values)) {
- return Collections.EMPTY_SET;
- } else if (values instanceof Object[]) {
- //Object array
- Object[] ar = (Object[]) values;
- if (ar.length == 0) {
- return Collections.EMPTY_SET;
- }
-
- HashSet set = new HashSet(calcCapacity(ar.length));
- for (int i = 0; i < ar.length; i++) {
- set.add(getConvertedStringValue(context, component, converter, ar[i]));
- }
- return set;
- } else if (values.getClass().isArray()) {
- //primitive array
- int len = Array.getLength(values);
- HashSet set = new HashSet(calcCapacity(len));
- for (int i = 0; i < len; i++) {
- set.add(getConvertedStringValue(context, component, converter, Array.get(values,
i)));
- }
- return set;
- } else if (values instanceof List) {
- List lst = (List) values;
- if (lst.size() == 0) {
- return Collections.EMPTY_SET;
- } else {
- HashSet set = new HashSet(calcCapacity(lst.size()));
- for (Iterator i = lst.iterator(); i.hasNext();) {
- set.add(getConvertedStringValue(context, component, converter, i.next()));
- }
- return set;
- }
- } else {
- throw new IllegalArgumentException("Value of UISelectMany component : is not of
type Array or List");
- }
- }
-
- public static final int calcCapacity(int size) {
- return ((size * 4) + 3) / 3;
- }
-
- public static String getConvertedStringValue(FacesContext context, UIComponent
component, Converter converter, Object value) {
- if (converter == null) {
- if (value == null) {
- return "";
- } else if (value instanceof String) {
- return (String) value;
- } else {
- throw new IllegalArgumentException(
- "Value is not String (class=" + value.getClass().getName() + ",
value=" + value + ") and component "
- + component.getClientId(context) + " does not have a Converter");
- }
- }
-
- return converter.getAsString(context, component, value);
- }
-// public static boolean renderHTMLAttributes(ResponseWriter writer,
-// UIComponent component, String[] attributes) throws IOException {
-// boolean somethingDone = false;
-// for (int i = 0, len = attributes.length; i < len; i++) {
-// String attrName = attributes[i];
-// if (renderHTMLAttribute(writer, component, attrName, attrName)) {
-// somethingDone = true;
-// }
-// }
-// return somethingDone;
-// }
-//
-// public static boolean renderHTMLAttribute(ResponseWriter writer,
-// UIComponent component, String componentProperty, String htmlAttrName)
throws IOException {
-// Object value = component.getAttributes().get(componentProperty);
-// return renderHTMLAttribute(writer, componentProperty, htmlAttrName, value);
-// }
-//
-// public static boolean renderHTMLAttribute(ResponseWriter writer,
-// String componentProperty, String attrName, Object value) throws
IOException {
-// if (!isDefaultAttributeValue(value)) {
-// // render JSF "styleClass" and "itemStyleClass" attributes as
"class"
-// String htmlAttrName =
-// attrName.equals("styleClass") ? "class" : attrName;
-// writer.writeAttribute(htmlAttrName, value, componentProperty);
-// return true;
-// }
-//
-// return false;
-// }
-//
-// public static boolean isDefaultAttributeValue(Object value) {
-// if (value == null) {
-// return true;
-// }
-// else if (value instanceof Boolean) {
-// return !((Boolean) value).booleanValue();
-// }
-// else if (value instanceof Number) {
-// if (value instanceof Integer) {
-// return ((Number) value).intValue() == Integer.MIN_VALUE;
-// }
-// else if (value instanceof Double) {
-// return ((Number) value).doubleValue() == Double.MIN_VALUE;
-// }
-// else if (value instanceof Long) {
-// return ((Number) value).longValue() == Long.MIN_VALUE;
-// }
-// else if (value instanceof Byte) {
-// return ((Number) value).byteValue() == Byte.MIN_VALUE;
-// }
-// else if (value instanceof Float) {
-// return ((Number) value).floatValue() == Float.MIN_VALUE;
-// }
-// else if (value instanceof Short) {
-// return ((Number) value).shortValue() == Short.MIN_VALUE;
-// }
-// }
-// return false;
-// }
+ }
+ public static String getConvertedStringValue(FacesContext context, UIComponent
component, Converter converter, Object value) {
+ if (converter == null) {
+ if (value == null) {
+ return "";
+ } else if (value instanceof String) {
+ return (String) value;
+ } else {
+ throw new IllegalArgumentException("Value is not String (class=" +
value.getClass().getName() + ", value=" + value + ") and component "
+ + component.getClientId(context) + " does not have a Converter");
+ }
+ }
+ return converter.getAsString(context, component, value);
+ }
}
Modified: trunk/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java
===================================================================
---
trunk/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java 2008-03-12
17:35:00 UTC (rev 6768)
+++
trunk/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java 2008-03-12
18:04:36 UTC (rev 6769)
@@ -10,7 +10,6 @@
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-import java.util.Set;
import javax.faces.component.EditableValueHolder;
import javax.faces.component.UIComponent;
@@ -37,331 +36,336 @@
import org.richfaces.picklist.util.PickListUtils;
public class PickListRenderer extends HeaderResourcesRendererBase {
-
- private static final String HIDDEN_SUFFIX = "valueKeeper";
+
+ private static final String HIDDEN_SUFFIX = "valueKeeper";
protected static final OrderingComponentRendererBase.ControlsHelper[] SHUTTLE_HELPERS
= ListShuttleControlsHelper.HELPERS;
protected final static String SHOW_LABELS_ATTRIBUTE_NAME =
"showButtonsLabel";
private static final String MESSAGE_BUNDLE_NAME =
OrderingListRendererBase.class.getPackage().getName() + "ListShuttle";
private boolean isSelectedList;
private boolean isAvailableList;
-
- protected List <SelectItem> selectItemsForSelectedList(FacesContext
facesContext,UIComponent uiComponent, List <SelectItem> selectItemList, Converter
converter, Set <SelectItem> lookupSet) {
- List <SelectItem> selectItemForSelectedValues = new
ArrayList<SelectItem>(lookupSet.size());
- for (Iterator <SelectItem> i = selectItemList.iterator(); i.hasNext();) {
- SelectItem selectItem = i.next();
- String itemStrValue = PickListUtils.getConvertedStringValue(facesContext,
uiComponent,converter, selectItem.getValue());
- for (Iterator <SelectItem> i2 = lookupSet.iterator(); i2.hasNext();) {
- Object value = i2.next();
- if (value.equals(itemStrValue)) {
- selectItemForSelectedValues.add(selectItem);
- }
- }
+
+ protected List<SelectItem> selectItemsForSelectedList(FacesContext
facesContext, UIComponent uiComponent, List<SelectItem> selectItemList,
+ Converter converter, List<SelectItem> lookupList) {
+ List<SelectItem> selectItemForSelectedValues = new ArrayList<SelectItem>();
+
+ for (Iterator<SelectItem> i2 = lookupList.iterator(); i2.hasNext();) {
+ Object value = i2.next();
+ for (Iterator<SelectItem> i = selectItemList.iterator(); i.hasNext();) {
+ SelectItem selectItem = i.next();
+ String itemStrValue = PickListUtils.getConvertedStringValue(facesContext, uiComponent,
converter, selectItem.getValue());
+ if (value.equals(itemStrValue)) {
+ selectItemForSelectedValues.add(selectItem);
}
- return selectItemForSelectedValues;
+ }
}
+ return selectItemForSelectedValues;
+ }
- protected List selectItemsForAvailableList(FacesContext facesContext, UIComponent
uiComponent, List <SelectItem> selectItemList, List <SelectItem>
selectItemsForSelectedList, Converter converter) {
- Collection collection = CollectionUtils.subtract(selectItemList,
selectItemsForSelectedList);
- return new ArrayList <SelectItem>(collection);
+ protected List selectItemsForAvailableList(FacesContext facesContext, UIComponent
uiComponent, List<SelectItem> selectItemList,
+ List<SelectItem> selectItemsForSelectedList, Converter converter) {
+ Collection collection = CollectionUtils.subtract(selectItemList,
selectItemsForSelectedList);
+ return new ArrayList<SelectItem>(collection);
+ }
+
+ protected List getSelectItemsList(FacesContext context, UIComponent component) {
+ return SelectUtils.getSelectItems(context, component);
+ }
+
+ private final String bundleName;
+
+ public PickListRenderer() {
+ super();
+ this.bundleName = MESSAGE_BUNDLE_NAME;
+ }
+
+ public void decode(FacesContext context, UIComponent component) {
+
+ UIPickList picklist = (UIPickList) component;
+ if (!(picklist instanceof EditableValueHolder)) {
+ throw new IllegalArgumentException("Component " +
picklist.getClientId(context) + " is not an EditableValueHolder");
}
-
- protected List getSelectItemsList(FacesContext context,UIComponent component) {
- return SelectUtils.getSelectItems(context, component);
- }
-
- private final String bundleName;
-
- public PickListRenderer() {
- super();
- this.bundleName = MESSAGE_BUNDLE_NAME;
- }
-
- public void decode(FacesContext context, UIComponent component) {
-
- UIPickList picklist = (UIPickList)component;
- if (!(picklist instanceof EditableValueHolder)) {
- throw new IllegalArgumentException("Component " +
picklist.getClientId(context) + " is not an EditableValueHolder");
- }
- String hiddenClientId = picklist.getClientId(context) + HIDDEN_SUFFIX;
- Map paramValuesMap = context.getExternalContext().getRequestParameterValuesMap();
+ String hiddenClientId = picklist.getClientId(context) + HIDDEN_SUFFIX;
+ Map paramValuesMap = context.getExternalContext().getRequestParameterValuesMap();
- if (picklist.isDisabled()) {
- return;
- }
+ if (picklist.isDisabled()) {
+ return;
+ }
- if (paramValuesMap.containsKey(hiddenClientId)) {
- String[] valuesInline = (String[]) paramValuesMap.get(hiddenClientId);
- if (valuesInline[0].trim().equals("")) {
- ((EditableValueHolder) picklist).setSubmittedValue(new String[] {});
- } else {
- String[] reqValues = valuesInline[0].split(",");
- ((EditableValueHolder) picklist).setSubmittedValue(reqValues);
- }
+ if (paramValuesMap.containsKey(hiddenClientId)) {
+ String[] valuesInline = (String[]) paramValuesMap.get(hiddenClientId);
+ if (valuesInline[0].trim().equals("")) {
+ ((EditableValueHolder) picklist).setSubmittedValue(new String[] {});
} else {
- ((EditableValueHolder) picklist).setSubmittedValue(new String[] {});
+ String[] reqValues = valuesInline[0].split(",");
+ ((EditableValueHolder) picklist).setSubmittedValue(reqValues);
}
+ } else {
+ ((EditableValueHolder) picklist).setSubmittedValue(new String[] {});
}
-
- private static boolean isTrue(Object obj) {
- if (!(obj instanceof Boolean)) {
- return false;
- }
- return ((Boolean) obj).booleanValue();
+ }
+
+ private static boolean isTrue(Object obj) {
+ if (!(obj instanceof Boolean)) {
+ return false;
}
-
- @Override
- public Object getConvertedValue(FacesContext context, UIComponent component, Object
submittedValue)
- throws ConverterException {
-
- if ((component instanceof UISelectMany) && (submittedValue instanceof
String[])) {
- return SelectUtils.getConvertedUISelectManyValue(context,(UISelectMany)component,
(String [])submittedValue);
- } else if ((component instanceof UISelectOne) && (submittedValue instanceof
String)) {
- return SelectUtils.getConvertedUIInputValue(context, (UISelectOne)component,
(String)submittedValue);
- } else {
- throw new IllegalArgumentException("Unsupported component class " +
component.getClass().getName());
- }
-
+ return ((Boolean) obj).booleanValue();
+ }
+
+ @Override
+ public Object getConvertedValue(FacesContext context, UIComponent component, Object
submittedValue) throws ConverterException {
+
+ if ((component instanceof UISelectMany) && (submittedValue instanceof String[]))
{
+ return SelectUtils.getConvertedUISelectManyValue(context, (UISelectMany) component,
(String[]) submittedValue);
+ } else if ((component instanceof UISelectOne) && (submittedValue instanceof
String)) {
+ return SelectUtils.getConvertedUIInputValue(context, (UISelectOne) component,
(String) submittedValue);
+ } else {
+ throw new ConverterException("Unsupported component class " +
component.getClass().getName());
}
-
- private void encodeRows(FacesContext context, UIComponent component, boolean source)
throws IOException {
- List selectItemsList = SelectUtils.getSelectItems(context,component);
- Converter converter = PickListUtils.findUISelectManyConverterFailsafe(context,
component);
- Set lookupSet = PickListUtils.getSubmittedOrSelectedValuesAsSet(true, component,
context, converter);
- List selectItemsForSelectedValues = selectItemsForSelectedList(context, component,
selectItemsList, converter, lookupSet); //TODO: optimaze
- List selectItemsForAvailableList = selectItemsForAvailableList(context, component,
selectItemsList, selectItemsForSelectedValues, converter);
- isSelectedList = !selectItemsForSelectedValues.isEmpty();
- isAvailableList = !selectItemsForAvailableList.isEmpty();
- List selectItemList = null;
- if (source) {
- selectItemList = selectItemsForAvailableList;
+
+ }
+
+ private void encodeRows(FacesContext context, UIComponent component, boolean source)
throws IOException {
+ List selectItemsList = SelectUtils.getSelectItems(context, component);
+
+ Converter converter = PickListUtils.findUISelectManyConverterFailsafe(context,
component);
+ List lookupList = PickListUtils.getValuesList(component, context, converter);
+ List selectItemsForSelectedValues = selectItemsForSelectedList(context, component,
selectItemsList, converter, lookupList);
+ List selectItemsForAvailableList = selectItemsForAvailableList(context, component,
selectItemsList, selectItemsForSelectedValues, converter);
+ isSelectedList = !selectItemsForSelectedValues.isEmpty();
+ isAvailableList = !selectItemsForAvailableList.isEmpty();
+
+ List selectItemList = null;
+ if (source) {
+ selectItemList = selectItemsForAvailableList;
+ } else {
+ selectItemList = selectItemsForSelectedValues;
+ }
+
+ int i = 0;
+ for (Iterator it = selectItemList.iterator(); it.hasNext();) {
+ i++;
+ SelectItem selectItem = (SelectItem) it.next();
+ if (selectItem instanceof SelectItemGroup) {
+ SelectItem[] items = ((SelectItemGroup) selectItem).getSelectItems();
+ for (int j = 0; j < items.length; j++) {
+ encodeItem(context, component, converter, items[i], source, "group:" +
Integer.toString(j));
+ }
} else {
- selectItemList = selectItemsForSelectedValues;
+ encodeItem(context, component, converter, selectItem, source, Integer.toString(i));
}
-
- int i = 0;
- for (Iterator it = selectItemList.iterator(); it.hasNext();) {
- i++;
- SelectItem selectItem = (SelectItem)it.next();
- if (selectItem instanceof SelectItemGroup) {
- //TODO
- } else {
- String itemStrValue = PickListUtils.getConvertedStringValue(context, component,
converter, selectItem.getValue());
-
- ResponseWriter writer = context.getResponseWriter();
- writer.startElement(HTML.TR_ELEMENT, component);
- String clientId = component.getClientId(context);
- if (source) {
- clientId += ":source:";
- }
- String id = clientId + ":" + i;
- writer.writeAttribute("id", id, null);
-
- StringBuffer rowClassName = new StringBuffer();
- StringBuffer cellClassName = new StringBuffer();
- if (source) {
- rowClassName.append("rich-picklist-source-row");
- cellClassName.append("rich-picklist-source-cell");
- } else {
- rowClassName.append("rich-picklist-target-row");
- cellClassName.append("rich-picklist-target-cell");
- }
-
- writer.writeAttribute("class", rowClassName.toString(), null);
- writer.startElement(HTML.td_ELEM, component);
- Object width = component.getAttributes().get("width");
- writer.writeAttribute(HTML.class_ATTRIBUTE, cellClassName, null);
-
- if (width != null) {
- writer.writeAttribute("style", "width: " +
HtmlUtil.qualifySize(width.toString()), null);
- }
-
- encodeSpacer(context, component, writer);
-
- boolean escape = isTrue(component.getAttributes().get("escape"));
- if (escape) {
- writer.writeText(selectItem.getLabel(), null);
- } else {
- writer.write(selectItem.getLabel());
- }
-
- encodeItemValue(context, component, writer, id, itemStrValue, lookupSet, i);
- writer.endElement(HTML.td_ELEM);
- writer.endElement(HTML.TR_ELEMENT);
- }
- }
}
-
- public void encodeTargetRows(FacesContext context, UIComponent component) throws
IOException {
- encodeRows(context, component, false);
+ }
+
+ public void encodeItem(FacesContext context, UIComponent component, Converter
converter, SelectItem selectItem, boolean source, String suff)
+ throws IOException {
+
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement(HTML.TR_ELEMENT, component);
+ String clientId = component.getClientId(context);
+ if (source) {
+ clientId += ":source:";
}
-
- public void encodeSourceRows(FacesContext context, UIComponent component) throws
IOException {
- encodeRows(context, component, true);
+ String id = clientId + ":" + suff;
+ writer.writeAttribute("id", id, null);
+
+ StringBuffer rowClassName = new StringBuffer();
+ StringBuffer cellClassName = new StringBuffer();
+ if (source) {
+ rowClassName.append("rich-picklist-source-row");
+ cellClassName.append("rich-picklist-source-cell");
+ } else {
+ rowClassName.append("rich-picklist-target-row");
+ cellClassName.append("rich-picklist-target-cell");
}
-
- private void encodeItemValue(FacesContext context, UIComponent component,
- ResponseWriter writer, String id,
- String itemStrValue, Set<SelectItem> lookupSet, int rowKey) throws
IOException { //rowKey = i
- writer.startElement(HTML.INPUT_ELEM, component);
- writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
- writer.writeAttribute(HTML.NAME_ATTRIBUTE, id, null);
- StringBuffer value = new StringBuffer();
- value.append(itemStrValue);
- writer.writeAttribute(HTML.value_ATTRIBUTE, value.toString(), null);
- writer.writeAttribute(HTML.id_ATTRIBUTE, id + "StateInput", null);
- writer.endElement(HTML.INPUT_ELEM);
+ writer.writeAttribute("class", rowClassName.toString(), null);
+ writer.startElement(HTML.td_ELEM, component);
+ Object width = component.getAttributes().get("width");
+ writer.writeAttribute(HTML.class_ATTRIBUTE, cellClassName, null);
+
+ if (width != null) {
+ writer.writeAttribute("style", "width: " +
HtmlUtil.qualifySize(width.toString()), null);
}
-
- protected void encodeSpacer(FacesContext context, UIComponent component,
- ResponseWriter writer) throws IOException {
- writer.startElement(HTML.IMG_ELEMENT, component);
- writer.writeAttribute(HTML.src_ATTRIBUTE,
getResource("/org/richfaces/renderkit/html/images/spacer.gif").getUri(context,
null), null);
- writer.writeAttribute(HTML.style_ATTRIBUTE, "width:1px;height:1px;",
null);
- writer.endElement(HTML.IMG_ELEMENT);
+
+ encodeSpacer(context, component, writer);
+
+ boolean escape = isTrue(component.getAttributes().get("escape"));
+ if (escape) {
+ writer.writeText(selectItem.getLabel(), null);
+ } else {
+ writer.write(selectItem.getLabel());
}
-
- public void encodeHiddenField(FacesContext context, UIComponent component) throws
IOException {
- UIPickList pl = (UIPickList) component;
- ResponseWriter writer = context.getResponseWriter();
- Converter converter = PickListUtils.findUISelectManyConverterFailsafe(context,
pl);
- Set lookupSet = PickListUtils.getSubmittedOrSelectedValuesAsSet(true, (UIPickList)
pl, context, converter);
- encodeHiddenField(context, pl, pl.getClientId(context) + HIDDEN_SUFFIX, lookupSet,
writer);
- }
-
- private void encodeHiddenField(FacesContext context, UIComponent component,
- String hiddenFieldCliendId, Set lookupSet, ResponseWriter writer) throws IOException
{
- writer.startElement(HTML.INPUT_ELEM, component);
- writer.writeAttribute(HTML.TYPE_ATTR, "hidden", "type");
- writer.writeAttribute(HTML.id_ATTRIBUTE, hiddenFieldCliendId, "id");
- writer.writeAttribute("name", hiddenFieldCliendId, null);
- StringBuffer sb = new StringBuffer();
- int n = 0;
-
- for (Iterator i = lookupSet.iterator(); i.hasNext();) {
- if (n > 0) {
- sb.append(",");
- }
- String value = (String) i.next();
- sb.append(value);
- n++;
- }
- writer.writeAttribute(HTML.value_ATTRIBUTE, sb.toString(), null);
- writer.endElement(HTML.INPUT_ELEM);
+ String itemValue = PickListUtils.getConvertedStringValue(context, component, converter,
selectItem.getValue());
+ encodeItemValue(context, component, writer, id, itemValue);
+ writer.endElement(HTML.td_ELEM);
+ writer.endElement(HTML.TR_ELEMENT);
+ }
+
+ public void encodeTargetRows(FacesContext context, UIComponent component) throws
IOException {
+ encodeRows(context, component, false);
+ }
+
+ public void encodeSourceRows(FacesContext context, UIComponent component) throws
IOException {
+ encodeRows(context, component, true);
+ }
+
+ private void encodeItemValue(FacesContext context, UIComponent component,
ResponseWriter writer, String id, String itemValue) throws IOException { //rowKey = i
+
+ writer.startElement(HTML.INPUT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, id, null);
+
+ StringBuffer value = new StringBuffer();
+
+ value.append(itemValue);
+ writer.writeAttribute(HTML.value_ATTRIBUTE, value.toString(), null);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, id + "StateInput", null);
+ writer.endElement(HTML.INPUT_ELEM);
+ }
+
+ protected void encodeSpacer(FacesContext context, UIComponent component,
ResponseWriter writer) throws IOException {
+ writer.startElement(HTML.IMG_ELEMENT, component);
+ writer.writeAttribute(HTML.src_ATTRIBUTE,
getResource("/org/richfaces/renderkit/html/images/spacer.gif").getUri(context,
null), null);
+ writer.writeAttribute(HTML.style_ATTRIBUTE, "width:1px;height:1px;", null);
+ writer.endElement(HTML.IMG_ELEMENT);
+ }
+
+ public void encodeHiddenField(FacesContext context, UIComponent component) throws
IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ Converter converter = PickListUtils.findUISelectManyConverterFailsafe(context,
component);
+ List lookupList = PickListUtils.getValuesList(component, context, converter);
+ encodeHiddenField(context, component, lookupList, writer);
+ }
+
+ private void encodeHiddenField(FacesContext context, UIComponent component, List
lookupList, ResponseWriter writer) throws IOException {
+ String hiddenFieldCliendId = component.getClientId(context) + HIDDEN_SUFFIX;
+ writer.startElement(HTML.INPUT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, "hidden", "type");
+ writer.writeAttribute(HTML.id_ATTRIBUTE, hiddenFieldCliendId, "id");
+ writer.writeAttribute("name", hiddenFieldCliendId, null);
+ StringBuffer sb = new StringBuffer();
+ int n = 0;
+
+ for (Iterator i = lookupList.iterator(); i.hasNext();) {
+ if (n > 0) {
+ sb.append(",");
+ }
+ String value = (String) i.next();
+ sb.append(value);
+ n++;
}
-
- protected Class <? extends UIComponent> getComponentClass() {
- return UIPickList.class;
- }
-
- public String getAsEventHandler(FacesContext context, UIComponent component, String
attributeName) {
- String event = (String) component.getAttributes().get(attributeName);
- ScriptString result = JSReference.NULL;
-
- if (event != null) {
- event = event.trim();
- if (event.length() != 0) {
- JSFunctionDefinition function = new JSFunctionDefinition();
- function.addParameter("event");
- function.addToBody(event);
- result = function;
- }
- }
- return ScriptUtils.toScript(result);
+ writer.writeAttribute(HTML.value_ATTRIBUTE, sb.toString(), null);
+ writer.endElement(HTML.INPUT_ELEM);
+ }
+
+ protected Class<? extends UIComponent> getComponentClass() {
+ return UIPickList.class;
+ }
+
+ public String getAsEventHandler(FacesContext context, UIComponent component, String
attributeName) {
+ String event = (String) component.getAttributes().get(attributeName);
+ ScriptString result = JSReference.NULL;
+
+ if (event != null) {
+ event = event.trim();
+ if (event.length() != 0) {
+ JSFunctionDefinition function = new JSFunctionDefinition();
+ function.addParameter("event");
+ function.addToBody(event);
+ result = function;
+ }
}
-
- public String getColumnClassesAsJSArray(FacesContext context, UIComponent component) {
- return ScriptUtils.toScript(getClassesAsList(context, component,
"columnClasses"));
+
+ return ScriptUtils.toScript(result);
+ }
+
+ public String getColumnClassesAsJSArray(FacesContext context, UIComponent component)
{
+ return ScriptUtils.toScript(getClassesAsList(context, component,
"columnClasses"));
+ }
+
+ public String getRowClassesAsJSArray(FacesContext context, UIComponent component) {
+ return ScriptUtils.toScript(getClassesAsList(context, component,
"rowClasses"));
+ }
+
+ protected List getClassesAsList(FacesContext context, UIComponent component, String
attr) {
+ String value = (String) ((UIComponent) component).getAttributes().get(attr);
+ if (value != null && (value.length() != 0)) {
+ return Arrays.asList(value.split(","));
}
-
- public String getRowClassesAsJSArray(FacesContext context, UIComponent component) {
- return ScriptUtils.toScript(getClassesAsList(context, component,
"rowClasses"));
- }
-
- protected List getClassesAsList(FacesContext context, UIComponent component, String
attr) {
- String value = (String) ((UIComponent) component).getAttributes().get(attr);
- if (value != null && (value.length() != 0)) {
- return Arrays.asList(value.split(","));
+ return null;
+ }
+
+ public void encodePickListControlsFacets(FacesContext context, UIComponent component)
throws IOException {
+ String clientId = component.getClientId(context);
+ ResponseWriter writer = context.getResponseWriter();
+ int divider = SHUTTLE_HELPERS.length / 2;
+ boolean enable = false;
+ for (int i = 0; i < SHUTTLE_HELPERS.length; i++) {
+ OrderingComponentRendererBase.ControlsHelper helper = SHUTTLE_HELPERS[i];
+ boolean isDisabled =
helper.getButtonStyleClass().equals(ListShuttleControlsHelper.DISABLED_STYLE_PREF);
+ if
(helper.getBundlePropertyName().equals(ListShuttleControlsHelper.BUNDLE_REMOVE_ALL_LABEL))
{
+ enable = isSelectedList;
+ if ((!enable && isDisabled) || (enable && !isDisabled)) {
+ enable = true;
+ } else {
+ enable = false;
}
- return null;
+ } else if
(helper.getBundlePropertyName().equals(ListShuttleControlsHelper.BUNDLE_COPY_ALL_LABEL))
{
+ enable = isAvailableList;
+ if ((!enable && isDisabled) || (enable && !isDisabled)) {
+ enable = true;
+ } else {
+ enable = false;
+ }
+ } else {
+ if (helper.getButtonStyleClass().equals(ListShuttleControlsHelper.DISABLED_STYLE_PREF))
{
+ enable = true;
+ } else {
+ enable = false;
+ }
+ }
+ encodeControlFacet(context, component, SHUTTLE_HELPERS[i], clientId, writer, enable,
"rich-list-picklist-button", " rich-picklist-control");
}
-
- public void encodePickListControlsFacets(FacesContext context, UIComponent component)
throws IOException {
- String clientId = component.getClientId(context);
- ResponseWriter writer = context.getResponseWriter();
- int divider = SHUTTLE_HELPERS.length / 2;
- boolean enable = false;
- for (int i = 0; i < SHUTTLE_HELPERS.length; i++) {
- OrderingComponentRendererBase.ControlsHelper helper = SHUTTLE_HELPERS[i];
- boolean isDisabled =
helper.getButtonStyleClass().equals(ListShuttleControlsHelper.DISABLED_STYLE_PREF);
- if
(helper.getBundlePropertyName().equals(ListShuttleControlsHelper.BUNDLE_REMOVE_ALL_LABEL))
{
- enable = isSelectedList;
- if ((!enable && isDisabled) || (enable && !isDisabled)) {
- enable = true;
- } else {
- enable = false;
- }
- } else if
(helper.getBundlePropertyName().equals(ListShuttleControlsHelper.BUNDLE_COPY_ALL_LABEL))
{
- enable = isAvailableList;
- if ((!enable && isDisabled) || (enable && !isDisabled)) {
- enable = true;
- } else {
- enable = false;
- }
- } else {
- if
(helper.getButtonStyleClass().equals(ListShuttleControlsHelper.DISABLED_STYLE_PREF)) {
- enable = true;
- } else {
- enable = false;
- }
- }
- encodeControlFacet(context, component, SHUTTLE_HELPERS[i], clientId, writer,
enable,
- "rich-list-picklist-button", "
rich-picklist-control");
- }
- }
-
- protected void encodeControlFacet(FacesContext context,
- UIComponent component, OrderingComponentRendererBase.ControlsHelper helper,
- String clientId, ResponseWriter writer, boolean enabled, String baseStyle,
- String baseControlStyle) 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 = component.getAttributes();
- UIComponent facet = component.getFacet(helper.getFacetName());
- boolean useFacet = (facet != null && facet.isRendered());
- renderDefaultControl(context, component, writer, useFacet, helper, clientId,
bundle ,enabled, baseStyle, baseControlStyle);
+ }
+
+ protected void encodeControlFacet(FacesContext context, UIComponent component,
OrderingComponentRendererBase.ControlsHelper helper, String clientId,
+ ResponseWriter writer, boolean enabled, String baseStyle, String baseControlStyle)
throws IOException {
+ Locale locale = null;
+
+ UIViewRoot viewRoot = context.getViewRoot();
+ if (viewRoot != null) {
+ locale = viewRoot.getLocale();
}
-
- protected void renderDefaultControl(FacesContext context,
- UIComponent orderingList, ResponseWriter writer,
- boolean useFacet, OrderingComponentRendererBase.ControlsHelper helper, String clientId,
ResourceBundle bundle,
- boolean enabled, String baseStyle, String baseControlStyle)
- throws IOException {
+
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ ResourceBundle bundle = null;
+
+ if (locale != null) {
+ try {
+ bundle = ResourceBundle.getBundle(bundleName, locale, contextClassLoader);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ Map attributes = component.getAttributes();
+ UIComponent facet = component.getFacet(helper.getFacetName());
+ boolean useFacet = (facet != null && facet.isRendered());
+ renderDefaultControl(context, component, writer, useFacet, helper, clientId, bundle,
enabled, baseStyle, baseControlStyle);
+ }
+
+ protected void renderDefaultControl(FacesContext context, UIComponent orderingList,
ResponseWriter writer, boolean useFacet,
+ OrderingComponentRendererBase.ControlsHelper helper, String clientId, ResourceBundle
bundle, boolean enabled, String baseStyle,
+ String baseControlStyle) 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);
+ customEvent = (String) attributes.get(helper.customEvent);
}
String styleFromAttribute = (String) attributes.get(helper.styleFromAttribute);
@@ -370,98 +374,97 @@
String currentStyle = baseControlStyle + helper.getStyleClassName();
if (styleFromAttribute != null) {
- currentStyle = styleFromAttribute.concat(currentStyle);
+ currentStyle = styleFromAttribute.concat(currentStyle);
}
writer.startElement(HTML.DIV_ELEM, orderingList);
String controlId = clientId + helper.getIdSuffix();
- writer.writeAttribute(HTML.id_ATTRIBUTE, controlId, null); //FIXME:
+ writer.writeAttribute(HTML.id_ATTRIBUTE, controlId, null); // FIXME:
writer.writeAttribute(HTML.class_ATTRIBUTE, currentStyle, null);
String style = null;
-
+
if (enabled) {
- style = "display:block;";
+ style = "display:block;";
} else {
- style = "display:none;";
+ style = "display:none;";
}
-
+
writer.writeAttribute(HTML.style_ATTRIBUTE, style, null);
-
+
if (!useFacet) {
- writer.startElement(HTML.DIV_ELEM, orderingList);
- writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + helper.getButtonStyleClass(),
null);
-
- if (helper.enable) {
- writer.writeAttribute(HTML.onmouseover_ATTRIBUTE, "this.className='" +
baseStyleLight + "'", null);
- writer.writeAttribute(HTML.onmousedown_ATTRIBUTE, "this.className='" +
baseStylePress + "'", null);
- writer.writeAttribute(HTML.onmouseup_ATTRIBUTE, "this.className='" +
baseStyle + "'", null);
- writer.writeAttribute(HTML.onmouseout_ATTRIBUTE, "this.className='" +
baseStyle + "'", null);
- }
-
+ writer.startElement(HTML.DIV_ELEM, orderingList);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle +
helper.getButtonStyleClass(), null);
+
+ if (helper.enable) {
+ writer.writeAttribute(HTML.onmouseover_ATTRIBUTE, "this.className='" +
baseStyleLight + "'", null);
+ writer.writeAttribute(HTML.onmousedown_ATTRIBUTE, "this.className='" +
baseStylePress + "'", null);
+ writer.writeAttribute(HTML.onmouseup_ATTRIBUTE, "this.className='" +
baseStyle + "'", null);
+ writer.writeAttribute(HTML.onmouseout_ATTRIBUTE, "this.className='" +
baseStyle + "'", null);
+ }
+
+ writer.startElement(HTML.a_ELEMENT, orderingList);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, controlId + "link", null); //
FIXME:
+ writer.writeAttribute(HTML.HREF_ATTR, "#", null);
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE, "return false;", null);
+
+ if (!helper.enable) {
+ writer.writeAttribute(HTML.DISABLED_ATTR, "disabled", null);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + "-a-disabled",
null);
writer.startElement(HTML.a_ELEMENT, orderingList);
- writer.writeAttribute(HTML.id_ATTRIBUTE, controlId + "link", null); //FIXME:
- writer.writeAttribute(HTML.HREF_ATTR, "#", null);
- writer.writeAttribute(HTML.onclick_ATTRIBUTE, "return false;", null);
-
- if (!helper.enable) {
- writer.writeAttribute(HTML.DISABLED_ATTR, "disabled", null);
- writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + "-a-disabled",
null);
- writer.startElement(HTML.a_ELEMENT, orderingList);
- } else {
- writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + "-selection",
null);
- writer.writeAttribute(HTML.onblur_ATTRIBUTE, "Control.onblur(this);",
null);
- writer.writeAttribute(HTML.onfocus_ATTRIBUTE, "Control.onfocus(this);",
null);
- }
-
- writer.startElement(HTML.DIV_ELEM, orderingList);
- writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + "-content", null);
+ } else {
+ writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + "-selection", null);
+ writer.writeAttribute(HTML.onblur_ATTRIBUTE, "Control.onblur(this);", null);
+ writer.writeAttribute(HTML.onfocus_ATTRIBUTE, "Control.onfocus(this);",
null);
+ }
+
+ writer.startElement(HTML.DIV_ELEM, orderingList);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + "-content",
null);
}
if (customEvent != null) {
- writer.writeAttribute(HTML.onclick_ATTRIBUTE, customEvent,null);
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE, customEvent, null);
}
-
+
if (useFacet) {
- renderChild(context, facet);
+ 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);
- //TODO check properties!!!
-// writer.write(helper.getDefaultText());
+ 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);
+ // TODO check properties!!!
+ // writer.write(helper.getDefaultText());
- if (getUtils().isBooleanAttribute(orderingList, SHOW_LABELS_ATTRIBUTE_NAME)) {
+ if (getUtils().isBooleanAttribute(orderingList, 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) {
- }
- }
+ 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.equals("")) {
- label = helper.getDefaultText();
- }
-
- writer.write(label);
+ if (label == null || label.equals("")) {
+ label = helper.getDefaultText();
}
+
+ writer.write(label);
+ }
}
-
+
if (!useFacet) {
- writer.endElement(HTML.DIV_ELEM);
+ writer.endElement(HTML.DIV_ELEM);
+ if (!helper.enable) {
+ writer.endElement(HTML.a_ELEMENT);
+ }
- if (!helper.enable) {
- writer.endElement(HTML.a_ELEMENT);
- }
-
- writer.endElement(HTML.a_ELEMENT);
- writer.endElement(HTML.DIV_ELEM);
+ writer.endElement(HTML.a_ELEMENT);
+ writer.endElement(HTML.DIV_ELEM);
}
writer.endElement(HTML.DIV_ELEM);
- }
- }
+ }
+}