Author: dsvyatobatsko
Date: 2009-02-13 08:33:28 -0500 (Fri, 13 Feb 2009)
New Revision: 12653
Modified:
trunk/ui/dataFilterSlider/src/main/java/org/richfaces/component/UIDataFltrSlider.java
Log:
https://jira.jboss.org/jira/browse/RF-5328
Modified:
trunk/ui/dataFilterSlider/src/main/java/org/richfaces/component/UIDataFltrSlider.java
===================================================================
---
trunk/ui/dataFilterSlider/src/main/java/org/richfaces/component/UIDataFltrSlider.java 2009-02-13
13:24:05 UTC (rev 12652)
+++
trunk/ui/dataFilterSlider/src/main/java/org/richfaces/component/UIDataFltrSlider.java 2009-02-13
13:33:28 UTC (rev 12653)
@@ -26,8 +26,13 @@
import java.util.List;
import java.util.Map;
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
import javax.faces.component.UIData;
+import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.el.MethodBinding;
import javax.faces.event.AbortProcessingException;
@@ -37,6 +42,7 @@
import org.ajax4jsf.component.AjaxActionComponent;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.RendererUtils;
+import org.richfaces.component.util.MessageUtil;
import org.richfaces.event.DataFilterSliderAdapter;
import org.richfaces.event.DataFilterSliderEvent;
import org.richfaces.event.DataFilterSliderListener;
@@ -108,7 +114,89 @@
decode(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>
+ *
+ * @throws 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;
+ }
+ }
+
+ protected void updateModel(FacesContext context) {
+ Integer handleValue = getHandleValue();
+ if (null != handleValue) {
+ ValueExpression ve = getValueExpression("handleValue");
+ if (ve != null) {
+ try {
+ ve.setValue(context.getELContext(), handleValue);
+ setHandleValue(null);
+ } catch (ELException e) {
+ String messageStr = e.getMessage();
+ Throwable result = e.getCause();
+ while (null != result &&
result.getClass().isAssignableFrom(ELException.class)) {
+ messageStr = result.getMessage();
+ result = result.getCause();
+ }
+ FacesMessage message;
+ if (null == messageStr) {
+ message =
+ // not an UIInput, but constant is fine
+ MessageUtil.getMessage(context, UIInput.UPDATE_MESSAGE_ID, new
Object[] { MessageUtil.getLabel(
+ context, this) });
+ } else {
+ message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
messageStr, messageStr);
+ }
+
+ context.getExternalContext().log(message.getSummary(), result);
+ context.addMessage(getClientId(context), message);
+ context.renderResponse();
+ } catch (IllegalArgumentException e) {
+ FacesMessage message = MessageUtil.getMessage(context,
UIInput.UPDATE_MESSAGE_ID,
+ new Object[] { MessageUtil.getLabel(context, this) });
+
+ context.getExternalContext().log(message.getSummary(), e);
+ context.addMessage(getClientId(context), message);
+ context.renderResponse();
+ } catch (Exception e) {
+ FacesMessage message = MessageUtil.getMessage(context,
UIInput.UPDATE_MESSAGE_ID,
+ new Object[] { MessageUtil.getLabel(context, this) });
+
+ context.getExternalContext().log(message.getSummary(), e);
+ context.addMessage(getClientId(context), message);
+ context.renderResponse();
+ }
+ }
+ }
+ }
+
+ /**
* @return Returns the active.
*/
public boolean isActive() {
@@ -116,7 +204,9 @@
}
/**
- * @param active The active to set. This method should never be called from user
code.
+ * @param active
+ * The active to set. This method should never be called from
+ * user code.
*/
public void setActive(boolean active) {
_active = active;