Author: nbelaevski
Date: 2007-11-25 22:05:55 -0500 (Sun, 25 Nov 2007)
New Revision: 4248
Added:
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleControlsHelper.java
Modified:
branches/3.1.x/sandbox/ui/listShuttle/src/main/config/component/listShuttle.xml
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleRowKey.java
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java
branches/3.1.x/sandbox/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js
branches/3.1.x/sandbox/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx
Log:
latest changes for listShuttle
Modified: branches/3.1.x/sandbox/ui/listShuttle/src/main/config/component/listShuttle.xml
===================================================================
---
branches/3.1.x/sandbox/ui/listShuttle/src/main/config/component/listShuttle.xml 2007-11-26
03:05:40 UTC (rev 4247)
+++
branches/3.1.x/sandbox/ui/listShuttle/src/main/config/component/listShuttle.xml 2007-11-26
03:05:55 UTC (rev 4248)
@@ -37,11 +37,14 @@
<defaultvalue>"default"</defaultvalue>
</property>
-->
+ <property hidden="true" exist="true">
+ <name>value</name>
+ </property>
<property hidden="true" el="false">
<name>submittedValue</name>
</property>
<property hidden="true" el="false"
exist="true">
- <name>submittedString</name>
+ <name>submittedStrings</name>
</property>
<property hidden="true" el="false">
<name>localValueSet</name>
Modified:
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java
===================================================================
---
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java 2007-11-26
03:05:40 UTC (rev 4247)
+++
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java 2007-11-26
03:05:55 UTC (rev 4248)
@@ -5,23 +5,35 @@
package org.richfaces.component;
import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
+import javax.faces.convert.ConverterException;
import javax.faces.el.MethodBinding;
import javax.faces.el.ValueBinding;
+import javax.faces.event.ValueChangeEvent;
import javax.faces.event.ValueChangeListener;
import javax.faces.model.DataModel;
+import org.apache.commons.collections.map.CompositeMap;
+import org.richfaces.component.UIOrderingBaseComponent.UpdateModelCommand;
import org.richfaces.component.UIOrderingList.SubmittedValue;
+import org.richfaces.component.UIOrderingList.ValueHolder;
import org.richfaces.model.ListShuttleDataModel;
import org.richfaces.model.ListShuttleRowKey;
-import org.richfaces.model.TranslatedSequenceDataModel;
/**
* JSF component class
@@ -39,41 +51,74 @@
*/
private static final long serialVersionUID = 5655312942714191981L;
//ListShuttleRowKey -> ListShuttleRowKey
- private Map translationTable = new LinkedHashMap();
+ private Map sourceTranslationTable = new LinkedHashMap();
+ private Map targetTranslationTable = new LinkedHashMap();
+
private Set selectedItems = new HashSet();
- private ListShuttleRowKey[] activeItems;
+ private List activeItems = new ArrayList();
- public SubmittedValue(String submittedString) {
+ public SubmittedValue(String[] submittedStrings) {
super();
- fromString(submittedString);
+
+ sourceListFromString(submittedStrings[0]);
+ targetListFromString(submittedStrings[1]);
}
+
+ private void convertAndStoreKey(String keyString, int i, boolean keySource) {
+ Matcher matcher = Pattern.compile("(s|t)(\\d+)(s?a?)").matcher(keyString);
+ matcher.matches();
+
+ try {
+ char c = matcher.group(1).charAt(0);
+ boolean source;
+
+ if (c == 's') {
+ source = true;
+ } else if (c == 't') {
+ source = false;
+ } else {
+ throw new IllegalArgumentException();
+ }
+
+ Integer key = Integer.valueOf(matcher.group(2));
+
+ ListShuttleRowKey orderKey = new ListShuttleRowKey(Integer.valueOf(i),
keySource);
+ ListShuttleRowKey result = new ListShuttleRowKey(key, source);
+
+ Map translationMap = keySource ? sourceTranslationTable : targetTranslationTable;
+
+ translationMap.put(orderKey, result);
+
+ String group = matcher.group(3);
+ for (int j = 0; j < group.length(); j++) {
+ c = group.charAt(j);
+ if ('s' == c) {
+ selectedItems.add(orderKey);
+ } else if ('a' == c) {
+ activeItems.add(orderKey);
+ } else {
+ break ;
+ }
+
+ }
+ } catch (NumberFormatException e) {
+ // TODO: handle exception
+ }
+ }
- private void fromString(String string) {
-// String[] valueOrder = string.split(",");
-// permutationOrder = new int[valueOrder.length];
-// for (int i = 0; i < valueOrder.length; i++) {
-// Matcher matcher =
Pattern.compile("(\\d+)(s?a?)").matcher(valueOrder[i]);
-// matcher.matches();
-//
-// try {
-// permutationOrder[i] = Integer.valueOf(matcher.group(1)).intValue();
-// String group = matcher.group(2);
-// for (int j = 0; j < group.length(); j++) {
-// char c = group.charAt(j);
-// if ('s' == c) {
-// selectedItems.add(new Integer(permutationOrder[i]));
-// } else if ('a' == c) {
-// activeItem = new Integer(permutationOrder[i]);
-// } else {
-// break ;
-// }
-//
-// }
-// } catch (NumberFormatException e) {
-// // TODO: handle exception
-// }
-// }
+ private void targetListFromString(String string) {
+ String[] valueOrder = string.split(",");
+ for (int i = 0; i < valueOrder.length; i++) {
+ convertAndStoreKey(valueOrder[i], i, false);
+ }
}
+
+ private void sourceListFromString(String string) {
+ String[] valueOrder = string.split(",");
+ for (int i = 0; i < valueOrder.length; i++) {
+ convertAndStoreKey(valueOrder[i], i, true);
+ }
+ }
public String toString() {
StringBuffer result = new StringBuffer();
@@ -97,13 +142,30 @@
return result.toString();
}
- public Map getTranslationTable() {
- return translationTable;
+ public Map getSourceTranslationTable() {
+ return sourceTranslationTable;
}
+
+ public Map getTargetTranslationTable() {
+ return targetTranslationTable;
+ }
}
private transient SubmittedValue submittedValueHolder = null;
+ protected static final class ValueHolder implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2124352131407581704L;
+
+ private Object sourceValue;
+ private boolean sourceValueSet;
+
+ private Object targetValue;
+ private boolean targetValueSet;
+ }
+
private Object sourceValue;
private boolean sourceValueSet;
@@ -139,6 +201,7 @@
public void setSourceValue(Object sourceValue) {
this.sourceValue = sourceValue;
+ this.sourceValueSet = true;
}
public Object getLocalTargetValue() {
@@ -160,29 +223,47 @@
public void setTargetValue(Object targetValue) {
this.targetValue = targetValue;
+ this.targetValueSet = true;
}
- public String getSubmittedString() {
+ public String[] getSubmittedStrings() {
return null;
}
- public void setSubmittedString(String submittedString) {
-
+ public void setSubmittedStrings(String[] submittedStrings) {
+ //TODO check for parameters correlation
+ this.submittedValueHolder = new SubmittedValue(submittedStrings);
}
- public Object saveIterationSubmittedState() {
- return null;
+ protected Object saveIterationSubmittedState() {
+ return submittedValueHolder;
}
- public void restoreIterationSubmittedState(Object object) {
+ protected void restoreIterationSubmittedState(Object object) {
+ this.submittedValueHolder = (SubmittedValue) object;
}
- public Object saveIterationState() {
- return null;
- }
+ protected Object saveIterationState() {
+ ValueHolder holder = new ValueHolder();
- public void restoreIterationState(Object object) {
+ holder.sourceValue = sourceValue;
+ holder.sourceValueSet = sourceValueSet;
+
+ holder.targetValue = targetValue;
+ holder.targetValueSet = targetValueSet;
+
+ return holder;
}
+
+ protected void restoreIterationState(Object object) {
+ ValueHolder holder = (ValueHolder) object;
+
+ sourceValue = holder.sourceValue ;
+ sourceValueSet = holder.sourceValueSet;
+
+ targetValue = holder.targetValue;
+ targetValueSet = holder.targetValueSet;
+ }
public org.ajax4jsf.model.ExtendedDataModel createDataModel() {
DataModel sourceDataModel = createDataModel(getSourceValue());
@@ -190,7 +271,10 @@
if (isTranslatedRenderingState() || isTranslatedState()) {
return new ListShuttleDataModel(sourceDataModel, targetDataModel,
- isTranslatedState(), submittedValueHolder != null ?
submittedValueHolder.translationTable : null);
+ isTranslatedState(),
+ submittedValueHolder != null ?
+ new CompositeMap(submittedValueHolder.sourceTranslationTable,
submittedValueHolder.targetTranslationTable)
+ : null);
} else {
return new ListShuttleDataModel(sourceDataModel, targetDataModel, false, null);
}
@@ -219,4 +303,289 @@
ListShuttleDataModel dataModel = (ListShuttleDataModel) getExtendedDataModel();
return dataModel.isTarget();
}
+
+ public String getSourceSubmittedString() {
+ //TODO implement
+ return "";
+ }
+
+ public String getTargetSubmittedString() {
+ //TODO implement
+ return "";
+ }
+
+ private final UpdateModelCommand updateSourceCommand = new UpdateModelCommand() {
+
+ public void execute(FacesContext context) {
+ if (sourceValueSet) {
+ ValueBinding vb = getValueBinding("sourceValue");
+ if (vb != null) {
+ vb.setValue(context, sourceValue);
+ sourceValue = null;
+ sourceValueSet = false;
+ }
+ }
+ }
+
+ };
+
+ private final UpdateModelCommand updateTargetCommand = new UpdateModelCommand() {
+
+ public void execute(FacesContext context) {
+ if (targetValueSet) {
+ ValueBinding vb = getValueBinding("targetValue");
+ if (vb != null) {
+ vb.setValue(context, targetValue);
+ targetValue = null;
+ targetValueSet = false;
+ }
+ }
+ }
+
+ };
+
+ /**
+ * <p>Perform the following algorithm to update the model data
+ * associated with this {@link UIInput}, if any, as appropriate.</p>
+ * <ul>
+ * <li>If the <code>valid</code> property of this component is
+ * <code>false</code>, take no further action.</li>
+ * <li>If the <code>localValueSet</code> property of this component
is
+ * <code>false</code>, take no further action.</li>
+ * <li>If no {@link ValueBinding} for <code>value</code> exists,
+ * take no further action.</li>
+ * <li>Call <code>setValue()</code> method of the {@link
ValueBinding}
+ * to update the value that the {@link ValueBinding} points at.</li>
+ * <li>If the <code>setValue()</code> method returns successfully:
+ * <ul>
+ * <li>Clear the local value of this {@link UIInput}.</li>
+ * <li>Set the <code>localValueSet</code> property of this
+ * {@link UIInput} to false.</li>
+ * </ul></li>
+ * <li>If the <code>setValue()</code> method call fails:
+ * <ul>
+ * <li>Enqueue an error message by calling
<code>addMessage()</code>
+ * on the specified {@link FacesContext} instance.</li>
+ * <li>Set the <code>valid</code> property of this {@link
UIInput}
+ * to <code>false</code>.</li>
+ * </ul></li>
+ * </ul>
+ *
+ * @param context {@link FacesContext} for the request we are processing
+ *
+ * @exception NullPointerException if <code>context</code>
+ * is <code>null</code>
+ */
+ public void updateModel(FacesContext context) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (!isValid()) {
+ return;
+ }
+
+ updateModel(context, updateSourceCommand);
+ updateModel(context, updateTargetCommand);
+ }
+
+
+ // ------------------------------------------------------ Validation Methods
+
+
+ /**
+ * <p>Perform the following algorithm to validate the local value of
+ * this {@link UIInput}.</p>
+ * <ul>
+ * <li>Retrieve the submitted value with
<code>getSubmittedValue()</code>.
+ * If this returns null, exit without further processing. (This
+ * indicates that no value was submitted for this component.)</li>
+ *
+ * <li> Convert the submitted value into a "local value" of the
+ * appropriate data type by calling {@link #getConvertedValue}.</li>
+ *
+ * <li>Validate the property by calling {@link #validateValue}.</li>
+ *
+ * <li>If the <code>valid</code> property of this component is still
+ * <code>true</code>, retrieve the previous value of the component
+ * (with <code>getValue()</code>), store the new local value using
+ * <code>setValue()</code>, and reset the submitted value to
+ * null. If the local value is different from
+ * the previous value of this component, fire a
+ * {@link ValueChangeEvent} to be broadcast to all interested
+ * listeners.</li>
+ * </ul>
+ *
+ * <p>Application components implementing {@link UIInput} that wish to
+ * perform validation with logic embedded in the component should perform
+ * their own correctness checks, and then call the
+ * <code>super.validate()</code> method to perform the standard
+ * processing described above.</p>
+ *
+ * @param context The {@link FacesContext} for the current request
+ *
+ * @exception NullPointerException if <code>context</code>
+ * is null
+ */
+ public void validate(FacesContext context) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ // Submitted value == null means "the component was not submitted
+ // at all"; validation should not continue
+ if (submittedValueHolder == null) {
+ return;
+ }
+
+ Object[] newValue = null;
+
+ try {
+ newValue = getConvertedValue(context);
+ }
+ catch (ConverterException ce) {
+ Object submittedValue = submittedValueHolder;
+ //addConversionErrorMessage(context, ce, submittedValue);
+ setValid(false);
+ }
+
+ //validateValue(context, newValue);
+
+ // If our value is valid, store the new value, erase the
+ // "submitted" value, and emit a ValueChangeEvent if appropriate
+ if (isValid()) {
+ Object rowKey = getRowKey();
+//
+// Set selectionSet = new HashSet();
+// Set selectedItems = submittedValueHolder.selectedItems;
+// for (Iterator iterator = selectedItems.iterator(); iterator
+// .hasNext();) {
+// setRowKey(context, iterator.next());
+// Object selectionItem = getRowData();
+//
+// selectionSet.add(selectionItem);
+// }
+//
+// setSelection(selectionSet);
+
+// if (submittedValueHolder.activeItem != null) {
+// setRowKey(context, submittedValueHolder.activeItem);
+// Object activeItem = getRowData();
+//
+// setActiveItem(activeItem);
+// } else {
+// setActiveItem(null);
+// }
+
+ Object previousSource = getSourceValue();
+ Object previousTarget = getTargetValue();
+ setSourceValue(newValue[0]);
+ setTargetValue(newValue[1]);
+ setTranslatedState();
+ //setSubmittedValue(null);
+ if (compareValues(previousSource, newValue[0]) || compareValues(previousTarget,
newValue[1])) {
+ queueEvent(new ValueChangeEvent(this, new Object[]{previousSource,previousTarget},
newValue));
+ }
+
+ this.submittedValueHolder = null;
+
+ setRowKey(rowKey);
+ }
+ }
+
+ private interface DataAdder {
+ Object getContainer();
+ void add(Object object);
+ }
+
+ private class ListDataAdder implements DataAdder {
+ private List container;
+
+ public ListDataAdder(int size) {
+ container = new ArrayList(size);
+ }
+
+ public Object getContainer() {
+ return container;
+ }
+
+ public void add(Object object) {
+ container.add(object);
+ }
+ }
+
+ private class ArrayDataAdder implements DataAdder {
+ private int idx = 0;
+ private Object[] objects;
+
+ public ArrayDataAdder(Class objectClass, int size) {
+ this.objects = (Object[]) Array.newInstance(objectClass.getComponentType(),
+ size);
+ }
+
+ public void add(Object object) {
+ this.objects[idx++] = object;
+ }
+
+ public Object getContainer() {
+ return objects;
+ }
+ }
+
+ private DataAdder createDataAdder(Object object, int size) {
+ if (object instanceof List) {
+ return new ListDataAdder(size);
+ } else {
+ return new ArrayDataAdder(object.getClass(), size);
+ }
+ }
+
+ protected Object[] getConvertedValue(FacesContext context) throws ConverterException {
+// Object convertedValue = getSourceValue();
+// if (convertedValue == null) {
+// convertedValue = new Object[0];
+// }
+
+ if (submittedValueHolder != null) {
+ Object rowKey = getRowKey();
+
+ Map source = submittedValueHolder.sourceTranslationTable;
+ Map target = submittedValueHolder.targetTranslationTable;
+
+ DataAdder sourceValue = createDataAdder(getSourceValue(), source.size());
+ DataAdder targetValue = createDataAdder(getTargetValue(), target.size());
+
+ Iterator iterator = source.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Entry entry = (Entry) iterator.next();
+
+ setRowKey(context, entry.getValue());
+ sourceValue.add(getRowData());
+ }
+
+ iterator = target.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Entry entry = (Entry) iterator.next();
+
+ setRowKey(context, entry.getValue());
+ targetValue.add(getRowData());
+ }
+
+ setRowKey(rowKey);
+
+ return new Object[] {sourceValue.getContainer(), targetValue.getContainer()};
+ }
+
+ return null;
+ }
+
+ protected void resetDataModel() {
+ super.resetDataModel();
+
+ if (this.submittedValueHolder != null) {
+ setTranslatedRenderingState();
+ }
+ }
}
Modified:
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleRowKey.java
===================================================================
---
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleRowKey.java 2007-11-26
03:05:40 UTC (rev 4247)
+++
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleRowKey.java 2007-11-26
03:05:55 UTC (rev 4248)
@@ -55,7 +55,7 @@
}
public String toString() {
- return rowKey.toString() + (source ? "y" : "n");
+ return (source ? "s" : "t") + rowKey.toString();
}
public ListShuttleRowKey(Object rowKey, boolean source) {
Added:
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleControlsHelper.java
===================================================================
---
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleControlsHelper.java
(rev 0)
+++
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleControlsHelper.java 2007-11-26
03:05:55 UTC (rev 4248)
@@ -0,0 +1,147 @@
+package org.richfaces.renderkit;
+
+import javax.faces.context.FacesContext;
+
+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 ListShuttleControlsHelper {
+
+ 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_CAPTION_LABEL = "captionLabel";
+
+ 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";
+
+ private 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";
+ private final static String DEFAULT_LABEL_REMOVE_ALL = "Remove All";
+
+ private final static String ATTRIBUTE_CLASS_BUTTON = "ol_button";
+ private final static String ATTRIBUTE_CLASS_BUTTON_DISABLED =
"ol_button_disabled";
+
+ 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,
+ " rich-ordering-control-top", ATTRIBUTE_CLASS_COPY_ALL_CONTROL,
ATTRIBUTE_CLASS_BUTTON,
+ CONTROL_ID_COPY_ALL, ATTRIBUTE_CE_ONCOPYALLCLICK, true) {
+
+ public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
+ return list.isFastOrderControlsVisible();
+ }
+
+ },
+ new OrderingComponentRendererBase.ControlsHelper("disabledCopyAll",
"COPY_ALL_LABEL", DEFAULT_LABEL_COPY_ALL,
ListShuttleIconCopyAllDisabled.class.getName(), FACET_DIS_COPY_ALL,
+ " rich-ordering-control-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL,
ATTRIBUTE_CLASS_BUTTON_DISABLED,
+ DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_COPY_ALL), null, false) {
+
+ public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
+ return list.isFastOrderControlsVisible();
+ }
+
+ },
+ new OrderingComponentRendererBase.ControlsHelper("copy",
"COPY_LABEL", DEFAULT_LABEL_COPY, ListShuttleIconCopy.class.getName(),
FACET_COPY,
+ " rich-ordering-control-up", ATTRIBUTE_CLASS_COPY_CONTROL,
ATTRIBUTE_CLASS_BUTTON,
+ CONTROL_ID_COPY, ATTRIBUTE_CE_ONCOPYCLICK ,true) {
+
+ public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
+ return list.isOrderControlsVisible();
+ }
+
+ },
+ new OrderingComponentRendererBase.ControlsHelper("disabledCopy",
"COPY_LABEL", DEFAULT_LABEL_COPY, ListShuttleIconCopyDisabled.class.getName(),
FACET_DIS_COPY,
+ " rich-ordering-control-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL,
ATTRIBUTE_CLASS_BUTTON_DISABLED,
+ DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_COPY), null, false) {
+
+ public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
+ return list.isOrderControlsVisible();
+ }
+
+ },
+ new OrderingComponentRendererBase.ControlsHelper("remove",
"REMOVE_LABEL", DEFAULT_LABEL_REMOVE, ListShuttleIconRemove.class.getName(),
FACET_REMOVE,
+ " rich-ordering-control-down", ATTRIBUTE_CLASS_REMOVE_CONTROL,
ATTRIBUTE_CLASS_BUTTON,
+ CONTROL_ID_REMOVE, ATTRIBUTE_CE_ONREMOVECLICK, true) {
+
+ public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
+ return list.isOrderControlsVisible();
+ }
+
+ },
+ new OrderingComponentRendererBase.ControlsHelper("disabledRemove",
"REMOVE_LABEL", DEFAULT_LABEL_REMOVE,
ListShuttleIconRemoveDisabled.class.getName(), FACET_DIS_REMOVE,
+ " rich-ordering-control-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL,
ATTRIBUTE_CLASS_BUTTON_DISABLED,
+ DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_REMOVE), null, false) {
+
+ public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
+ return list.isOrderControlsVisible();
+ }
+
+ },
+ new OrderingComponentRendererBase.ControlsHelper("removeAll",
"REMOVE_ALL_LABEL", DEFAULT_LABEL_REMOVE_ALL,
ListShuttleIconRemoveAll.class.getName(), FACET_REMOVE_ALL,
+ " rich-ordering-control-bottom", ATTRIBUTE_CLASS_REMOVE_ALL_CONTROL,
ATTRIBUTE_CLASS_BUTTON,
+ CONTROL_ID_REMOVE_ALL, ATTRIBUTE_CE_ONREMOVEALLCLICK, true) {
+
+ public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
+ return list.isFastOrderControlsVisible();
+ }
+
+ },
+ new OrderingComponentRendererBase.ControlsHelper("disabledRemoveAll",
"REMOVE_ALL_LABEL", DEFAULT_LABEL_REMOVE_ALL,
ListShuttleIconRemoveAllDisabled.class.getName(), FACET_DIS_REMOVE_ALL,
+ " rich-ordering-control-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL,
ATTRIBUTE_CLASS_BUTTON_DISABLED,
+ DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_REMOVE_ALL), null, false) {
+
+ public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
+ return list.isFastOrderControlsVisible();
+ }
+
+ }
+ };
+}
Modified:
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java
===================================================================
---
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java 2007-11-26
03:05:40 UTC (rev 4247)
+++
branches/3.1.x/sandbox/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java 2007-11-26
03:05:55 UTC (rev 4248)
@@ -18,7 +18,6 @@
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.UIListShuttle;
import org.richfaces.component.UIOrderingBaseComponent;
-import org.richfaces.component.UIOrderingList;
/**
* @author Nick Belaevski
@@ -30,7 +29,7 @@
public final static String FACET_TARGET_CAPTION = "targetCaption";
- protected static final OrderingComponentRendererBase.ControlsHelper[] SHUTTLE_HELPERS =
OrderingComponentControlsHelper.HELPERS;
+ protected static final OrderingComponentRendererBase.ControlsHelper[] SHUTTLE_HELPERS =
ListShuttleControlsHelper.HELPERS;
protected static final OrderingComponentRendererBase.ControlsHelper[] TL_HELPERS =
OrderingComponentControlsHelper.HELPERS;
@@ -133,7 +132,7 @@
public void encodeTLControlsFacets(FacesContext context, UIOrderingBaseComponent
component)
throws IOException {
- String clientId = component.getClientId(context) + "targetList";
+ String clientId = component.getClientId(context);
encodeControlsFacets(context, component, TL_HELPERS, clientId);
}
@@ -162,5 +161,16 @@
}
}
+ protected void doDecode(FacesContext context, UIComponent component) {
+ super.doDecode(context, component);
+
+ String clientId = component.getClientId(context);
+ Object object =
context.getExternalContext().getRequestParameterValuesMap().get(clientId);
+ if (object != null) {
+ UIListShuttle listShuttle = (UIListShuttle) component;
+ String[] submittedValues = (String[]) object;
+ listShuttle.setSubmittedStrings(submittedValues);
+ }
+ }
}
Modified:
branches/3.1.x/sandbox/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js
===================================================================
---
branches/3.1.x/sandbox/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js 2007-11-26
03:05:40 UTC (rev 4247)
+++
branches/3.1.x/sandbox/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js 2007-11-26
03:05:55 UTC (rev 4248)
@@ -90,7 +90,7 @@
this.moveItem(sourceComponent, targetComponent, item);
}
this.controlListManager();
- this.sourceList.controlListManager();
+ this.targetList.controlListManager();
this.saveState();
}
},
Modified:
branches/3.1.x/sandbox/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx
===================================================================
---
branches/3.1.x/sandbox/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx 2007-11-26
03:05:40 UTC (rev 4247)
+++
branches/3.1.x/sandbox/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx 2007-11-26
03:05:55 UTC (rev 4248)
@@ -29,9 +29,10 @@
<table id="#{clientId}">
<tr>
<td>
- <div id="#{clientId}sourceList"
x:passThruWithExclusions="id">
+ <input id="#{clientId}valueKeeper" type="hidden"
name="#{clientId}" value="#{component.sourceSubmittedString}"/>
+ <input id="#{clientId}tlValueKeeper" type="hidden"
name="#{clientId}" value="#{component.targetSubmittedString}"/>
+ <div>
<input id="#{clientId}focusKeeper" type="button"
value="" style="width: 1px; position: absolute; left: -32767px;"
name="focusKeeper"/>
- <input id="#{clientId}valueKeeper" type="hidden"
name="#{clientId}" value="#{component.submittedString}"/>
<table id="#{clientId}table" cellpadding="0"
cellspacing="0" class="ol_body">
<tbody>
@@ -63,19 +64,22 @@
</div>
</td>
<td>
- <a id="#{clientId}copy"
href="#">copy</a><br/>
+ <div class="ol_button_layout">
+ <f:call name="encodeShuttleControlsFacets" />
+ </div>
+
+ <!-- a id="#{clientId}copy"
href="#">copy</a><br/>
<a id="#{clientId}disCopy"
href="#">dcopy</a><br/>
<a id="#{clientId}copyAll"
href="#">copyAll</a><br/>
<a id="#{clientId}disCopyAll"
href="#">dcopyAll</a><br/>
<a id="#{clientId}remove"
href="#">remove</a><br/>
<a id="#{clientId}disRemove"
href="#">dremove</a><br/>
<a id="#{clientId}removeAll"
href="#">removeAll</a><br/>
- <a id="#{clientId}disRemoveAll"
href="#">dremoveAll</a>
+ <a id="#{clientId}disRemoveAll"
href="#">dremoveAll</a-->
</td>
<td>
- <div id="#{clientId}targetList"
x:passThruWithExclusions="id">
+ <div>
<input id="#{clientId}tlFocusKeeper" type="button"
value="" style="width: 1px; position: absolute; left: -32767px;"
name="focusKeeper"/>
- <input id="#{clientId}tlValueKeeper" type="hidden"
name="#{clientId}" value="#{component.submittedString}"/>
<table id="#{clientId}tlTable" cellpadding="0"
cellspacing="0" class="ol_body">
<tbody>
@@ -126,9 +130,9 @@
document.body.className = "body";
function init() {
var cotrolsIdPrefix = [['up', 'disup'], ['down',
'disdown'], ['last', 'dislast'],
['first','disfirst']];
- var listShuttleCotrolsIdPrefix = [['copy', 'disCopy'],
['copyAll', 'disCopyAll'], ['remove', 'disRemove'],
['removeAll','disRemoveAll']];
- var listShuttle = new Richfaces.ListShuttle(new
Richfaces.OrderingList('#{cId}targetList', '#{cId}tlInternal_tab',
'#{cId}tlInternal_header_tab', '#{cId}tlFocusKeeper',
'#{cId}tlValueKeeper', cotrolsIdPrefix, '#{cId}sortLabel', function()
{#{component.attributes['onorderchanged']}}),
- new Richfaces.ListBase('#{cId}sourceList',
'#{cId}internal_tab', '#{cId}internal_header_tab',
'#{cId}focusKeeper', '#{cId}valueKeeper'),
+ var listShuttleCotrolsIdPrefix = [['copy', 'discopy'],
['copyAll', 'discopyAll'], ['remove', 'disremove'],
['removeAll','disremoveAll']];
+ var listShuttle = new Richfaces.ListShuttle(new
Richfaces.OrderingList('#{cId}', '#{cId}tlInternal_tab',
'#{cId}tlInternal_header_tab', '#{cId}tlFocusKeeper',
'#{cId}tlValueKeeper', cotrolsIdPrefix, '#{cId}sortLabel', function()
{#{component.attributes['onorderchanged']}}),
+ new Richfaces.ListBase('#{cId}', '#{cId}internal_tab',
'#{cId}internal_header_tab', '#{cId}focusKeeper',
'#{cId}valueKeeper'),
"#{cId}", listShuttleCotrolsIdPrefix);
var sourceLayoutManager = new LayoutManager('#{cId}internal_header_tab',
'#{cId}internal_tab');
var targetLayoutManager = new LayoutManager('#{cId}tlInternal_header_tab',
'#{cId}tlInternal_tab');