Author: nbelaevski
Date: 2007-11-25 22:06:02 -0500 (Sun, 25 Nov 2007)
New Revision: 4249
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/OrderingComponentControlsHelper.java
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js
Log:
latest changes for 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-11-26
03:05:55 UTC (rev 4248)
+++
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java 2007-11-26
03:06:02 UTC (rev 4249)
@@ -5,15 +5,21 @@
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import javax.faces.FacesException;
+import javax.faces.application.FacesMessage;
import javax.faces.component.EditableValueHolder;
import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
import javax.faces.el.MethodBinding;
import javax.faces.el.ValueBinding;
import javax.faces.model.ArrayDataModel;
@@ -267,4 +273,200 @@
return dataModel;
}
+
+
+ /**
+ * @exception NullPointerException {@inheritDoc}
+ */
+ public void decode(FacesContext context) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ // Force validity back to "true"
+ setValid(true);
+ super.decode(context);
+ }
+
+ /**
+ * <p>Specialized decode behavior on top of that provided by the
+ * superclass. In addition to the standard
+ * <code>processDecodes</code> behavior inherited from {@link
+ * UIComponentBase}, calls <code>validate()</code> if the the
+ * <code>immediate</code> property is true; if the component is
+ * invalid afterwards or a <code>RuntimeException</code> is thrown,
+ * calls {@link FacesContext#renderResponse}. </p>
+ * @exception NullPointerException {@inheritDoc}
+ */
+ public void processDecodes(FacesContext context) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ // Skip processing if our rendered flag is false
+ if (!isRendered()) {
+ return;
+ }
+
+ super.processDecodes(context);
+
+ if (isImmediate()) {
+ executeValidate(context);
+ }
+ }
+
+ /**
+ * Executes validation logic.
+ */
+ private void executeValidate(FacesContext context) {
+ try {
+ validate(context);
+ } catch (RuntimeException e) {
+ context.renderResponse();
+ throw e;
+ }
+
+ if (!isValid()) {
+ context.renderResponse();
+ }
+ }
+
+
+ public abstract void validate(FacesContext context);
+
+ /**
+ * <p>In addition to the standard <code>processValidators</code>
behavior
+ * inherited from {@link UIComponentBase}, calls <code>validate()</code>
+ * if the <code>immediate</code> property is false (which is the
+ * default); if the component is invalid afterwards, calls
+ * {@link FacesContext#renderResponse}.
+ * If a <code>RuntimeException</code> is thrown during
+ * validation processing, calls {@link FacesContext#renderResponse}
+ * and re-throw the exception.
+ * </p>
+ * @exception NullPointerException {@inheritDoc}
+ */
+ public void processValidators(FacesContext context) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ // Skip processing if our rendered flag is false
+ if (!isRendered()) {
+ return;
+ }
+
+ super.processValidators(context);
+ if (!isImmediate()) {
+ executeValidate(context);
+ }
+ }
+
+ /**
+ * <p>In addition to the standard <code>processUpdates</code>
behavior
+ * inherited from {@link UIComponentBase}, calls
+ * <code>updateModel()</code>.
+ * If the component is invalid afterwards, calls
+ * {@link FacesContext#renderResponse}.
+ * If a <code>RuntimeException</code> is thrown during
+ * update processing, calls {@link FacesContext#renderResponse}
+ * and re-throw the exception.
+ * </p>
+ * @exception NullPointerException {@inheritDoc}
+ */
+ public void processUpdates(FacesContext context) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ // Skip processing if our rendered flag is false
+ if (!isRendered()) {
+ return;
+ }
+
+ super.processUpdates(context);
+
+ try {
+ updateModel(context);
+ } catch (RuntimeException e) {
+ context.renderResponse();
+ throw e;
+ }
+
+ if (!isValid()) {
+ context.renderResponse();
+ }
+ }
+
+ public abstract void updateModel(FacesContext context);
+
+ protected interface UpdateModelCommand {
+ public void execute(FacesContext context);
+ }
+
+ protected void updateModel(FacesContext context, UpdateModelCommand command) {
+ try {
+ command.execute(context);
+ } catch (EvaluationException e) {
+ String messageStr = e.getMessage();
+ FacesMessage message = null;
+ if (null == messageStr) {
+ message =
+ MessageFactory.getMessage(context, UIInput.CONVERSION_MESSAGE_ID);
+ }
+ else {
+ message = new FacesMessage(messageStr);
+ }
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ context.addMessage(getClientId(context), message);
+ setValid(false);
+ }
+ catch (FacesException e) {
+ FacesMessage message =
+ MessageFactory.getMessage(context, UIInput.CONVERSION_MESSAGE_ID);
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ context.addMessage(getClientId(context), message);
+ setValid(false);
+ } catch (IllegalArgumentException e) {
+ FacesMessage message =
+ MessageFactory.getMessage(context, UIInput.CONVERSION_MESSAGE_ID);
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ context.addMessage(getClientId(context), message);
+ setValid(false);
+ } catch (Exception e) {
+ FacesMessage message =
+ MessageFactory.getMessage(context, UIInput.CONVERSION_MESSAGE_ID);
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ context.addMessage(getClientId(context), message);
+ setValid(false);
+ }
+ }
+
+ /**
+ * <p>Return <code>true</code> if the new value is different from the
+ * previous value.</p>
+ *
+ * @param previous old value of this component (if any)
+ * @param value new value of this component (if any)
+ */
+ protected boolean compareValues(Object previous, Object value) {
+
+ if (previous == null) {
+ return (value != null);
+ } else if (value == null) {
+ return (true);
+ } else {
+ if (previous instanceof Object[]) {
+ return !Arrays.equals((Object[]) previous, (Object[]) value);
+ } else {
+ return (!(previous.equals(value)));
+ }
+ }
+
+ }
+
}
Modified:
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
===================================================================
---
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java 2007-11-26
03:05:55 UTC (rev 4248)
+++
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java 2007-11-26
03:06:02 UTC (rev 4249)
@@ -29,9 +29,7 @@
import javax.faces.event.FacesEvent;
import javax.faces.event.ValueChangeEvent;
import javax.faces.event.ValueChangeListener;
-import javax.faces.model.ArrayDataModel;
import javax.faces.model.DataModel;
-import javax.faces.model.ListDataModel;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
@@ -370,9 +368,6 @@
super.processDecodes(context);
- if (isImmediate()) {
- executeValidate(context);
- }
}
/**
@@ -399,9 +394,6 @@
}
super.processValidators(context);
- if (!isImmediate()) {
- executeValidate(context);
- }
}
/**
@@ -428,34 +420,9 @@
}
super.processUpdates(context);
-
- try {
- updateModel(context);
- } catch (RuntimeException e) {
- context.renderResponse();
- throw e;
- }
-
- if (!isValid()) {
- context.renderResponse();
- }
}
/**
- * @exception NullPointerException {@inheritDoc}
- */
- public void decode(FacesContext context) {
-
- if (context == null) {
- throw new NullPointerException();
- }
-
- // Force validity back to "true"
- setValid(true);
- super.decode(context);
- }
-
- /**
* <p>In addition to to the default {@link UIComponent#broadcast}
* processing, pass the {@link ValueChangeEvent} being broadcast to the
* method referenced by <code>valueChangeListener</code> (if
any).</p>
@@ -486,10 +453,6 @@
}
- private interface UpdateModelCommand {
- public void execute(FacesContext context);
- }
-
private final UpdateModelCommand updateValueCommand = new UpdateModelCommand() {
public void execute(FacesContext context) {
@@ -535,44 +498,6 @@
};
- private void updateModel(FacesContext context, UpdateModelCommand command) {
- try {
- command.execute(context);
- } catch (EvaluationException e) {
- String messageStr = e.getMessage();
- FacesMessage message = null;
- if (null == messageStr) {
- message =
- MessageFactory.getMessage(context, UIInput.CONVERSION_MESSAGE_ID);
- }
- else {
- message = new FacesMessage(messageStr);
- }
- message.setSeverity(FacesMessage.SEVERITY_ERROR);
- context.addMessage(getClientId(context), message);
- setValid(false);
- }
- catch (FacesException e) {
- FacesMessage message =
- MessageFactory.getMessage(context, UIInput.CONVERSION_MESSAGE_ID);
- message.setSeverity(FacesMessage.SEVERITY_ERROR);
- context.addMessage(getClientId(context), message);
- setValid(false);
- } catch (IllegalArgumentException e) {
- FacesMessage message =
- MessageFactory.getMessage(context, UIInput.CONVERSION_MESSAGE_ID);
- message.setSeverity(FacesMessage.SEVERITY_ERROR);
- context.addMessage(getClientId(context), message);
- setValid(false);
- } catch (Exception e) {
- FacesMessage message =
- MessageFactory.getMessage(context, UIInput.CONVERSION_MESSAGE_ID);
- message.setSeverity(FacesMessage.SEVERITY_ERROR);
- context.addMessage(getClientId(context), message);
- setValid(false);
- }
- }
-
/**
* <p>Perform the following algorithm to update the model data
* associated with this {@link UIInput}, if any, as appropriate.</p>
@@ -860,46 +785,6 @@
- /**
- * <p>Return <code>true</code> if the new value is different from the
- * previous value.</p>
- *
- * @param previous old value of this component (if any)
- * @param value new value of this component (if any)
- */
- protected boolean compareValues(Object previous, Object value) {
-
- if (previous == null) {
- return (value != null);
- } else if (value == null) {
- return (true);
- } else {
- if (previous instanceof Object[]) {
- return !Arrays.equals((Object[]) previous, (Object[]) value);
- } else {
- return (!(previous.equals(value)));
- }
- }
-
- }
-
-
- /**
- * Executes validation logic.
- */
- private void executeValidate(FacesContext context) {
- try {
- validate(context);
- } catch (RuntimeException e) {
- context.renderResponse();
- throw e;
- }
-
- if (!isValid()) {
- context.renderResponse();
- }
- }
-
private boolean isEmpty(Object value) {
if (value == null) {
Modified:
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentControlsHelper.java
===================================================================
---
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentControlsHelper.java 2007-11-26
03:05:55 UTC (rev 4248)
+++
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentControlsHelper.java 2007-11-26
03:06:02 UTC (rev 4249)
@@ -78,7 +78,7 @@
protected static final OrderingComponentRendererBase.ControlsHelper[] HELPERS = new
OrderingComponentRendererBase.ControlsHelper[] {
new OrderingComponentRendererBase.ControlsHelper("top",
"TOP_LABEL", DEFAULT_LABEL_TOP, OrderingListIconTop.class.getName(), FACET_TOP,
" rich-ordering-control-top", ATTRIBUTE_CLASS_TOP_CONTROL,
ATTRIBUTE_CLASS_BUTTON,
- CONTROL_ID_TOP, ATTRIBUTE_CE_ONTOPCLICK, true, "topControlLabel") {
+ CONTROL_ID_TOP, ATTRIBUTE_CE_ONTOPCLICK, true) {
public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
return list.isFastOrderControlsVisible();
@@ -87,7 +87,7 @@
},
new OrderingComponentRendererBase.ControlsHelper("disabledTop",
"TOP_LABEL", DEFAULT_LABEL_TOP, OrderingListIconTopDisabled.class.getName(),
FACET_DIS_TOP,
" rich-ordering-control-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL,
ATTRIBUTE_CLASS_BUTTON_DISABLED,
- DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_TOP), null, false,
"topControlLabel") {
+ DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_TOP), null, false) {
public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
return list.isFastOrderControlsVisible();
@@ -96,7 +96,7 @@
},
new OrderingComponentRendererBase.ControlsHelper("up", "UP_LABEL",
DEFAULT_LABEL_UP, OrderingListIconUp.class.getName(), FACET_UP,
" rich-ordering-control-up", ATTRIBUTE_CLASS_UP_CONTROL,
ATTRIBUTE_CLASS_BUTTON,
- CONTROL_ID_UP, ATTRIBUTE_CE_ONUPCLICK ,true, "upControlLabel") {
+ CONTROL_ID_UP, ATTRIBUTE_CE_ONUPCLICK ,true) {
public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
return list.isOrderControlsVisible();
@@ -105,7 +105,7 @@
},
new OrderingComponentRendererBase.ControlsHelper("disabledUp",
"UP_LABEL", DEFAULT_LABEL_UP, OrderingListIconUpDisabled.class.getName(),
FACET_DIS_UP,
" rich-ordering-control-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL,
ATTRIBUTE_CLASS_BUTTON_DISABLED,
- DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_UP), null, false,
"upControlLabel") {
+ DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_UP), null, false) {
public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
return list.isOrderControlsVisible();
@@ -114,7 +114,7 @@
},
new OrderingComponentRendererBase.ControlsHelper("down",
"DOWN_LABEL", DEFAULT_LABEL_DOWN, OrderingListIconDown.class.getName(),
FACET_DOWN,
" rich-ordering-control-down", ATTRIBUTE_CLASS_DOWN_CONTROL,
ATTRIBUTE_CLASS_BUTTON,
- CONTROL_ID_DOWN, ATTRIBUTE_CE_ONDOWNCLICK, true, "downControlLabel")
{
+ CONTROL_ID_DOWN, ATTRIBUTE_CE_ONDOWNCLICK, true) {
public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
return list.isOrderControlsVisible();
@@ -123,7 +123,7 @@
},
new OrderingComponentRendererBase.ControlsHelper("disabledDown",
"DOWN_LABEL", DEFAULT_LABEL_DOWN, OrderingListIconDownDisabled.class.getName(),
FACET_DIS_DOWN,
" rich-ordering-control-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL,
ATTRIBUTE_CLASS_BUTTON_DISABLED,
- DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_DOWN), null, false,
"downControlLabel") {
+ DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_DOWN), null, false) {
public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
return list.isOrderControlsVisible();
@@ -132,7 +132,7 @@
},
new OrderingComponentRendererBase.ControlsHelper("bottom",
"BOTTOM_LABEL", DEFAULT_LABEL_BOTTOM, OrderingListIconBottom.class.getName(),
FACET_BOTTOM,
" rich-ordering-control-bottom", ATTRIBUTE_CLASS_BOTTOM_CONTROL,
ATTRIBUTE_CLASS_BUTTON,
- CONTROL_ID_BOTTOM, ATTRIBUTE_CE_ONBOTTOMCLICK, true,
"bottomControlLabel") {
+ CONTROL_ID_BOTTOM, ATTRIBUTE_CE_ONBOTTOMCLICK, true) {
public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
return list.isFastOrderControlsVisible();
@@ -141,7 +141,7 @@
},
new OrderingComponentRendererBase.ControlsHelper("disabledBottom",
"BOTTOM_LABEL", DEFAULT_LABEL_BOTTOM,
OrderingListIconBottomDisabled.class.getName(), FACET_DIS_BOTTOM,
" rich-ordering-control-disabled", ATTRIBUTE_CLASS_DISABLED_CONTROL,
ATTRIBUTE_CLASS_BUTTON_DISABLED,
- DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_BOTTOM), null, false,
"bottomControlLabel") {
+ DIS_CONTROL_ID_PREFIX.concat(CONTROL_ID_BOTTOM), null, false) {
public boolean isRendered(FacesContext context, UIOrderingBaseComponent list) {
return list.isFastOrderControlsVisible();
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-11-26
03:05:55 UTC (rev 4248)
+++
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java 2007-11-26
03:06:02 UTC (rev 4249)
@@ -66,7 +66,7 @@
public ControlsHelper(String name, String bundlePropertyName, String defaultText,
String imageURI,
String facetName, String styleClassName, String styleFromAttribute, String
buttonStyleClass,
- String idSuffix, String customEvent, boolean isEnable, String labelAttributeName) {
+ String idSuffix, String customEvent, boolean isEnable) {
super();
this.name = name;
this.bundlePropertyName = bundlePropertyName;
@@ -79,7 +79,7 @@
this.customEvent = customEvent;
this.buttonStyleClass = buttonStyleClass;
this.enable = isEnable;
- this.labelAttributeName = labelAttributeName;
+ this.labelAttributeName = name + "ControlLabel";
}
public String getName() {
Modified:
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js
===================================================================
---
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js 2007-11-26
03:05:55 UTC (rev 4248)
+++
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js 2007-11-26
03:06:02 UTC (rev 4249)
@@ -363,9 +363,9 @@
},
saveState : function() {
- if (this.activeItem != null || (this.selectedItems.length > 0)) {
+ //if (this.activeItem != null || (this.selectedItems.length > 0)) {
this.valueKeeper.value = this.getAsString();
- }
+ //}
}
}