Author: abelevich
Date: 2008-02-05 13:33:50 -0500 (Tue, 05 Feb 2008)
New Revision: 5839
Removed:
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListControlsHelper.java
Modified:
trunk/sandbox/ui/pickList/src/main/config/component/picklist.xml
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/picklist/util/PickListUtils.java
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java
Log:
clean classes
Modified: trunk/sandbox/ui/pickList/src/main/config/component/picklist.xml
===================================================================
--- trunk/sandbox/ui/pickList/src/main/config/component/picklist.xml 2008-02-05 18:05:00
UTC (rev 5838)
+++ trunk/sandbox/ui/pickList/src/main/config/component/picklist.xml 2008-02-05 18:33:50
UTC (rev 5839)
@@ -65,6 +65,36 @@
</property>
<property>
+ <name>showButtonLabels</name>
+ <classname>java.lang.String</classname>
+ <defaultvalue>"true"</defaultvalue>
+ </property>
+
+ <property>
+ <name>copyAllControlLabel</name>
+ <classname>java.lang.String</classname>
+ <defaultvalue>""</defaultvalue>
+ </property>
+
+ <property>
+ <name>copyControlLabel</name>
+ <classname>java.lang.String</classname>
+ <defaultvalue>""</defaultvalue>
+ </property>
+
+ <property>
+ <name>removeControlLabel</name>
+ <classname>java.lang.String</classname>
+ <defaultvalue>""</defaultvalue>
+ </property>
+
+ <property>
+ <name>removeAllControlLabel</name>
+ <classname>java.lang.String</classname>
+ <defaultvalue>""</defaultvalue>
+ </property>
+
+ <property>
<name>value</name>
<classname>java.lang.String</classname>
</property>
Modified:
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/picklist/util/PickListUtils.java
===================================================================
---
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/picklist/util/PickListUtils.java 2008-02-05
18:05:00 UTC (rev 5838)
+++
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/picklist/util/PickListUtils.java 2008-02-05
18:33:50 UTC (rev 5839)
@@ -8,6 +8,7 @@
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;
@@ -15,7 +16,6 @@
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
-import javax.faces.el.ValueBinding;
import javax.faces.model.SelectItem;
import org.ajax4jsf.util.SelectUtils;
@@ -37,10 +37,10 @@
if (converter != null) return converter;
//Try to find out by value binding
- ValueBinding vb = component.getValueBinding("value");
- if (vb == null) return null;
+ ValueExpression ve = component.getValueExpression("value");
+ if (ve == null) return null;
- Class valueType = vb.getType(context);
+ Class valueType = ve.getType(context.getELContext());
if (valueType == null) return null;
if (List.class.isAssignableFrom(valueType)) {
Deleted:
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListControlsHelper.java
===================================================================
---
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListControlsHelper.java 2008-02-05
18:05:00 UTC (rev 5838)
+++
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListControlsHelper.java 2008-02-05
18:33:50 UTC (rev 5839)
@@ -1,147 +0,0 @@
-package org.richfaces.renderkit;
-
-import javax.faces.context.FacesContext;
-
-import org.richfaces.component.UIListShuttle;
-import org.richfaces.component.UIOrderingBaseComponent;
-import org.richfaces.renderkit.html.images.ListShuttleIconCopy;
-import org.richfaces.renderkit.html.images.ListShuttleIconCopyAll;
-import org.richfaces.renderkit.html.images.ListShuttleIconCopyAllDisabled;
-import org.richfaces.renderkit.html.images.ListShuttleIconCopyDisabled;
-import org.richfaces.renderkit.html.images.ListShuttleIconRemove;
-import org.richfaces.renderkit.html.images.ListShuttleIconRemoveAll;
-import org.richfaces.renderkit.html.images.ListShuttleIconRemoveAllDisabled;
-import org.richfaces.renderkit.html.images.ListShuttleIconRemoveDisabled;
-
-public class PickListControlsHelper {
-
- private final static String FACET_COPY_ALL = "copyAllControl";
-
- private final static String FACET_REMOVE_ALL = "removeAllControl";
-
- private final static String FACET_COPY = "copyControl";
-
- private final static String FACET_REMOVE = "removeControl";
-
- private final static String FACET_DIS_COPY_ALL = FACET_COPY_ALL + "Disabled";
-
- private final static String FACET_DIS_REMOVE_ALL = FACET_REMOVE_ALL +
"Disabled";
-
- private final static String FACET_DIS_COPY = FACET_COPY + "Disabled";
-
- private final static String FACET_DIS_REMOVE = FACET_REMOVE + "Disabled";
-
- public final static String FACET_CAPTION = "caption";
-
- private final static String ATTRIBUTE_CE_ONCOPYALLCLICK = "oncopyallclick";
-
- private final static String ATTRIBUTE_CE_ONREMOVECLICK = "onremoveclick";
-
- private final static String ATTRIBUTE_CE_ONCOPYCLICK = "oncopyclick";
-
- private final static String ATTRIBUTE_CE_ONREMOVEALLCLICK =
"onremoveallclick";
-
- public final static String ATTRIBUTE_SOURCE_CAPTION_LABEL =
"sourceCaptionLabel";
-
- public final static String ATTRIBUTE_TARGET_CAPTION_LABEL =
"targetCaptionLabel";
-
- private final static String ATTRIBUTE_CLASS_COPY_ALL_CONTROL = FACET_COPY_ALL +
"Class";
-
- private final static String ATTRIBUTE_CLASS_REMOVE_ALL_CONTROL = FACET_REMOVE_ALL +
"Class";
-
- private final static String ATTRIBUTE_CLASS_REMOVE_CONTROL = FACET_REMOVE +
"Class";
-
- private final static String ATTRIBUTE_CLASS_COPY_CONTROL = FACET_COPY +
"Class";
-
- private final static String ATTRIBUTE_CLASS_DISABLED_CONTROL =
"disabledControlClass";
-
- private final static String DIS_CONTROL_ID_PREFIX = "dis";
-
- private final static String CONTROL_ID_COPY_ALL = "copyAll";
-
- private final static String CONTROL_ID_COPY = "copy";
-
- private final static String CONTROL_ID_REMOVE = "remove";
-
- private final static String CONTROL_ID_REMOVE_ALL = "removeAll";
-
- public final static String DEFAULT_LABEL_COPY_ALL = "Copy all";
- private final static String DEFAULT_LABEL_COPY = "Copy";
- private final static String DEFAULT_LABEL_REMOVE = "Remove";
- public final static String DEFAULT_LABEL_REMOVE_ALL = "Remove All";
-
- protected static final OrderingComponentRendererBase.ControlsHelper[] HELPERS = new
OrderingComponentRendererBase.ControlsHelper[] {
- new OrderingComponentRendererBase.ControlsHelper("copyAll",
"COPY_ALL_LABEL", DEFAULT_LABEL_COPY_ALL,
ListShuttleIconCopyAll.class.getName(), FACET_COPY_ALL,
- "-copyall", ATTRIBUTE_CLASS_COPY_ALL_CONTROL, "",
- CONTROL_ID_COPY_ALL, ATTRIBUTE_CE_ONCOPYALLCLICK, true,
"copyAll".concat(OrderingComponentControlsHelper.CONTROL_LABEL_ATTRIBUTE_SUFFIX))
{
-
- public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
- return true;
- }
-
- },
- new OrderingComponentRendererBase.ControlsHelper("disabledCopyAll",
"COPY_ALL_LABEL", DEFAULT_LABEL_COPY_ALL,
ListShuttleIconCopyAllDisabled.class.getName(), FACET_DIS_COPY_ALL,
- "-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL, "-disabled",
- DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_COPY_ALL), null, false,
"copyAll".concat(OrderingComponentControlsHelper.CONTROL_LABEL_ATTRIBUTE_SUFFIX))
{
-
- public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
- return true;
- }
-
- },
- new OrderingComponentRendererBase.ControlsHelper("copy",
"COPY_LABEL", DEFAULT_LABEL_COPY, ListShuttleIconCopy.class.getName(),
FACET_COPY,
- "-copy", ATTRIBUTE_CLASS_COPY_CONTROL, "",
- CONTROL_ID_COPY, ATTRIBUTE_CE_ONCOPYCLICK ,false,
"copy".concat(OrderingComponentControlsHelper.CONTROL_LABEL_ATTRIBUTE_SUFFIX))
{
-
- public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
- return true;
- }
-
- },
- new OrderingComponentRendererBase.ControlsHelper("disabledCopy",
"COPY_LABEL", DEFAULT_LABEL_COPY, ListShuttleIconCopyDisabled.class.getName(),
FACET_DIS_COPY,
- "-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL, "-disabled",
- DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_COPY), null, true,
"copy".concat(OrderingComponentControlsHelper.CONTROL_LABEL_ATTRIBUTE_SUFFIX))
{
-
- public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
- return true;
- }
-
- },
- new OrderingComponentRendererBase.ControlsHelper("remove",
"REMOVE_LABEL", DEFAULT_LABEL_REMOVE, ListShuttleIconRemove.class.getName(),
FACET_REMOVE,
- "-remove", ATTRIBUTE_CLASS_REMOVE_CONTROL, "",
- CONTROL_ID_REMOVE, ATTRIBUTE_CE_ONREMOVECLICK, false,
"remove".concat(OrderingComponentControlsHelper.CONTROL_LABEL_ATTRIBUTE_SUFFIX))
{
-
- public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
- return true;
- }
-
- },
- new OrderingComponentRendererBase.ControlsHelper("disabledRemove",
"REMOVE_LABEL", DEFAULT_LABEL_REMOVE,
ListShuttleIconRemoveDisabled.class.getName(), FACET_DIS_REMOVE,
- "-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL, "-disabled",
- DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_REMOVE), null, true,
"remove".concat(OrderingComponentControlsHelper.CONTROL_LABEL_ATTRIBUTE_SUFFIX))
{
-
- public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
- return true;
- }
-
- },
- new OrderingComponentRendererBase.ControlsHelper("removeAll",
"REMOVE_ALL_LABEL", DEFAULT_LABEL_REMOVE_ALL,
ListShuttleIconRemoveAll.class.getName(), FACET_REMOVE_ALL,
- "-removeall", ATTRIBUTE_CLASS_REMOVE_ALL_CONTROL, "",
- CONTROL_ID_REMOVE_ALL, ATTRIBUTE_CE_ONREMOVEALLCLICK, true,
"removeAll".concat(OrderingComponentControlsHelper.CONTROL_LABEL_ATTRIBUTE_SUFFIX))
{
-
- public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
- return true;
- }
-
- },
- new OrderingComponentRendererBase.ControlsHelper("disabledRemoveAll",
"REMOVE_ALL_LABEL", DEFAULT_LABEL_REMOVE_ALL,
ListShuttleIconRemoveAllDisabled.class.getName(), FACET_DIS_REMOVE_ALL,
- "-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL, "-disabled",
- DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_REMOVE_ALL), null, false,
"removeAll".concat(OrderingComponentControlsHelper.CONTROL_LABEL_ATTRIBUTE_SUFFIX))
{
-
- public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
- return true;
- }
-
- }
- };
-}
Modified:
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java
===================================================================
---
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java 2008-02-05
18:05:00 UTC (rev 5838)
+++
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java 2008-02-05
18:33:50 UTC (rev 5839)
@@ -3,9 +3,8 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashSet;
+import java.util.Collection;
import java.util.Iterator;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -18,7 +17,6 @@
import javax.faces.component.UISelectMany;
import javax.faces.component.UISelectOne;
import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
@@ -34,32 +32,25 @@
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.util.SelectUtils;
import org.apache.commons.collections.CollectionUtils;
-import org.richfaces.component.UIListShuttle;
-import org.richfaces.component.UIOrderingBaseComponent;
import org.richfaces.component.UIPickList;
import org.richfaces.component.util.HtmlUtil;
import org.richfaces.picklist.util.PickListUtils;
-import org.richfaces.renderkit.OrderingComponentRendererBase.SelectionState;
public class PickListRenderer extends HeaderResourcesRendererBase {
- private static final String AVAILABLE_SUFFIX = "_AVAILABLE";
- private static final String SELECTED_SUFFIX = "_SELECTED";
private static final String HIDDEN_SUFFIX = "valueKeeper";
- private static final String FUNCTION_ADD_TO_SELECTED =
"myfaces_picklist_addToSelected";
- private static final String FUNCTION_REMOVE_FROM_SELECTED =
"myfaces_picklist_removeFromSelected";
protected static final OrderingComponentRendererBase.ControlsHelper[] SHUTTLE_HELPERS
= ListShuttleControlsHelper.HELPERS;
protected final static String SHOW_LABELS_ATTRIBUTE_NAME =
"showButtonLabels";
private static final String MESSAGE_BUNDLE_NAME =
OrderingListRendererBase.class.getPackage().getName() + "ListShuttle";
private boolean isSelectedList;
private boolean isAvailableList;
- protected List selectItemsForSelectedList(FacesContext facesContext,UIComponent
uiComponent, List selectItemList, Converter converter, Set lookupSet) {
- List selectItemForSelectedValues = new ArrayList(lookupSet.size());
- for (Iterator i = selectItemList.iterator(); i.hasNext();) {
- SelectItem selectItem = (SelectItem) i.next();
+ 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 i2 = lookupSet.iterator(); i2.hasNext();) {
+ for (Iterator <SelectItem> i2 = lookupSet.iterator(); i2.hasNext();) {
Object value = i2.next();
if (value.equals(itemStrValue)) {
selectItemForSelectedValues.add(selectItem);
@@ -69,8 +60,9 @@
return selectItemForSelectedValues;
}
- protected List selectItemsForAvailableList(FacesContext facesContext, UIComponent
uiComponent, List selectItemList, List selectItemsForSelectedList, Converter converter) {
- return new ArrayList(CollectionUtils.subtract(selectItemList,
selectItemsForSelectedList));
+ 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) {
@@ -81,14 +73,12 @@
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");
}
@@ -100,42 +90,19 @@
return;
}
- /*String[] valuesInline = getSubmittedValues(context, component);
- if (valuesInline == null || (valuesInline[0] == null) ||
"".equals(valuesInline[0].trim())) {
- ((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 {
- String[] reqValues = valuesInline[0].split(",");
- ((EditableValueHolder) picklist).setSubmittedValue(reqValues);
- }
+ if (valuesInline[0].trim().equals("")) {
+ ((EditableValueHolder) picklist).setSubmittedValue(new String[] {});
+ } else {
+ String[] reqValues = valuesInline[0].split(",");
+ ((EditableValueHolder) picklist).setSubmittedValue(reqValues);
+ }
} else {
((EditableValueHolder) picklist).setSubmittedValue(new String[] {});
}
}
- private String[] getSubmittedValues(FacesContext context, UIComponent component) {
- UIListShuttle listShuttle = (UIListShuttle) component;
-
- String clientId = listShuttle.getBaseClientId(context);
- ExternalContext externalContext = context.getExternalContext();
- Map requestParameterMap = externalContext.getRequestParameterMap();
-
- String[] strings = null;
-
- if (requestParameterMap.containsKey(clientId)) {
- strings = (String[]) externalContext.getRequestParameterValuesMap().get(clientId);
- }
- return strings;
- }
-
private boolean isDisabledOrReadOnly(UIPickList picklist) {
return picklist.isDisplayValueOnly() ||
isTrue(picklist.getAttributes().get("disabled"));
}
@@ -162,97 +129,66 @@
}
private void encodeRows(FacesContext context, UIComponent component, boolean source)
throws IOException {
- List <SelectItem> selectItemsList =
SelectUtils.getSelectItems(context,component);
+ 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;
+ selectItemList = selectItemsForAvailableList;
} else {
- selectItemList = selectItemsForSelectedValues;
+ selectItemList = selectItemsForSelectedValues;
}
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);
- 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");
- }
-
- /*
- * String rowClass = holder.getRowClass();
- if (rowClass != null) {
- rowClassName.append(' ');
- rowClassName.append(rowClass);
- }
- */
-
- /*
- * boolean active = itemState.isActive();
- boolean selected = itemState.isSelected();
- selectionState.addState(selected);
- if (selected) {
- if (source) {
- rowClassName.append(" rich-shuttle-source-row-selected");
- cellClassName.append(" rich-shuttle-source-cell-selected");
- } else {
- rowClassName.append(" rich-shuttle-target-row-selected");
- cellClassName.append(" rich-shuttle-target-cell-selected");
- }
- }
- */
- 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);
- }
- /*
- * String columnClass = holder.getColumnClass(colCounter);
- if (columnClass != null) {
- writer.writeAttribute("class", cellClassName.toString().concat("
" + columnClass), null);
- } else {
- writer.writeAttribute("class", cellClassName.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);
- }
+ 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);
+ 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);
+ }
}
}
@@ -266,30 +202,16 @@
private void encodeItemValue(FacesContext context, UIComponent component,
ResponseWriter writer, String id,
- String itemStrValue, Set lookupSet, int rowKey) throws IOException { //rowKey =
i
+ 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();
- //if (lookupSet.contains(itemStrValue)) {
- //value.append('s');
- //}
-
- /*if (active) {
- value.append('a');
- }*/
-
- //value.append(rowKey);
- //value.append(':');
- //value.append(shuttleRendererTableHolder.getConverter().getAsString(context, table,
table.getRowData()));
- value.append(itemStrValue); //??
-
- writer.writeAttribute(HTML.value_ATTRIBUTE, value.toString(), null);
-
- writer.writeAttribute(HTML.id_ATTRIBUTE, id + "StateInput", null);
-
- writer.endElement(HTML.INPUT_ELEM);
+ value.append(itemStrValue);
+ 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,
@@ -310,14 +232,13 @@
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(",");
@@ -332,7 +253,7 @@
}
- protected Class<? extends UIComponent> getComponentClass() {
+ protected Class <? extends UIComponent> getComponentClass() {
return UIPickList.class;
}
@@ -342,12 +263,10 @@
if (event != null) {
event = event.trim();
-
if (event.length() != 0) {
JSFunctionDefinition function = new JSFunctionDefinition();
function.addParameter("event");
function.addToBody(event);
-
result = function;
}
}
@@ -364,7 +283,6 @@
}
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(","));
@@ -372,19 +290,16 @@
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;
+ 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;
for (int i = 0; i < SHUTTLE_HELPERS.length; i++) {
- OrderingComponentRendererBase.ControlsHelper helper = SHUTTLE_HELPERS[i];
- if
(helper.getDefaultText().equals(PickListControlsHelper.DEFAULT_LABEL_REMOVE_ALL)) {
+ OrderingComponentRendererBase.ControlsHelper helper = SHUTTLE_HELPERS[i];
+ if
(helper.getDefaultText().equals(ListShuttleControlsHelper.CONTROL_ID_REMOVE_ALL)) {
enable = isSelectedList;
- } else if
(helper.getDefaultText().equals(PickListControlsHelper.DEFAULT_LABEL_COPY_ALL)) {
+ } else if
(helper.getDefaultText().equals(ListShuttleControlsHelper.CONTROL_ID_COPY_ALL)) {
enable = isAvailableList;
} else {
if
(helper.getButtonStyleClass().equals(ListShuttleControlsHelper.DISABLED_STYLE_PREF)) {
@@ -396,7 +311,7 @@
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,
@@ -416,16 +331,13 @@
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);
+ renderDefaultControl(context, component, writer, useFacet, helper, clientId,
bundle ,enabled, baseStyle, baseControlStyle);
}
protected void renderDefaultControl(FacesContext context,
@@ -436,17 +348,16 @@
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 styleFromAttribute = (String) attributes.get(helper.styleFromAttribute);
String baseStyleLight = baseStyle.concat("-light");
String baseStylePress = baseStyle.concat("-press");
-
String currentStyle = baseControlStyle + helper.getStyleClassName();
+
if (styleFromAttribute != null) {
currentStyle = styleFromAttribute.concat(currentStyle);
}
@@ -456,16 +367,19 @@
writer.writeAttribute(HTML.id_ATTRIBUTE, controlId, null); //FIXME:
writer.writeAttribute(HTML.class_ATTRIBUTE, currentStyle, null);
String style = null;
+
if (enabled) {
style = "display:block;";
} else {
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);
@@ -477,6 +391,7 @@
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);
@@ -489,7 +404,6 @@
writer.startElement(HTML.DIV_ELEM, orderingList);
writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + "-content", null);
-
}
if (customEvent != null) {
@@ -503,44 +417,40 @@
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.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)) {
+
String label = (String) attributes.get(helper.getLabelAttributeName());
-
if (label == null && bundle != null) {
try {
label = bundle.getString(helper.getBundlePropertyName());
} catch (MissingResourceException e) {
-
}
}
- if (label == null) {
+ if (label == null || label.equals("")) {
label = helper.getDefaultText();
}
- writer.writeText(label, null);
+ writer.write(label);
}
}
- // writer.writeAttribute(HTML.id_ATTRIBUTE, clientId +
- // helper.getIdSuffix(), null);
-
- // writer.writeAttribute(HTML.class_ATTRIBUTE, currentStyle, null);
if (!useFacet) {
writer.endElement(HTML.DIV_ELEM);
+
if (!helper.enable) {
writer.endElement(HTML.a_ELEMENT);
}
+
writer.endElement(HTML.a_ELEMENT);
writer.endElement(HTML.DIV_ELEM);
}
writer.endElement(HTML.DIV_ELEM);
-}
+ }
}