JBoss Rich Faces SVN: r4534 - in branches/3.1.x/ui/listShuttle/src/main: templates/org/richfaces and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-12-06 00:28:53 -0500 (Thu, 06 Dec 2007)
New Revision: 4534
Modified:
branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js
branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx
Log:
orderingList & listShuttle: selection initialization fixed
Modified: branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js
===================================================================
--- branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js 2007-12-06 05:28:48 UTC (rev 4533)
+++ branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js 2007-12-06 05:28:53 UTC (rev 4534)
@@ -2,6 +2,54 @@
Richfaces.ListShuttle = Class.create();
+Richfaces.ListShuttle.Source = Class.create({
+ CLASSDEF: {
+ name: 'Richfaces.ListShuttle.Source',
+ parent: Richfaces.ListBase
+ }
+});
+
+Richfaces.ListShuttle.Source.prototype.CLASSES = {
+ ROW : {
+ ACTIVE : "rich-shuttle-source-row-active",
+ SELECTED : "rich-shuttle-source-row-selected",
+ ACTIVE_SELECTED : "rich-shuttle-source-row-selected rich-shuttle-source-row-active",
+ DISABLED : "rich-shuttle-source-row-disabled",
+ NORMAL : "rich-shuttle-source-row"
+ },
+ CELL : {
+ ACTIVE : "rich-shuttle-source-cell-active",
+ SELECTED : "rich-shuttle-source-cell-selected",
+ ACTIVE_SELECTED : "rich-shuttle-source-cell-selected rich-shuttle-source-cell-active",
+ DISABLED : "rich-shuttle-source-cell-disabled",
+ NORMAL : "rich-shuttle-source-cell"
+ }
+};
+
+Richfaces.ListShuttle.Target = Class.create({
+ CLASSDEF: {
+ name: 'Richfaces.ListShuttle.Target',
+ parent: Richfaces.OrderingList
+ }
+});
+
+Richfaces.ListShuttle.Target.prototype.CLASSES = {
+ ROW : {
+ ACTIVE : "rich-shuttle-target-row-active",
+ SELECTED : "rich-shuttle-target-row-selected",
+ ACTIVE_SELECTED : "rich-shuttle-target-row-selected rich-shuttle-target-row-active",
+ DISABLED : "rich-shuttle-target-row-disabled",
+ NORMAL : "rich-shuttle-target-row"
+ },
+ CELL : {
+ ACTIVE : "rich-shuttle-target-cell-active",
+ SELECTED : "rich-shuttle-target-cell-selected",
+ ACTIVE_SELECTED : "rich-shuttle-target-cell-selected rich-shuttle-target-cell-active",
+ DISABLED : "rich-shuttle-target-cell-disabled",
+ NORMAL : "rich-shuttle-target-cell"
+ }
+};
+
Richfaces.ListShuttle.prototype = {
initialize: function(targetList, sourceList, clientId, controlIds, switchByClick) {
sourceList._onclickHandler = sourceList.onclickHandler;
@@ -22,40 +70,6 @@
this.controlList = new Array();
this.initControlList(clientId, controlIds);
-
- this.sourceList.CLASSES = {
- ROW : {
- ACTIVE : "rich-shuttle-source-row-active",
- SELECTED : "rich-shuttle-source-row-selected",
- ACTIVE_SELECTED : "rich-shuttle-source-row-selected rich-shuttle-source-row-active",
- DISABLED : "rich-shuttle-source-row-disabled",
- NORMAL : "rich-shuttle-source-row"
- },
- CELL : {
- ACTIVE : "rich-shuttle-source-cell-active",
- SELECTED : "rich-shuttle-source-cell-selected",
- ACTIVE_SELECTED : "rich-shuttle-source-cell-selected rich-shuttle-source-cell-active",
- DISABLED : "rich-shuttle-source-cell-disabled",
- NORMAL : "rich-shuttle-source-cell"
- }
- };
-
- this.targetList.CLASSES = {
- ROW : {
- ACTIVE : "rich-shuttle-target-row-active",
- SELECTED : "rich-shuttle-target-row-selected",
- ACTIVE_SELECTED : "rich-shuttle-target-row-selected rich-shuttle-target-row-active",
- DISABLED : "rich-shuttle-target-row-disabled",
- NORMAL : "rich-shuttle-target-row"
- },
- CELL : {
- ACTIVE : "rich-shuttle-target-cell-active",
- SELECTED : "rich-shuttle-target-cell-selected",
- ACTIVE_SELECTED : "rich-shuttle-target-cell-selected rich-shuttle-target-cell-active",
- DISABLED : "rich-shuttle-target-cell-disabled",
- NORMAL : "rich-shuttle-target-cell"
- }
- };
},
initControlList : function(clientId, ids) {
@@ -68,7 +82,7 @@
this.controlList[i] = new Control(node, disNode, false, false, id[0]);
}
}
- this.controlListManager();
+ //this.controlListManager();
},
controlListManager : function() {
Modified: branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx
===================================================================
--- branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx 2007-12-06 05:28:48 UTC (rev 4533)
+++ branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx 2007-12-06 05:28:53 UTC (rev 4534)
@@ -180,8 +180,8 @@
Event.onReady(function() {
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('#{clientId}', '#{clientId}tlInternal_tab', '#{clientId}tlInternal_header_tab', '#{clientId}tlFocusKeeper', cotrolsIdPrefix, '#{clientId}sortLabel', #{this:getAsEventHandler(context, component, "onorderchanged")}),
- new Richfaces.ListBase('#{clientId}', '#{clientId}internal_tab', '#{clientId}internal_header_tab', '#{clientId}focusKeeper'),
+ var listShuttle = new Richfaces.ListShuttle(new Richfaces.ListShuttle.Target('#{clientId}', '#{clientId}tlInternal_tab', '#{clientId}tlInternal_header_tab', '#{clientId}tlFocusKeeper', cotrolsIdPrefix, '#{clientId}sortLabel', #{this:getAsEventHandler(context, component, "onorderchanged")}),
+ new Richfaces.ListShuttle.Source('#{clientId}', '#{clientId}internal_tab', '#{clientId}internal_header_tab', '#{clientId}focusKeeper'),
"#{clientId}", listShuttleCotrolsIdPrefix, "#{switchByClick}");
var sourceLayoutManager = new LayoutManager('#{clientId}internal_header_tab', '#{clientId}internal_tab');
var targetLayoutManager = new LayoutManager('#{clientId}tlInternal_header_tab', '#{clientId}tlInternal_tab');
18 years, 5 months
JBoss Rich Faces SVN: r4533 - branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-12-06 00:28:48 -0500 (Thu, 06 Dec 2007)
New Revision: 4533
Modified:
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js
Log:
orderingList & listShuttle: selection initialization fixed
Modified: branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js 2007-12-06 04:45:44 UTC (rev 4532)
+++ branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js 2007-12-06 05:28:48 UTC (rev 4533)
@@ -29,7 +29,7 @@
this.controlList[i] = new Control(node, disNode, false, false, id[0]);
}
}
- this.controlListManager();
+ //this.controlListManager();
},
controlListManager : function() {
18 years, 5 months
JBoss Rich Faces SVN: r4532 - branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-12-05 23:45:44 -0500 (Wed, 05 Dec 2007)
New Revision: 4532
Modified:
branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java
Log:
code refactoring & optimization done for orderingList & listShuttle
Modified: branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java
===================================================================
--- branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java 2007-12-06 04:45:37 UTC (rev 4531)
+++ branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java 2007-12-06 04:45:44 UTC (rev 4532)
@@ -16,6 +16,7 @@
import javax.faces.FacesException;
import javax.faces.application.FacesMessage;
+import javax.faces.component.StateHolder;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.convert.ConverterException;
@@ -27,6 +28,7 @@
import org.ajax4jsf.Messages;
import org.ajax4jsf.model.DataVisitor;
+import org.richfaces.component.UIOrderingList.ValueHolder;
import org.richfaces.component.util.MessageUtil;
import org.richfaces.model.ListShuttleDataModel;
import org.richfaces.model.ListShuttleRowKey;
@@ -41,76 +43,6 @@
public static final String COMPONENT_FAMILY = "org.richfaces.ListShuttle";
- private Collection sourceSelection;
- private boolean sourceSelectionSet;
-
- private Collection targetSelection;
- private boolean targetSelectionSet;
-
- protected void processDecodes(FacesContext faces, Object argument) {
- if (!this.isRendered())
- return;
- this.decode(faces);
-
- SubmittedValue submittedValue = UIListShuttle.this.submittedValueHolder;
- if (submittedValue != null) {
- if (submittedValue != null) {
- Object modelSourceValue = getSourceValue();
- Object modelTargetValue = getTargetValue();
-
- Iterator iterator = submittedValue.map.entrySet().iterator();
- while (iterator.hasNext()) {
- Entry entry = (Entry) iterator.next();
- Object value = entry.getValue();
-
- if (!isSuitableValue(modelSourceValue, value) && !isSuitableValue(modelTargetValue, value)) {
- String messageText = Messages.getMessage(
- Messages.INVALID_VALUE, MessageUtil.getLabel(faces, this), value);
-
- FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, messageText, null);
- faces.addMessage(this.getClientId(faces), message);
-
- setValid(false);
- break;
- }
- }
- }
- }
-
- if (isImmediate()) {
- executeValidate(faces);
- }
-
- if (!isValid()) {
- faces.renderResponse();
- }
-
- this.iterate(faces, decodeVisitor, argument);
- }
-
- private final class ModelItemState implements ItemState {
- private Collection sourceSelectedItems;
- private Collection targetSelectedItems;
- private Object activeItem;
-
- public ModelItemState(Collection sourceSelectedItems, Collection targetSelectedItems, Object activeItem) {
- super();
- this.sourceSelectedItems = sourceSelectedItems;
- this.targetSelectedItems = targetSelectedItems;
- this.activeItem = activeItem;
- }
-
- public boolean isSelected() {
- Object rowData = getRowData();
- return ((sourceSelectedItems != null && sourceSelectedItems.contains(rowData)) ||
- (targetSelectedItems != null && targetSelectedItems.contains(rowData)));
- }
-
- public boolean isActive() {
- return activeItem != null && activeItem.equals(getRowData());
- }
- }
-
protected static final class SubmittedValue implements Serializable {
/**
*
@@ -124,6 +56,8 @@
private Object activeItem;
+ private boolean _null = false;
+
public SubmittedValue(Map map, Set sourceSelection, Set targetSelection, Object activeItem) {
this.map = map;
@@ -133,13 +67,22 @@
this.activeItem = activeItem;
}
+ public void setNull() {
+ _null = true;
+ }
+
+ public boolean isNull() {
+ return _null;
+ }
+
+ public void resetDataModel() {
+ if (_null) {
+ this.map = null;
+ }
+ }
}
- private transient Map map;
-
- private transient SubmittedValue submittedValueHolder = null;
-
- protected static final class ValueHolder implements Serializable {
+ public static final class ValueHolder implements Serializable {
/**
*
*/
@@ -157,62 +100,178 @@
private Collection targetSelection;
private boolean targetSelectionSet;
- private Map map;
- }
+ private Object activeItem;
+ private boolean activeItemSet;
- private Object sourceValue;
- private boolean sourceValueSet;
+ private boolean collectionIsEmpty(Collection collection) {
+ return collection == null || collection.isEmpty();
+ }
+
+ private Object saveBoolean(boolean b) {
+ return b ? Boolean.TRUE : Boolean.FALSE;
+ }
+
+ public boolean isTransient() {
+ //TODO null collection == [] ?
+ return sourceValue == null && !sourceValueSet && targetValue == null && !targetValueSet &&
+ collectionIsEmpty(sourceSelection) && !sourceSelectionSet &&
+ collectionIsEmpty(targetSelection) && !targetSelectionSet &&
+ activeItem == null && !activeItemSet;
+ }
- private Object targetValue;
- private boolean targetValueSet;
+ public void restoreState(FacesContext context, UIListShuttle list, Object _state) {
+ Object[] state = (Object[]) _state;
- public Object saveState(FacesContext context) {
- Object[] state = new Object[8];
+ sourceValue = state[0];
+ sourceValueSet = Boolean.TRUE.equals(state[1]);
- state[0] = super.saveState(context);
- state[1] = saveIterationState();
+ targetValue = state[2];
+ targetValueSet = Boolean.TRUE.equals(state[3]);
- final HashSet sourceSelectionKeySet = new HashSet();
- final HashSet targetSelectionKeySet = new HashSet();
- final HashSet activeItemSet = new HashSet(1);
-
- Object rowKey = getRowKey();
- try {
- walk(context, new DataVisitor() {
+ sourceSelection = (Collection) state[4];
+ sourceSelectionSet = Boolean.TRUE.equals(state[5]);
- public void process(FacesContext context, Object rowKey,
- Object argument) throws IOException {
+ targetSelection = (Collection) state[6];
+ targetSelectionSet = Boolean.TRUE.equals(state[7]);
- setRowKey(context, rowKey);
- Object data = getRowData();
-
- if (data != null) {
- if (data.equals(activeItem)) {
- activeItemSet.add(rowKey);
- }
+ activeItem = state[8];
+ activeItemSet = Boolean.TRUE.equals(state[9]);
+ }
+
+ public Object saveState(FacesContext context, final UIListShuttle list) {
+ final HashSet sourceSelectionKeySet = new HashSet();
+ final HashSet targetSelectionKeySet = new HashSet();
+ final Object[] activeItemKeys = new Object[1];
+
+ Object rowKey = list.getRowKey();
+ try {
+ list.walk(context, new DataVisitor() {
+
+ public void process(FacesContext context, Object rowKey,
+ Object argument) throws IOException {
+
+ list.setRowKey(context, rowKey);
+ Object data = list.getRowData();
- if (sourceSelection != null && sourceSelection.contains(data)) {
- sourceSelectionKeySet.add(rowKey);
- } else if (targetSelection != null && targetSelection.contains(data)){
- targetSelectionKeySet.add(rowKey);
+ if (data != null) {
+ if (data.equals(activeItem)) {
+ activeItemKeys[0] = rowKey;
+ }
+
+ if (sourceSelection != null && sourceSelection.contains(data)) {
+ sourceSelectionKeySet.add(rowKey);
+ } else if (targetSelection != null && targetSelection.contains(data)){
+ targetSelectionKeySet.add(rowKey);
+ }
}
}
+
+ }, null);
+ } catch (IOException e) {
+ throw new FacesException(e.getLocalizedMessage(), e);
+ }
+
+ Object[] state = new Object[10];
+
+ state[0] = sourceValue;
+ state[1] = sourceValueSet ? Boolean.TRUE : Boolean.FALSE;
+
+ state[2] = targetValue;
+ state[3] = targetValueSet ? Boolean.TRUE : Boolean.FALSE;
+
+ state[4] = sourceSelectionKeySet;
+ state[5] = sourceSelectionSet ? Boolean.TRUE : Boolean.FALSE;
+
+ state[6] = targetSelectionKeySet;
+ state[7] = targetSelectionSet ? Boolean.TRUE : Boolean.FALSE;
+
+ state[8] = activeItemKeys[0];
+ state[9] = activeItemSet ? Boolean.TRUE : Boolean.FALSE;
+
+ return state;
+ }
+
+ public void setTransient(boolean newTransientValue) {
+ if (newTransientValue) {
+ throw new IllegalArgumentException();
+ }
+ }
+ }
+
+ private transient SubmittedValue submittedValueHolder = null;
+
+ private ValueHolder valueHolder;
+
+ protected void processDecodes(FacesContext faces, Object argument) {
+ if (!this.isRendered())
+ return;
+ this.decode(faces);
+
+ SubmittedValue submittedValue = UIListShuttle.this.submittedValueHolder;
+ if (submittedValue != null) {
+ Object modelSourceValue = getSourceValue();
+ Object modelTargetValue = getTargetValue();
+
+ Iterator iterator = submittedValue.map.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Entry entry = (Entry) iterator.next();
+ Object value = entry.getValue();
+
+ if (!isSuitableValue(modelSourceValue, value) && !isSuitableValue(modelTargetValue, value)) {
+ String messageText = Messages.getMessage(
+ Messages.INVALID_VALUE, MessageUtil.getLabel(faces, this), value);
+
+ FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, messageText, null);
+ faces.addMessage(this.getClientId(faces), message);
+
+ setValid(false);
+ break;
}
-
- }, null);
- } catch (IOException e) {
- throw new FacesException(e.getLocalizedMessage(), e);
+ }
}
- state[2] = sourceSelectionKeySet;
- state[3] = this.sourceSelectionSet ? Boolean.TRUE : Boolean.FALSE;
+ if (isImmediate()) {
+ executeValidate(faces);
+ }
- state[4] = targetSelectionKeySet;
- state[5] = this.targetSelectionSet ? Boolean.TRUE : Boolean.FALSE;
+ if (!isValid()) {
+ faces.renderResponse();
+ }
- state[6] = activeItemSet.isEmpty() ? null : activeItemSet.iterator().next();
- state[7] = this.activeItemSet ? Boolean.TRUE : Boolean.FALSE;
+ this.iterate(faces, decodeVisitor, argument);
+ }
+ private final class ModelItemState implements ItemState {
+ private Collection sourceSelectedItems;
+ private Collection targetSelectedItems;
+ private Object activeItem;
+
+ public ModelItemState(Collection sourceSelectedItems, Collection targetSelectedItems, Object activeItem) {
+ super();
+ this.sourceSelectedItems = sourceSelectedItems;
+ this.targetSelectedItems = targetSelectedItems;
+ this.activeItem = activeItem;
+ }
+
+ public boolean isSelected() {
+ Object rowData = getRowData();
+ return ((sourceSelectedItems != null && sourceSelectedItems.contains(rowData)) ||
+ (targetSelectedItems != null && targetSelectedItems.contains(rowData)));
+ }
+
+ public boolean isActive() {
+ return activeItem != null && activeItem.equals(getRowData());
+ }
+ }
+
+ public Object saveState(FacesContext context) {
+ Object[] state = new Object[2];
+
+ state[0] = super.saveState(context);
+
+ if (this.valueHolder != null) {
+ state[1] = this.valueHolder.saveState(context, this);
+ }
return state;
}
@@ -220,21 +279,15 @@
Object[] state = (Object[]) object;
super.restoreState(context, state[0]);
- restoreIterationState(state[1]);
-
- this.sourceSelection = (Collection) state[2];
- this.sourceSelectionSet = ((Boolean) state[3]).booleanValue();
-
- this.targetSelection = (Collection) state[4];
- this.targetSelectionSet = ((Boolean) state[5]).booleanValue();
-
- this.activeItem = state[6];
- this.activeItemSet = ((Boolean) state[7]).booleanValue();
+ if (state[1] != null) {
+ this.valueHolder = new ValueHolder();
+ this.valueHolder.restoreState(context, this, state[1]);
+ }
}
public Object getSourceValue() {
- if (sourceValue != null) {
- return sourceValue;
+ if (valueHolder != null && valueHolder.sourceValue != null) {
+ return valueHolder.sourceValue;
}
ValueBinding vb = getValueBinding("sourceValue");
@@ -247,13 +300,14 @@
public void setSourceValue(Object sourceValue) {
setExtendedDataModel(null);
- this.sourceValue = sourceValue;
- this.sourceValueSet = true;
+ createValueHolder();
+ valueHolder.sourceValue = sourceValue;
+ valueHolder.sourceValueSet = true;
}
public Object getTargetValue() {
- if (targetValue != null) {
- return targetValue;
+ if (valueHolder != null && valueHolder.targetValue != null) {
+ return valueHolder.targetValue;
}
ValueBinding vb = getValueBinding("targetValue");
@@ -266,67 +320,32 @@
public void setTargetValue(Object targetValue) {
setExtendedDataModel(null);
- this.targetValue = targetValue;
- this.targetValueSet = true;
+ createValueHolder();
+ valueHolder.targetValue = targetValue;
+ valueHolder.targetValueSet = true;
}
public void setSubmittedStrings(Map map, Set sourceSelection, Set targetSelection, Object activeItem) {
this.submittedValueHolder = new SubmittedValue(map, sourceSelection, targetSelection, activeItem);
}
- protected Object saveIterationSubmittedState() {
+ public Object getSubmittedValue() {
return submittedValueHolder;
}
+ public void setSubmittedValue(Object object) {
+ this.submittedValueHolder = (SubmittedValue) object;
+ }
+
protected void restoreIterationSubmittedState(Object object) {
this.submittedValueHolder = (SubmittedValue) object;
}
- protected Object saveIterationState() {
- ValueHolder holder = new ValueHolder();
-
- holder.sourceValue = sourceValue;
- holder.sourceValueSet = sourceValueSet;
-
- holder.targetValue = targetValue;
- holder.targetValueSet = targetValueSet;
-
- holder.sourceSelection = this.sourceSelection;
- holder.sourceSelectionSet = this.sourceSelectionSet;
-
- holder.targetSelection = this.targetSelection;
- holder.targetSelectionSet = this.targetSelectionSet;
-
- holder.map = map;
-
- return holder;
- }
-
- protected void restoreIterationState(Object object) {
- ValueHolder holder = (ValueHolder) object;
-
- this.sourceValue = holder.sourceValue ;
- this.sourceValueSet = holder.sourceValueSet;
-
- this.targetValue = holder.targetValue;
- this.targetValueSet = holder.targetValueSet;
-
- this.sourceSelection = holder.sourceSelection;
- this.sourceSelectionSet = holder.sourceSelectionSet;
-
- this.targetSelection = holder.targetSelection;
- this.targetSelectionSet = holder.targetSelectionSet;
-
- map = holder.map;
- }
-
public org.ajax4jsf.model.ExtendedDataModel createDataModel() {
Map source = null;
if (submittedValueHolder != null) {
source = submittedValueHolder.map;
- } else {
- source = this.map;
}
if (source != null) {
@@ -361,27 +380,42 @@
protected final UpdateModelCommand updateTargetSelectionCommand = new UpdateModelCommand() {
public void execute(FacesContext context) {
- if (targetSelectionSet) {
+ if (valueHolder.targetSelectionSet) {
ValueBinding vb = getValueBinding("targetSelection");
if (vb != null) {
- vb.setValue(context, targetSelection);
- targetSelection = null;
- targetSelectionSet = false;
+ vb.setValue(context, valueHolder.targetSelection);
+ valueHolder.targetSelection = null;
+ valueHolder.targetSelectionSet = false;
}
}
}
};
+ protected final UpdateModelCommand updateActiveItemCommand = new UpdateModelCommand() {
+
+ public void execute(FacesContext context) {
+ if (valueHolder.activeItemSet) {
+ ValueBinding vb = getValueBinding("activeItem");
+ if (vb != null) {
+ vb.setValue(context, valueHolder.activeItem);
+ valueHolder.activeItem = null;
+ valueHolder.activeItemSet = false;
+ }
+ }
+ }
+
+ };
+
protected final UpdateModelCommand updateSourceSelectionCommand = new UpdateModelCommand() {
public void execute(FacesContext context) {
- if (sourceSelectionSet) {
+ if (valueHolder.sourceSelectionSet) {
ValueBinding vb = getValueBinding("sourceSelection");
if (vb != null) {
- vb.setValue(context, sourceSelection);
- sourceSelection = null;
- sourceSelectionSet = false;
+ vb.setValue(context, valueHolder.sourceSelection);
+ valueHolder.sourceSelection = null;
+ valueHolder.sourceSelectionSet = false;
}
}
}
@@ -391,12 +425,12 @@
private final UpdateModelCommand updateSourceCommand = new UpdateModelCommand() {
public void execute(FacesContext context) {
- if (sourceValueSet) {
+ if (valueHolder.sourceValueSet) {
ValueBinding vb = getValueBinding("sourceValue");
if (vb != null) {
- vb.setValue(context, sourceValue);
- sourceValue = null;
- sourceValueSet = false;
+ vb.setValue(context, valueHolder.sourceValue);
+ valueHolder.sourceValue = null;
+ valueHolder.sourceValueSet = false;
}
}
}
@@ -406,12 +440,12 @@
private final UpdateModelCommand updateTargetCommand = new UpdateModelCommand() {
public void execute(FacesContext context) {
- if (targetValueSet) {
+ if (valueHolder.targetValueSet) {
ValueBinding vb = getValueBinding("targetValue");
if (vb != null) {
- vb.setValue(context, targetValue);
- targetValue = null;
- targetValueSet = false;
+ vb.setValue(context, valueHolder.targetValue);
+ valueHolder.targetValue = null;
+ valueHolder.targetValueSet = false;
}
}
}
@@ -460,11 +494,13 @@
return;
}
- updateModel(context, updateActiveItemCommand);
- updateModel(context, updateSourceSelectionCommand);
- updateModel(context, updateTargetSelectionCommand);
- updateModel(context, updateSourceCommand);
- updateModel(context, updateTargetCommand);
+ if (valueHolder != null) {
+ updateModel(context, updateActiveItemCommand);
+ updateModel(context, updateSourceSelectionCommand);
+ updateModel(context, updateTargetSelectionCommand);
+ updateModel(context, updateSourceCommand);
+ updateModel(context, updateTargetCommand);
+ }
}
@@ -572,33 +608,26 @@
setSourceValue(newSourceValue);
setTargetValue(newTargetValue);
- setTranslatedState();
-
if (compareValues(previousSource, newSourceValue) || compareValues(previousTarget, newTargetValue)) {
queueEvent(new ValueChangeEvent(this,
new Object[]{previousSource,previousTarget},
new Object[]{newSourceValue, newTargetValue}));
}
- this.map = this.submittedValueHolder.map;
-
- this.submittedValueHolder = null;
-
+ this.submittedValueHolder.setNull();
}
}
protected void resetDataModel() {
super.resetDataModel();
- this.map = null;
-
- if (this.submittedValueHolder != null) {
- setTranslatedRenderingState();
+ if (submittedValueHolder != null) {
+ submittedValueHolder.resetDataModel();
}
}
public ItemState getItemState() {
- if (submittedValueHolder != null) {
+ if (submittedValueHolder != null && !submittedValueHolder.isNull()) {
return new ModelItemState(submittedValueHolder.sourceSelection, submittedValueHolder.targetSelection,
submittedValueHolder.activeItem);
} else {
@@ -618,9 +647,15 @@
public abstract boolean isFastMoveControlsVisible();
public abstract void setFastMoveControlsVisible(boolean visible);
+ private void createValueHolder() {
+ if (valueHolder == null) {
+ valueHolder = new ValueHolder();
+ }
+ }
+
public Collection getSourceSelection() {
- if (this.sourceSelection != null) {
- return this.sourceSelection;
+ if (valueHolder != null && valueHolder.sourceSelection != null) {
+ return valueHolder.sourceSelection;
} else {
ValueBinding vb = getValueBinding("sourceSelection");
if (vb != null) {
@@ -632,13 +667,14 @@
}
public void setSourceSelection(Collection collection) {
- this.sourceSelection = collection;
- this.sourceSelectionSet = true;
+ createValueHolder();
+ valueHolder.sourceSelection = collection;
+ valueHolder.sourceSelectionSet = true;
}
public Collection getTargetSelection() {
- if (this.targetSelection != null) {
- return this.targetSelection;
+ if (valueHolder != null && valueHolder.targetSelection != null) {
+ return valueHolder.targetSelection;
} else {
ValueBinding vb = getValueBinding("targetSelection");
if (vb != null) {
@@ -650,10 +686,30 @@
}
public void setTargetSelection(Collection collection) {
- this.targetSelection = collection;
- this.targetSelectionSet = true;
+ createValueHolder();
+ valueHolder.targetSelection = collection;
+ valueHolder.targetSelectionSet = true;
}
+ public Object getActiveItem() {
+ if (valueHolder != null && valueHolder.activeItem != null) {
+ return valueHolder.activeItem;
+ } else {
+ ValueBinding vb = getValueBinding("activeItem");
+ if (vb != null) {
+ return vb.getValue(FacesContext.getCurrentInstance());
+ }
+ }
+
+ return null;
+ }
+
+ public void setActiveItem(Object activeItem) {
+ createValueHolder();
+ valueHolder.activeItem = activeItem;
+ valueHolder.activeItemSet = true;
+ }
+
public abstract String getSourceCaptionLabel();
public abstract void setSourceCaptionLabel(String label);
@@ -667,4 +723,12 @@
return super.getValueBinding(name);
}
+
+ public void setValue(Object value) {
+ this.valueHolder = (ValueHolder) value;
+ }
+
+ public Object getLocalValue() {
+ return this.valueHolder;
+ }
}
18 years, 5 months
JBoss Rich Faces SVN: r4531 - branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-12-05 23:45:37 -0500 (Wed, 05 Dec 2007)
New Revision: 4531
Modified:
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
Log:
code refactoring & optimization done for orderingList & listShuttle
Modified: branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java 2007-12-06 03:18:37 UTC (rev 4530)
+++ branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java 2007-12-06 04:45:37 UTC (rev 4531)
@@ -3,7 +3,6 @@
*/
package org.richfaces.component;
-import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
@@ -46,12 +45,8 @@
*/
public abstract class UIOrderingBaseComponent extends UIDataAdaptor implements EditableValueHolder {
- private Object value;
private boolean localValueSet;
- protected Object activeItem;
- protected boolean activeItemSet;
-
private List validators = null;
private MethodBinding validator;
@@ -83,92 +78,21 @@
}
}
- private static class EditableState implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = -3276243811945890889L;
-
- private boolean translated = false;
-
- //setting this flag to true means we should reorder elements
- private boolean translatedRendering = false;
- }
-
- private static final class ValueHolder implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 2349104220087787755L;
-
- private Object value;
-
- private Object activeItem;
- private boolean activeItemSet;
-
- private Object state;
- }
-
- private transient EditableState editableState = new EditableState();
-
- protected abstract void restoreIterationState(Object object);
- protected abstract Object saveIterationState();
-
- protected abstract void restoreIterationSubmittedState(Object object);
- protected abstract Object saveIterationSubmittedState();
-
public abstract boolean isOrderControlsVisible();
public abstract void setOrderControlsVisible(boolean visible);
public abstract boolean isFastOrderControlsVisible();
public abstract void setFastOrderControlsVisible(boolean visible);
- protected void setTranslatedState() {
- this.editableState.translated = true;
- }
-
- protected boolean isTranslatedState() {
- return this.editableState.translated;
- }
-
- protected void setTranslatedRenderingState() {
- this.editableState.translatedRendering = true;
- }
-
- protected boolean isTranslatedRenderingState() {
- return this.editableState.translatedRendering;
- }
-
- public final Object getSubmittedValue() {
- Object[] state = new Object[2];
-
- state[0] = saveIterationSubmittedState();
- state[1] = editableState;
-
- return state;
- }
-
- public final void setSubmittedValue(Object object) {
- if (object != null) {
- Object[] state = (Object[]) object;
-
- restoreIterationSubmittedState(state[0]);
- editableState = (EditableState) state[1];
- } else {
- restoreIterationSubmittedState(null);
- }
- }
-
public Object saveState(FacesContext faces) {
- Object[] state = new Object[5];
+ Object[] state = new Object[4];
state[0] = super.saveState(faces);
state[1] = saveAttachedState(faces, validators);
state[2] = saveAttachedState(faces, validator);
- state[3] = this.value;
- state[4] = localValueSet ? Boolean.TRUE : Boolean.FALSE;
+ state[3] = localValueSet ? Boolean.TRUE : Boolean.FALSE;
return state;
}
@@ -181,9 +105,7 @@
validators = (List) restoreAttachedState(faces, state[1]);
validator = (MethodBinding) restoreAttachedState(faces, state[2]);
- value = state[3];
- localValueSet = ((Boolean) state[4]).booleanValue();
-
+ localValueSet = ((Boolean) state[3]).booleanValue();
}
protected DataComponentState createComponentState() {
@@ -248,52 +170,6 @@
}
//validators end
- //value
- protected Object getLocalValueFieldValue() {
- return value;
- }
-
- public Object getLocalValue() {
- ValueHolder holder = new ValueHolder();
- holder.value = this.value;
-
- holder.activeItem = this.activeItem;
- holder.activeItemSet = this.activeItemSet;
-
- holder.state = saveIterationState();
-
- return holder;
- }
-
- public void setValue(Object value) {
- if (value instanceof ValueHolder) {
- ValueHolder holder = (ValueHolder) value;
-
- setValue(holder.value);
- restoreIterationState(holder.state);
-
- this.activeItem = holder.activeItem;
- this.activeItemSet = holder.activeItemSet;
- } else {
- super.setValue(value);
- this.value = value;
- setLocalValueSet(true);
- }
- }
-
- public Object getValue() {
- if (this.value != null) {
- return (this.value);
- }
- ValueBinding ve = getValueBinding("value");
- if (ve != null) {
- return (ve.getValue(getFacesContext()));
- } else {
- return (null);
- }
- }
- //value end
-
public boolean isLocalValueSet() {
return localValueSet;
}
@@ -457,36 +333,6 @@
void add(Object object);
}
- protected final UpdateModelCommand updateValueCommand = new UpdateModelCommand() {
-
- public void execute(FacesContext context) {
- if (isLocalValueSet()) {
- ValueBinding vb = getValueBinding("value");
- if (vb != null) {
- vb.setValue(context, getLocalValueFieldValue());
- setValue(null);
- setLocalValueSet(false);
- }
- }
- }
-
- };
-
- protected final UpdateModelCommand updateActiveItemCommand = new UpdateModelCommand() {
-
- public void execute(FacesContext context) {
- if (activeItemSet) {
- ValueBinding vb = getValueBinding("activeItem");
- if (vb != null) {
- vb.setValue(context, activeItem);
- activeItem = null;
- activeItemSet = false;
- }
- }
- }
-
- };
-
protected void updateModel(FacesContext context, UpdateModelCommand command) {
try {
command.execute(context);
@@ -583,24 +429,6 @@
return (false);
}
- public Object getActiveItem() {
- if (this.activeItem != null) {
- return this.activeItem;
- } else {
- ValueBinding vb = getValueBinding("activeItem");
- if (vb != null) {
- return vb.getValue(FacesContext.getCurrentInstance());
- }
- }
-
- return null;
- }
-
- public void setActiveItem(Object activeItem) {
- this.activeItem = activeItem;
- this.activeItemSet = true;
- }
-
protected Object createContainer(ArrayList data, Object object) {
if (object != null) {
Class objectClass = object.getClass();
Modified: branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java 2007-12-06 03:18:37 UTC (rev 4530)
+++ branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java 2007-12-06 04:45:37 UTC (rev 4531)
@@ -13,6 +13,7 @@
import javax.faces.FacesException;
import javax.faces.application.FacesMessage;
+import javax.faces.component.StateHolder;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.component.UIInput;
@@ -76,7 +77,7 @@
this.iterate(faces, decodeVisitor, argument);
}
- private transient Map dataMap;
+ private ValueHolder valueHolder;
protected static final class SubmittedValue implements Serializable {
/**
@@ -88,11 +89,27 @@
private Collection selection;
private Object activeItem;
+ private boolean _null = false;
+
public SubmittedValue(Map dataMap, Set selection, Object activeItem) {
this.dataMap = dataMap;
this.selection = selection;
this.activeItem = activeItem;
}
+
+ public void setNull() {
+ _null = true;
+ }
+
+ public boolean isNull() {
+ return _null;
+ }
+
+ public void resetDataModel() {
+ if (_null) {
+ this.dataMap = null;
+ }
+ }
}
private final class ModelItemState implements ItemState {
@@ -119,8 +136,6 @@
if (submittedValueHolder != null) {
modelMap = submittedValueHolder.dataMap;
- } else {
- modelMap = this.dataMap;
}
if (modelMap != null) {
@@ -135,22 +150,89 @@
private transient SubmittedValue submittedValueHolder = null;
- protected static final class ValueHolder implements Serializable {
+ public final static class ValueHolder implements Serializable {
/**
*
*/
private static final long serialVersionUID = -4216115242421460529L;
+ private Object value;
+
private Collection selection;
private boolean selectionSet;
-
- private Map map;
+
+ private Object activeItem;
+ private boolean activeItemSet;
+
+ public boolean isTransient() {
+ //TODO null collection == [] ?
+ return value == null && (selection == null || selection.isEmpty()) && !selectionSet &&
+ activeItem == null && !activeItemSet;
+ }
+
+ public void restoreState(FacesContext context, UIOrderingList list, Object _state) {
+ Object[] state = (Object[]) _state;
+
+ value = state[0];
+
+ selection = (Collection) state[1];
+ selectionSet = Boolean.TRUE.equals(state[2]);
+
+ activeItem = state[3];
+ activeItemSet = Boolean.TRUE.equals(state[4]);
+ }
+
+ public Object saveState(FacesContext context, final UIOrderingList list) {
+ Object rowKey = list.getRowKey();
+
+ final HashSet selectionKeySet = new HashSet();
+ final Object[] activeItemSet = new Object[1];
+ try {
+ list.walk(context, new DataVisitor() {
+
+ public void process(FacesContext context, Object rowKey,
+ Object argument) throws IOException {
+
+ list.setRowKey(context, rowKey);
+ Object data = list.getRowData();
+
+ if (data != null) {
+ if (data.equals(activeItem)) {
+ activeItemSet[0] = rowKey;
+ }
+
+ if (selection != null && selection.contains(data)) {
+ selectionKeySet.add(rowKey);
+ }
+ }
+ }
+
+ }, null);
+ } catch (IOException e) {
+ throw new FacesException(e.getLocalizedMessage(), e);
+ }
+
+ Object[] state = new Object[5];
+
+ state[0] = value;
+
+ state[1] = selectionKeySet;
+ state[2] = this.selectionSet ? Boolean.TRUE : Boolean.FALSE;
+
+ state[3] = activeItemSet[0];
+ state[4] = this.activeItemSet ? Boolean.TRUE : Boolean.FALSE;
+
+ return state;
+ }
+
+ public void setTransient(boolean newTransientValue) {
+ if (newTransientValue) {
+ throw new IllegalArgumentException();
+ }
+ }
}
- private Collection selection;
- private boolean selectionSet;
-
public void addValueChangeListener(ValueChangeListener listener) {
addFacesListener(listener);
}
@@ -177,27 +259,20 @@
this.submittedValueHolder = new SubmittedValue(submittedString, selection, activeItem);
}
- protected Object saveIterationSubmittedState() {
+ public Object getSubmittedValue() {
return submittedValueHolder;
}
- protected void restoreIterationSubmittedState(Object object) {
+ public void setSubmittedValue(Object object) {
this.submittedValueHolder = (SubmittedValue) object;
}
protected Object saveIterationState() {
- ValueHolder valueHolder = new ValueHolder();
- valueHolder.map = dataMap;
- valueHolder.selection = selection;
- valueHolder.selectionSet = selectionSet;
return valueHolder;
}
protected void restoreIterationState(Object object) {
- ValueHolder valueHolder = (ValueHolder) object;
- dataMap = valueHolder.map;
- selection = valueHolder.selection;
- selectionSet = valueHolder.selectionSet;
+ this.valueHolder = (ValueHolder) object;
}
public abstract void setImmediate(boolean immediate);
@@ -319,21 +394,51 @@
}
+ protected final UpdateModelCommand updateActiveItemCommand = new UpdateModelCommand() {
+
+ public void execute(FacesContext context) {
+ if (valueHolder.activeItemSet) {
+ ValueBinding vb = getValueBinding("activeItem");
+ if (vb != null) {
+ vb.setValue(context, valueHolder.activeItem);
+ valueHolder.activeItem = null;
+ valueHolder.activeItemSet = false;
+ }
+ }
+ }
+
+ };
+
protected final UpdateModelCommand updateSelectionCommand = new UpdateModelCommand() {
public void execute(FacesContext context) {
- if (selectionSet) {
+ if (valueHolder.selectionSet) {
ValueBinding vb = getValueBinding("selection");
if (vb != null) {
- vb.setValue(context, selection);
- selection = null;
- selectionSet = false;
+ vb.setValue(context, valueHolder.selection);
+ valueHolder.selection = null;
+ valueHolder.selectionSet = false;
}
}
}
};
+ protected final UpdateModelCommand updateValueCommand = new UpdateModelCommand() {
+
+ public void execute(FacesContext context) {
+ if (isLocalValueSet() && valueHolder != null) {
+ ValueBinding vb = getValueBinding("value");
+ if (vb != null) {
+ vb.setValue(context, valueHolder.value);
+ setValue(null);
+ setLocalValueSet(false);
+ }
+ }
+ }
+
+ };
+
/**
* <p>Perform the following algorithm to update the model dataMap
* associated with this {@link UIInput}, if any, as appropriate.</p>
@@ -376,9 +481,11 @@
return;
}
- updateModel(context, updateValueCommand);
- updateModel(context, updateSelectionCommand);
- updateModel(context, updateActiveItemCommand);
+ if (valueHolder != null) {
+ updateModel(context, updateValueCommand);
+ updateModel(context, updateSelectionCommand);
+ updateModel(context, updateActiveItemCommand);
+ }
}
@@ -475,24 +582,20 @@
setActiveItem(submittedValueHolder.activeItem);
setValue(newValue);
- setTranslatedState();
if (compareValues(previousValue, newValue)) {
queueEvent(new ValueChangeEvent(this, previousValue, newValue));
}
- this.dataMap = this.submittedValueHolder.dataMap;
- this.submittedValueHolder = null;
+ this.submittedValueHolder.setNull();
}
}
protected void resetDataModel() {
super.resetDataModel();
- this.dataMap = null;
-
if (this.submittedValueHolder != null) {
- setTranslatedRenderingState();
+ this.submittedValueHolder.resetDataModel();
}
}
@@ -587,7 +690,7 @@
}
public ItemState getItemState() {
- if (submittedValueHolder != null) {
+ if (submittedValueHolder != null && !submittedValueHolder.isNull()) {
return new ModelItemState(submittedValueHolder.selection,
submittedValueHolder.activeItem);
} else {
@@ -599,8 +702,8 @@
public abstract void setControlsType(String type);
public Collection getSelection() {
- if (this.selection != null) {
- return this.selection;
+ if (valueHolder != null && valueHolder.selection != null) {
+ return valueHolder.selection;
} else {
ValueBinding vb = getValueBinding("selection");
if (vb != null) {
@@ -612,49 +715,68 @@
}
public void setSelection(Collection collection) {
- this.selection = collection;
- this.selectionSet = true;
+ createValueHolder();
+ valueHolder.selection = collection;
+ valueHolder.selectionSet = true;
}
- public Object saveState(FacesContext faces) {
- Object[] state = new Object[5];
- state[0] = super.saveState(faces);
+ public Object getActiveItem() {
+ if (valueHolder != null && valueHolder.activeItem != null) {
+ return valueHolder.activeItem;
+ } else {
+ ValueBinding vb = getValueBinding("activeItem");
+ if (vb != null) {
+ return vb.getValue(FacesContext.getCurrentInstance());
+ }
+ }
- Object rowKey = getRowKey();
+ return null;
+ }
+
+ public void setActiveItem(Object activeItem) {
+ createValueHolder();
+ valueHolder.activeItem = activeItem;
+ valueHolder.activeItemSet = true;
+ }
+
+ private void createValueHolder() {
+ if (valueHolder == null) {
+ valueHolder = new ValueHolder();
+ }
+ }
- final HashSet selectionKeySet = new HashSet();
- final HashSet activeItemSet = new HashSet(1);
- try {
- walk(faces, new DataVisitor() {
+ public void setValue(Object value) {
+ if (value instanceof ValueHolder) {
+ this.valueHolder = (ValueHolder) value;
+ } else {
+ createValueHolder();
+ valueHolder.value = value;
+ setLocalValueSet(true);
+ }
+ }
- public void process(FacesContext context, Object rowKey,
- Object argument) throws IOException {
+ public Object getLocalValue() {
+ return valueHolder;
+ }
+
+ public Object getValue() {
+ if (valueHolder != null && valueHolder.value != null) {
+ return valueHolder.value;
+ }
+ ValueBinding ve = getValueBinding("value");
+ if (ve != null) {
+ return (ve.getValue(getFacesContext()));
+ } else {
+ return (null);
+ }
+ }
- setRowKey(context, rowKey);
- Object data = getRowData();
-
- if (data != null) {
- if (data.equals(activeItem)) {
- activeItemSet.add(rowKey);
- }
-
- if (selection != null && selection.contains(data)) {
- selectionKeySet.add(rowKey);
- }
- }
- }
-
- }, null);
- } catch (IOException e) {
- throw new FacesException(e.getLocalizedMessage(), e);
+ public Object saveState(FacesContext faces) {
+ Object[] state = new Object[2];
+ state[0] = super.saveState(faces);
+ if (this.valueHolder != null) {
+ state[1] = this.valueHolder.saveState(faces, this);
}
-
- state[1] = selectionKeySet;
- state[2] = this.selectionSet ? Boolean.TRUE : Boolean.FALSE;
-
- state[3] = activeItemSet.isEmpty() ? null : activeItemSet.iterator().next();
- state[4] = this.activeItemSet ? Boolean.TRUE : Boolean.FALSE;
-
return state;
}
@@ -663,11 +785,10 @@
super.restoreState(faces, state[0]);
- this.selection = (Collection) state[1];
- this.selectionSet = ((Boolean) state[2]).booleanValue();
-
- this.activeItem = state[3];
- this.activeItemSet = ((Boolean) state[4]).booleanValue();
+ if (state[1] != null) {
+ this.valueHolder = new ValueHolder();
+ this.valueHolder.restoreState(faces, this, state[1]);
+ }
}
}
18 years, 5 months
JBoss Rich Faces SVN: r4530 - in branches/3.1.x/samples/listShuttleDemo/src/main: webapp/pages and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-12-05 22:18:37 -0500 (Wed, 05 Dec 2007)
New Revision: 4530
Modified:
branches/3.1.x/samples/listShuttleDemo/src/main/java/org/richfaces/ListShuttleDemoBean.java
branches/3.1.x/samples/listShuttleDemo/src/main/webapp/pages/index.jsp
Log:
converter enhancements
Modified: branches/3.1.x/samples/listShuttleDemo/src/main/java/org/richfaces/ListShuttleDemoBean.java
===================================================================
--- branches/3.1.x/samples/listShuttleDemo/src/main/java/org/richfaces/ListShuttleDemoBean.java 2007-12-06 03:18:32 UTC (rev 4529)
+++ branches/3.1.x/samples/listShuttleDemo/src/main/java/org/richfaces/ListShuttleDemoBean.java 2007-12-06 03:18:37 UTC (rev 4530)
@@ -5,6 +5,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
import java.util.Random;
@@ -23,8 +24,10 @@
private ListShuttleOptionItem[] source;
- private List target;
+ private ListShuttleOptionItem[] target;
+ private Integer[] numbers = new Integer[10];
+
private boolean moveControlsVisible = true;
private boolean fastMoveControlsVisible = true;
@@ -39,10 +42,14 @@
source[i] = new ListShuttleOptionItem("Source Item " + i, new Random().nextInt(40));
}
- target = new ArrayList();
- for (int i = 0; i < 5; i++) {
- target.add(new ListShuttleOptionItem("Target Item " + i, new Random().nextInt(40)));
+ target = new ListShuttleOptionItem[5];
+ for (int i = 0; i < target.length; i++) {
+ target[i] = new ListShuttleOptionItem("Target Item " + i, new Random().nextInt(40));
}
+
+ for (int i = 0; i < numbers.length; i++) {
+ numbers[i] = new Random().nextInt(256);
+ }
}
public ListShuttleOptionItem[] getSource() {
@@ -79,12 +86,12 @@
this.source = source;
}
- public List getTarget() {
+ public ListShuttleOptionItem[] getTarget() {
return target;
}
- public void setTarget(List target) {
- System.out.println("ListShuttleDemoBean.setTarget() " + target);
+ public void setTarget(ListShuttleOptionItem[] target) {
+ System.out.println("ListShuttleDemoBean.setTarget() " + arrayToString(target));
this.target = target;
}
@@ -142,4 +149,16 @@
this.targetSelection = targetSelection;
}
+ public Integer[] getNumbers() {
+ return numbers;
+ }
+
+ public void setNumbers(Integer[] numbers) {
+ for (int i = 0; i < numbers.length; i++) {
+ System.out.print(numbers[i].getClass().getSimpleName() + " ");
+ }
+ System.out.println();
+
+ this.numbers = numbers;
+ }
}
Modified: branches/3.1.x/samples/listShuttleDemo/src/main/webapp/pages/index.jsp
===================================================================
--- branches/3.1.x/samples/listShuttleDemo/src/main/webapp/pages/index.jsp 2007-12-06 03:18:32 UTC (rev 4529)
+++ branches/3.1.x/samples/listShuttleDemo/src/main/webapp/pages/index.jsp 2007-12-06 03:18:37 UTC (rev 4530)
@@ -78,7 +78,14 @@
<h:commandButton value="Submit" />
<h:commandButton value="Submit Immediate" immediate="true" />
- <h:commandButton value="Start over" action="#{listShuttleDemoBean.startOver}" />
+ <h:commandButton value="Start over" action="#{listShuttleDemoBean.startOver}" immediate="true"/>
+
+
+ <ls:listShuttle id="listShuttle1" var="item" sourceValue="#{listShuttleDemoBean.numbers}">
+ <h:column>
+ <h:outputText value="#{item}" />
+ </h:column>
+ </ls:listShuttle>
</h:form>
</f:view>
</body>
18 years, 5 months
JBoss Rich Faces SVN: r4529 - in branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces: renderkit and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-12-05 22:18:32 -0500 (Wed, 05 Dec 2007)
New Revision: 4529
Modified:
branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java
branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java
Log:
converter enhancements
Modified: branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java
===================================================================
--- branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java 2007-12-06 03:18:27 UTC (rev 4528)
+++ branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java 2007-12-06 03:18:32 UTC (rev 4529)
@@ -548,8 +548,8 @@
throw new ConverterException(e.getLocalizedMessage(), e);
}
- newSourceValue = createContainer(sourceList, oldSourceValue.getClass());
- newTargetValue = createContainer(targetList, oldTargetValue.getClass());
+ newSourceValue = createContainer(sourceList, oldSourceValue);
+ newTargetValue = createContainer(targetList, oldTargetValue);
}
catch (ConverterException ce) {
Object submittedValue = submittedValueHolder;
@@ -660,4 +660,11 @@
public abstract String getTargetCaptionLabel();
public abstract void setTargetCaptionLabel(String label);
+ public ValueBinding getValueBinding(String name) {
+ if ("value".equals(name)) {
+ return super.getValueBinding("sourceValue");
+ }
+
+ return super.getValueBinding(name);
+ }
}
Modified: branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java
===================================================================
--- branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java 2007-12-06 03:18:27 UTC (rev 4528)
+++ branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java 2007-12-06 03:18:32 UTC (rev 4529)
@@ -18,6 +18,7 @@
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import javax.faces.convert.Converter;
import org.ajax4jsf.component.UIDataAdaptor;
import org.ajax4jsf.renderkit.ComponentVariables;
@@ -49,16 +50,22 @@
private static class ListShuttleRendererTableHolder extends TableHolder {
private boolean source;
+ private Converter converter;
- public ListShuttleRendererTableHolder(UIDataAdaptor table, boolean source) {
+ public ListShuttleRendererTableHolder(UIDataAdaptor table, Converter converter, boolean source) {
super(table);
+ this.converter = converter;
this.source = source;
}
public boolean isSource() {
return source;
}
+
+ public Converter getConverter() {
+ return converter;
+ }
}
public ListShuttleRendererBase() {
@@ -87,7 +94,7 @@
ResponseWriter writer = context.getResponseWriter();
StringWriter stringWriter = new StringWriter();
context.setResponseWriter(writer.cloneWithWriter(stringWriter));
- encodeRows(context, shuttle, new ListShuttleRendererTableHolder(shuttle, source));
+ encodeRows(context, shuttle, new ListShuttleRendererTableHolder(shuttle, getConverter(context, shuttle), source));
context.getResponseWriter().flush();
context.setResponseWriter(writer);
@@ -185,7 +192,7 @@
}
value.append(':');
- value.append(getAsString(context, table, table.getRowData()));
+ value.append(shuttleRendererTableHolder.getConverter().getAsString(context, table, table.getRowData()));
writer.writeAttribute(HTML.value_ATTRIBUTE, value.toString(), null);
@@ -279,6 +286,8 @@
Map requestParameterMap = externalContext
.getRequestParameterMap();
+
+
if (requestParameterMap.containsKey(clientId)) {
Set sourceSelection = new HashSet();
Set targetSelection = new HashSet();
@@ -288,6 +297,8 @@
boolean facadeSource = true;
+ Converter converter = getConverter(context, listShuttle);
+
for (int i = 0; i < strings.length; i++) {
String string = strings[i];
@@ -297,7 +308,7 @@
}
int idx = string.indexOf(':');
- Object value = getAsObject(context, listShuttle, string.substring(idx + 1));
+ Object value = converter.getAsObject(context, listShuttle, string.substring(idx + 1));
String substring = string.substring(0, idx);
boolean target = false;
18 years, 5 months
JBoss Rich Faces SVN: r4528 - in branches/3.1.x/ui/orderingList/src/main/java/org/richfaces: renderkit and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-12-05 22:18:27 -0500 (Wed, 05 Dec 2007)
New Revision: 4528
Modified:
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
Log:
converter enhancements
Modified: branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java 2007-12-06 02:03:12 UTC (rev 4527)
+++ branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java 2007-12-06 03:18:27 UTC (rev 4528)
@@ -14,12 +14,14 @@
import java.util.Map;
import javax.faces.FacesException;
+import javax.faces.application.Application;
import javax.faces.application.FacesMessage;
import javax.faces.component.EditableValueHolder;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.el.EvaluationException;
import javax.faces.el.MethodBinding;
@@ -599,13 +601,17 @@
this.activeItemSet = true;
}
- protected Object createContainer(ArrayList data, Class objectClass) {
- if (objectClass.isArray()) {
- return data.toArray((Object[]) Array.newInstance(objectClass.getComponentType(), data.size()));
- } else {
- data.trimToSize();
- return data;
+ protected Object createContainer(ArrayList data, Object object) {
+ if (object != null) {
+ Class objectClass = object.getClass();
+ Class componentType = objectClass.getComponentType();
+ if (componentType != null) {
+ return data.toArray((Object[]) Array.newInstance(componentType, data.size()));
+ }
}
+
+ data.trimToSize();
+ return data;
}
public abstract ItemState getItemState();
@@ -615,31 +621,30 @@
public boolean isActive();
}
-// protected final class SubmittedItemState implements ItemState {
-//
-// private Object activeItem;
-// private Set selectionKeys;
-//
-// public boolean isActive() {
-// return activeItemKeys != null && activeItemKeys.contains(getRowKey());
-// }
-//
-// public boolean isSelected() {
-// return selectionKeys != null && selectionKeys.contains(getRowKey());
-// }
-//
-// public SubmittedItemState(Set selectionKeys, Set activeItemKeys) {
-// super();
-// this.selectionKeys = selectionKeys;
-// this.activeItemKeys = activeItemKeys;
-// }
-// }
+ private Converter getConverterForType(FacesContext context, Class type) {
+ if (!Object.class.equals(type)) {
+ Application application = context.getApplication();
+ return application.createConverter(type);
+ }
+
+ return null;
+ }
- protected Object getAsObject(String string) {
- return string;
+ public Converter getConverterForValue(FacesContext context) {
+ ValueBinding binding = this.getValueBinding("value");
+ if (binding != null) {
+ Class type = binding.getType(context);
+ if (type != null) {
+ Class componentType = type.getComponentType();
+ if (componentType != null) {
+ return getConverterForType(context, componentType);
+ } else {
+ //support for generics introspection
+ }
+ }
+ }
+
+ return null;
}
-
- protected String getAsString(Object object) {
- return object.toString();
- }
+
}
Modified: branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java 2007-12-06 02:03:12 UTC (rev 4527)
+++ branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java 2007-12-06 03:18:27 UTC (rev 4528)
@@ -454,7 +454,7 @@
}, null);
- newValue = createContainer(list, previousValue.getClass());
+ newValue = createContainer(list, previousValue);
} catch (IOException e) {
throw new ConverterException(e.getLocalizedMessage(), e);
}
Modified: branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java 2007-12-06 02:03:12 UTC (rev 4527)
+++ branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java 2007-12-06 03:18:27 UTC (rev 4528)
@@ -16,7 +16,6 @@
import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
-import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptString;
@@ -33,6 +32,29 @@
*/
public abstract class OrderingComponentRendererBase extends AbstractRowsRenderer {
+ private static final Converter DEFAULT_CONVERTER = new Converter() {
+
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) {
+
+ return value;
+ }
+
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) {
+ if (value instanceof String) {
+ return (String) value;
+ }
+
+ if (null == value) {
+ return "";
+ }
+
+ return value.toString();
+ }
+
+ };
+
private static final String ITEM_STATE_VAR_NAME = "itemState";
protected final static String SHOW_LABELS_ATTRIBUTE_NAME = "showButtonLabels";
@@ -433,28 +455,19 @@
return (ItemState) variables.getVariable(ITEM_STATE_VAR_NAME);
}
- protected String getAsString(FacesContext context, UIOrderingBaseComponent component, Object object) {
- if (object instanceof String) {
- return (String) object;
+ protected Converter getConverter(FacesContext context, UIOrderingBaseComponent component) {
+ Converter converter = component.getConverter();
+
+ if (converter == null) {
+ converter = component.getConverterForValue(context);
}
- if (null == object) {
- return "null";
+
+ if (converter == null) {
+ converter = DEFAULT_CONVERTER;
}
- if (null == component.getConverter()) {
- return object.toString();
- }
- return component.getConverter().getAsString(context, component, object);
+ return converter;
}
-
- protected Object getAsObject(FacesContext context, UIOrderingBaseComponent component, String string) {
- Converter converter = component.getConverter();
- if (converter != null) {
- return converter.getAsObject(context, component, string);
- } else {
- return string;
- }
- }
public String getCaptionDisplay(FacesContext context, UIComponent component) {
Object caption = component.getAttributes().get(OrderingComponentControlsHelper.ATTRIBUTE_CAPTION_LABEL);
Modified: branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-12-06 02:03:12 UTC (rev 4527)
+++ branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-12-06 03:18:27 UTC (rev 4528)
@@ -14,10 +14,13 @@
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import javax.faces.convert.Converter;
+import org.ajax4jsf.component.UIDataAdaptor;
import org.ajax4jsf.renderkit.ComponentVariables;
import org.ajax4jsf.renderkit.ComponentsVariableResolver;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.UIOrderingBaseComponent;
import org.richfaces.component.UIOrderingList;
import org.richfaces.component.UIOrderingBaseComponent.ItemState;
@@ -81,9 +84,32 @@
}
}
+ private static final class OrderingListRendererTableHolder extends TableHolder {
+
+ private Converter converter;
+
+ public OrderingListRendererTableHolder(UIDataAdaptor table, Converter converter) {
+ super(table);
+
+ this.converter = converter;
+ }
+
+ public Converter getConverter() {
+ return converter;
+ }
+ }
+
+ public void encodeRows(FacesContext context, UIComponent component)
+ throws IOException {
+
+ super.encodeRows(context, component, new OrderingListRendererTableHolder((UIDataAdaptor) component,
+ getConverter(context, (UIOrderingBaseComponent) component)));
+ }
+
public void encodeOneRow(FacesContext context, TableHolder holder)
throws IOException {
ResponseWriter writer = context.getResponseWriter();
+ OrderingListRendererTableHolder tableHolder = (OrderingListRendererTableHolder) holder;
UIOrderingList table = (UIOrderingList) holder.getTable();
String clientId = holder.getTable().getClientId(context);
writer.startElement(HTML.TR_ELEMENT, table);
@@ -155,7 +181,7 @@
}
value.append(':');
- value.append(getAsString(context, table, table.getRowData()));
+ value.append(tableHolder.getConverter().getAsString(context, table, table.getRowData()));
writer.writeAttribute(HTML.value_ATTRIBUTE, value.toString(), null);
@@ -184,10 +210,11 @@
Object activeItem = null;
String[] strings = (String[]) externalContext.getRequestParameterValuesMap().get(clientId);
Map map = new LinkedHashMap();
+ Converter converter = getConverter(context, orderingList);
for (int i = 0; i < strings.length; i++) {
String string = strings[i];
int idx = string.indexOf(':');
- Object value = getAsObject(context, orderingList, string.substring(idx + 1));
+ Object value = converter.getAsObject(context, orderingList, string.substring(idx + 1));
String substring = string.substring(0, idx);
idx = substring.length() - 1;
18 years, 5 months
JBoss Rich Faces SVN: r4527 - branches/3.1.x/samples/orderingListDemo/src/main/webapp/pages.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-12-05 21:03:12 -0500 (Wed, 05 Dec 2007)
New Revision: 4527
Modified:
branches/3.1.x/samples/orderingListDemo/src/main/webapp/pages/index.jsp
Log:
onorderchanged event handler updated
Modified: branches/3.1.x/samples/orderingListDemo/src/main/webapp/pages/index.jsp
===================================================================
--- branches/3.1.x/samples/orderingListDemo/src/main/webapp/pages/index.jsp 2007-12-06 02:03:08 UTC (rev 4526)
+++ branches/3.1.x/samples/orderingListDemo/src/main/webapp/pages/index.jsp 2007-12-06 02:03:12 UTC (rev 4527)
@@ -54,7 +54,7 @@
ontopclick="#{demoBean.ontopclick}"
onbottomclick="#{demoBean.onbottomclick}"
- onorderchanged="new Effect.Highlight('form:onorderchangedDiv', {startcolor:'#FF0000', endcolor:'#FF0000', restorecolor: 'green'});"
+ onorderchanged="orderChanged(event); new Effect.Highlight('form:onorderchangedDiv', {startcolor:'#FF0000', endcolor:'#FF0000', restorecolor: 'green'});"
ondownclick="new Effect.Highlight('form:ondownclickDiv', {startcolor:'#FF0000', endcolor:'#FF0000', restorecolor: 'green'});"
onheaderclick="new Effect.Highlight('form:onheaderclickDiv', {startcolor:'#FF0000', endcolor:'#FF0000', restorecolor: 'green'});"
onupclick="new Effect.Highlight('form:onupclickDiv', {startcolor:'#FF0000', endcolor:'#FF0000', restorecolor: 'green'});" >
@@ -184,6 +184,19 @@
<h:commandButton value="Add item" action="#{demoBean.addItem}" />
<h:commandButton value="Submit" />
<h:commandButton value="Submit immediate" immediate="true" />
+
+ <f:verbatim>
+ <div id="cdiv" style="width: 600px; height: 200px; overflow: auto;"></div>
+
+ <script>
+ function orderChanged(event) {
+ var cdiv = $('cdiv');
+ Element.clearChildren(cdiv);
+ cdiv.appendChild(document.createTextNode(Object.inspect($H(event))));
+ }
+ </script>
+ </f:verbatim>
+
<h3>Ordering lists within a4j:repeat</h3>
<a4j:commandButton reRender="repeat" value="Rerender a4j:repeat" />
<h:commandButton value="Clear list" action="#{demoBean.clear}"></h:commandButton>
18 years, 5 months
JBoss Rich Faces SVN: r4526 - branches/3.1.x/samples/listShuttleDemo/src/main/webapp/pages.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-12-05 21:03:08 -0500 (Wed, 05 Dec 2007)
New Revision: 4526
Modified:
branches/3.1.x/samples/listShuttleDemo/src/main/webapp/pages/index.jsp
Log:
onorderchanged event handler updated
Modified: branches/3.1.x/samples/listShuttleDemo/src/main/webapp/pages/index.jsp
===================================================================
--- branches/3.1.x/samples/listShuttleDemo/src/main/webapp/pages/index.jsp 2007-12-06 02:03:04 UTC (rev 4525)
+++ branches/3.1.x/samples/listShuttleDemo/src/main/webapp/pages/index.jsp 2007-12-06 02:03:08 UTC (rev 4526)
@@ -30,6 +30,7 @@
moveControlsVisible="#{listShuttleDemoBean.moveControlsVisible}"
fastMoveControlsVisible="#{listShuttleDemoBean.fastMoveControlsVisible}"
converter="#{converter}"
+ onorderchanged="orderChanged(event)"
sourceSelection="#{listShuttleDemoBean.sourceSelection}"
targetSelection="#{listShuttleDemoBean.targetSelection}"
@@ -46,6 +47,18 @@
</h:column>
</ls:listShuttle>
+ <f:verbatim>
+ <div id="cdiv" style="width: 600px; height: 200px; overflow: auto;"></div>
+
+ <script>
+ function orderChanged(event) {
+ var cdiv = $('cdiv');
+ Element.clearChildren(cdiv);
+ cdiv.appendChild(document.createTextNode(Object.inspect($H(event))));
+ }
+ </script>
+ </f:verbatim>
+
<h:panelGrid columns="2">
<h:outputText value="Order controls visible:" />
<h:selectBooleanCheckbox value="#{listShuttleDemoBean.orderControlsVisible}" />
18 years, 5 months
JBoss Rich Faces SVN: r4525 - in branches/3.1.x/ui/listShuttle/src/main: templates/org/richfaces and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-12-05 21:03:04 -0500 (Wed, 05 Dec 2007)
New Revision: 4525
Modified:
branches/3.1.x/ui/listShuttle/src/main/config/component/listShuttle.xml
branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx
Log:
onorderchanged event handler updated
Modified: branches/3.1.x/ui/listShuttle/src/main/config/component/listShuttle.xml
===================================================================
--- branches/3.1.x/ui/listShuttle/src/main/config/component/listShuttle.xml 2007-12-06 02:02:58 UTC (rev 4524)
+++ branches/3.1.x/ui/listShuttle/src/main/config/component/listShuttle.xml 2007-12-06 02:03:04 UTC (rev 4525)
@@ -114,8 +114,11 @@
<defaultvalue>true</defaultvalue>
</property>
+ <property>
+ <name>onorderchanged</name>
+ <classname>java.lang.String</classname>
+ </property>
-
<property>
<name>showButtonLabels</name>
<classname>boolean</classname>
Modified: branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx
===================================================================
--- branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx 2007-12-06 02:02:58 UTC (rev 4524)
+++ branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx 2007-12-06 02:03:04 UTC (rev 4525)
@@ -180,7 +180,7 @@
Event.onReady(function() {
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('#{clientId}', '#{clientId}tlInternal_tab', '#{clientId}tlInternal_header_tab', '#{clientId}tlFocusKeeper', cotrolsIdPrefix, '#{clientId}sortLabel', function() {#{component.attributes['onorderchanged']}}),
+ var listShuttle = new Richfaces.ListShuttle(new Richfaces.OrderingList('#{clientId}', '#{clientId}tlInternal_tab', '#{clientId}tlInternal_header_tab', '#{clientId}tlFocusKeeper', cotrolsIdPrefix, '#{clientId}sortLabel', #{this:getAsEventHandler(context, component, "onorderchanged")}),
new Richfaces.ListBase('#{clientId}', '#{clientId}internal_tab', '#{clientId}internal_header_tab', '#{clientId}focusKeeper'),
"#{clientId}", listShuttleCotrolsIdPrefix, "#{switchByClick}");
var sourceLayoutManager = new LayoutManager('#{clientId}internal_header_tab', '#{clientId}internal_tab');
18 years, 5 months