Author: abelevich
Date: 2007-10-02 13:09:12 -0400 (Tue, 02 Oct 2007)
New Revision: 3200
Modified:
trunk/ui/tabPanel/src/main/java/org/richfaces/component/UITabPanel.java
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
Log:
RF-1051, RF-843, RF-1032
Modified: trunk/ui/tabPanel/src/main/java/org/richfaces/component/UITabPanel.java
===================================================================
--- trunk/ui/tabPanel/src/main/java/org/richfaces/component/UITabPanel.java 2007-10-02
16:09:05 UTC (rev 3199)
+++ trunk/ui/tabPanel/src/main/java/org/richfaces/component/UITabPanel.java 2007-10-02
17:09:12 UTC (rev 3200)
@@ -22,10 +22,13 @@
package org.richfaces.component;
import java.util.Iterator;
+import java.util.List;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
@@ -60,7 +63,7 @@
if (object != null) {
return object;
}
-
+
return ((UITab) component).getName();
}
@@ -82,7 +85,7 @@
* @return selectedTab value from local variable or value bindings
*/
public Object getSelectedTab() {
- return getValue();
+ return getValue();
}
/**
@@ -113,7 +116,21 @@
return state;
}
-
+
+ public UITab getTabWithName(Object tabName){
+
+ List children = getChildren();
+ for (Iterator iterator = children.iterator(); iterator.hasNext();) {
+ UIComponent childComponent = (UIComponent) iterator.next();
+
+ if(childComponent instanceof UITab &&
((UITab)childComponent).getName().equals(tabName)){
+ return (UITab)childComponent;
+ }
+ }
+
+ return null;
+ }
+
public void restoreState(FacesContext context, Object state) {
Object[] states = (Object[]) state;
super.restoreState(context, states[0]);
@@ -185,17 +202,38 @@
public abstract void setHeaderClass(String value);
+
+
public void queueEvent(FacesEvent event) {
+
+ FacesEvent processedEvent = event;
+
if (event instanceof SwitchablePanelSwitchEvent &&
this.equals(event.getComponent())) {
-
SwitchablePanelSwitchEvent switchEvent = (SwitchablePanelSwitchEvent) event;
- UIComponent component = switchEvent.getEventSource();
- if((component instanceof UITab) && ((UITab)component).isImmediate()){
+ UIComponent component = switchEvent.getEventSource();
+ UITab savedTab = getTabWithName(getValue());
+ if((component instanceof UITab) && ((UITab)savedTab).isImmediate() ||
isImmediate()){
setImmediate(true);
}else{
setImmediate(false);
}
}
- super.queueEvent(event);
+ // redefine phaseId of ActionEvent RF-843
+ if(event instanceof ActionEvent ){
+ UIComponent component = event.getComponent();
+ UITab savedTab = getTabWithName(getValue());
+
+ if((component instanceof UITab) && ((UITab)savedTab).isImmediate() ||
isImmediate()){
+ setImmediate(true);
+ processedEvent.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
+ }else{
+ setImmediate(false);
+ processedEvent.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ }
+ }
+
+ super.queueEvent(processedEvent);
}
+
+
}
Modified:
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
===================================================================
---
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2007-10-02
16:09:05 UTC (rev 3199)
+++
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2007-10-02
17:09:12 UTC (rev 3200)
@@ -99,12 +99,14 @@
}
} else {
String newValue = (String) requestParameterMap.get(clientId);
+
if (null != newValue) {
- new SwitchablePanelSwitchEvent(panel, newValue, null).queue();
+ new SwitchablePanelSwitchEvent(panel, newValue, null).queue();
}
}
}
+
private static final TabInfoCollector collector = new TabInfoCollector() {
private final JSReference JSR_ACTIVE_CLASS = new
JSReference("activeClass");
private final JSReference JSR_ID = new JSReference("id");
@@ -185,7 +187,7 @@
}
protected String getValueAsString(FacesContext context, UITabPanel tabPanel) {
- return getUtils().getValueAsString(context, tabPanel);
+ return getUtils().getValueAsString(context, tabPanel);
}
private Object checkValue(Object value) {
@@ -276,6 +278,7 @@
ComponentVariables componentVariables =
ComponentsVariableResolver.getVariables(this, tabPanel);
tabPanel.setRenderedValue(null);
+
Object checkedValue = checkValue(tabPanel.getValue());
UITabPanel pane = tabPanel;
@@ -297,7 +300,6 @@
"] has no enabled or rendered tab with such name. Tab: " +
activeTab.getName() +
" will be used instead!";
context.getExternalContext().log(message);
-
tabPanel.setRenderedValue(activeTab.getName());
} else if (checkedValue == null) {
tabPanel.setRenderedValue(activeTab.getName());
Show replies by date