Author: abelevich
Date: 2011-02-17 14:14:59 -0500 (Thu, 17 Feb 2011)
New Revision: 21743
Modified:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/panelmenu/PanelMenuBean.java
trunk/ui/output/api/src/main/java/org/richfaces/event/ItemChangeEvent.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenu.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTab.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java
Log:
RF-10054 Panels: attributes bypassUpdates and immediate ignored
Modified:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/panelmenu/PanelMenuBean.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/panelmenu/PanelMenuBean.java 2011-02-17
19:09:37 UTC (rev 21742)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/panelmenu/PanelMenuBean.java 2011-02-17
19:14:59 UTC (rev 21743)
@@ -28,6 +28,6 @@
}
public void updateCurrent(ItemChangeEvent event) {
- setCurrent(event.getNewItem());
+ setCurrent(event.getNewItemName());
}
}
Modified: trunk/ui/output/api/src/main/java/org/richfaces/event/ItemChangeEvent.java
===================================================================
--- trunk/ui/output/api/src/main/java/org/richfaces/event/ItemChangeEvent.java 2011-02-17
19:09:37 UTC (rev 21742)
+++ trunk/ui/output/api/src/main/java/org/richfaces/event/ItemChangeEvent.java 2011-02-17
19:14:59 UTC (rev 21743)
@@ -38,8 +38,11 @@
private static final long serialVersionUID = -4747704006016875163L;
- private final String oldItem;
- private final String newItem;
+ private final String oldItemName;
+ private final String newItemName;
+
+ private final UIComponent oldItem;
+ private final UIComponent newItem;
// ------------------------------------------------------------ Constructors
@@ -52,28 +55,38 @@
*
* @param component Source {@link UIComponent} for this event
*
- * @param oldItem
- * @param newItem
+ * @param oldItemName
+ * @param newItemName
*
* @throws IllegalArgumentException if <code>component</code> is
* <code>null</code>
*/
- public ItemChangeEvent(UIComponent component, String oldItem, String newItem) {
+ public ItemChangeEvent(UIComponent component, String oldItemName, UIComponent
oldItem,
+ String newItemName, UIComponent newItem) {
super(component);
+ this.oldItemName = oldItemName;
+ this.newItemName = newItemName;
this.oldItem = oldItem;
this.newItem = newItem;
}
-
// -------------------------------------------------------------- Properties
- public String getOldItem() {
+ public String getOldItemName() {
+ return oldItemName;
+ }
+
+ public String getNewItemName() {
+ return newItemName;
+ }
+
+ public UIComponent getOldItem() {
return oldItem;
}
- public String getNewItem() {
+ public UIComponent getNewItem() {
return newItem;
- }
+ }
// ------------------------------------------------- Event Broadcast Methods
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java 2011-02-17
19:09:37 UTC (rev 21742)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java 2011-02-17
19:14:59 UTC (rev 21743)
@@ -24,6 +24,8 @@
import javax.el.MethodExpression;
import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
import org.richfaces.cdk.annotations.Attribute;
@@ -99,11 +101,9 @@
public void queueEvent(FacesEvent facesEvent) {
PanelToggleEvent event = null;
if ((facesEvent instanceof ItemChangeEvent) && (facesEvent.getComponent()
== this)) {
- event = new PanelToggleEvent(this, Boolean.valueOf(((ItemChangeEvent)
facesEvent).getNewItem()));
-
+ event = new PanelToggleEvent(this, Boolean.valueOf(((ItemChangeEvent)
facesEvent).getNewItemName()));
setEventPhase(event);
}
-
super.queueEvent(event != null ? event : facesEvent);
}
@@ -215,4 +215,14 @@
public void setValue(Object value) {
setExpanded(Boolean.parseBoolean((String) value));
}
+
+ @Override
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ super.broadcast(event);
+
+ if (event instanceof PanelToggleEvent
+ && (isBypassUpdates() || isImmediate())) {
+ FacesContext.getCurrentInstance().renderResponse();
+ }
+ }
}
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenu.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenu.java 2011-02-17
19:09:37 UTC (rev 21742)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenu.java 2011-02-17
19:14:59 UTC (rev 21743)
@@ -95,15 +95,16 @@
setSubmittedActiveItem(null);
if (previous == null || !previous.equalsIgnoreCase(activeItem)) {
- AbstractPanelMenuItem prevItm = getItem(previous);
+ AbstractPanelMenuItem prevItm = null;
+ if (previous != null) {
+ prevItm = getItem(previous);
+ }
AbstractPanelMenuItem actItm = getItem(activeItem);
- ItemChangeEvent event = new ItemChangeEvent(this, previous, activeItem);
- if (isImmediate() ||
- ((prevItm != null && prevItm.isImmediate()) ||
- (actItm != null && actItm.isImmediate()))) {
+ ItemChangeEvent event = new ItemChangeEvent(this, previous,prevItm,
activeItem, actItm);
+ if (isImmediate() || (actItm != null && actItm.isImmediate())) {
event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
- } else if (prevItm.isBypassUpdates() || actItm.isBypassUpdates()) {
+ } else if (actItm.isBypassUpdates()) {
event.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
} else {
event.setPhaseId(PhaseId.INVOKE_APPLICATION);
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTab.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTab.java 2011-02-17
19:09:37 UTC (rev 21742)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTab.java 2011-02-17
19:14:59 UTC (rev 21743)
@@ -22,12 +22,16 @@
package org.richfaces.component;
-import org.richfaces.cdk.annotations.*;
-import org.richfaces.renderkit.html.DivPanelRenderer;
-
import javax.faces.component.UIComponent;
import javax.faces.component.behavior.ClientBehaviorHolder;
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.annotations.TagType;
+import org.richfaces.renderkit.html.DivPanelRenderer;
+
/**
* @author akolonitsky
* @since 2010-10-19
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java 2011-02-17
19:09:37 UTC (rev 21742)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java 2011-02-17
19:14:59 UTC (rev 21743)
@@ -57,6 +57,7 @@
import org.richfaces.event.ItemChangeEvent;
import org.richfaces.event.ItemChangeListener;
import org.richfaces.event.ItemChangeSource;
+import org.richfaces.renderkit.util.RendererUtils;
import com.google.common.base.Strings;
@@ -215,10 +216,8 @@
} finally {
popComponentFromEL(context);
}
-
- if (isImmediate()) {
- executeValidate(context);
- }
+
+ createItemChangeEvent(context);
}
/**
@@ -303,7 +302,6 @@
popComponentFromEL(context);
- executeValidate(context);
try {
updateModel(context);
} catch (RuntimeException e) {
@@ -387,21 +385,7 @@
}
}
- private void executeValidate(FacesContext context) {
- try {
- validate(context);
- } catch (RuntimeException e) {
- context.renderResponse();
- throw e;
- }
-
- if (!isValid()) {
- context.validationFailed();
- context.renderResponse();
- }
- }
-
- public void validate(FacesContext context) {
+ private void createItemChangeEvent(FacesContext context) {
if (context == null) {
throw new NullPointerException();
}
@@ -416,19 +400,36 @@
setValue(activeItem);
setSubmittedActiveItem(null);
if (previous == null || !previous.equalsIgnoreCase(activeItem)) {
- queueEvent(new ItemChangeEvent(this, previous, activeItem));
+ UIComponent prevComp = null;
+ UIComponent actvComp = (UIComponent)getItem(activeItem);
+
+ if (previous != null) {
+ prevComp = (UIComponent)getItem(previous);
+ }
+ new ItemChangeEvent(this, previous, prevComp, activeItem, actvComp).queue();
}
}
-
+
@Override
public void queueEvent(FacesEvent event) {
if ((event instanceof ItemChangeEvent) && (event.getComponent() == this))
{
- setEventPhase(event);
+ setEventPhase((ItemChangeEvent)event);
}
-
super.queueEvent(event);
}
+ protected void setEventPhase(ItemChangeEvent event) {
+ if (isImmediate() || (event.getNewItem() != null &&
+ RendererUtils.getInstance().isBooleanAttribute(event.getNewItem(),
"immediate"))) {
+ event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
+ } else if (isBypassUpdates() || (event.getNewItem() != null &&
+ RendererUtils.getInstance().isBooleanAttribute(event.getNewItem(),
"bypassUpdates"))) {
+ event.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
+ } else {
+ event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ }
+ }
+
protected void setEventPhase(FacesEvent event) {
if (isImmediate()) {
event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
@@ -443,8 +444,7 @@
public void broadcast(FacesEvent event) throws AbortProcessingException {
super.broadcast(event);
- if (event instanceof ItemChangeEvent
- && (isBypassUpdates() || isImmediate())) {
+ if (event instanceof ItemChangeEvent) {
FacesContext.getCurrentInstance().renderResponse();
}
}