Author: nbelaevski
Date: 2008-06-26 18:35:48 -0400 (Thu, 26 Jun 2008)
New Revision: 9259
Modified:
trunk/ui/simpleTogglePanel/src/main/java/org/richfaces/component/UISimpleTogglePanel.java
trunk/ui/simpleTogglePanel/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanelRenderer.java
Log:
http://jira.jboss.com/jira/browse/RF-3799
Modified:
trunk/ui/simpleTogglePanel/src/main/java/org/richfaces/component/UISimpleTogglePanel.java
===================================================================
---
trunk/ui/simpleTogglePanel/src/main/java/org/richfaces/component/UISimpleTogglePanel.java 2008-06-26
22:29:09 UTC (rev 9258)
+++
trunk/ui/simpleTogglePanel/src/main/java/org/richfaces/component/UISimpleTogglePanel.java 2008-06-26
22:35:48 UTC (rev 9259)
@@ -21,7 +21,10 @@
package org.richfaces.component;
+import java.util.Iterator;
+
import javax.faces.component.ActionSource;
+import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import org.ajax4jsf.component.AjaxActionComponent;
@@ -41,8 +44,21 @@
public static final String AJAX_SWITCH_TYPE = "ajax";
public static final boolean COLLAPSED = false;
public static final boolean EXPANDED = true;
+
+ private transient Boolean wasOpened = null;
+
+ protected boolean isWasOpened() {
+ if (wasOpened == null) {
+ if (CLIENT_SWITCH_TYPE.equals(getSwitchType())) {
+ wasOpened = Boolean.TRUE;
+ } else {
+ wasOpened = isOpened();
+ }
+ }
+
+ return wasOpened;
+ }
-
public abstract void setSwitchType(String switchType);
public abstract String getSwitchType();
@@ -57,7 +73,7 @@
return ((Boolean)value).booleanValue();
} else if (value instanceof String) {
String s = (String) value;
- return new Boolean(s).booleanValue();
+ return Boolean.parseBoolean(s);
}
return true;
}
@@ -66,20 +82,88 @@
return true;
}
- public void processDecodes(FacesContext context) {
- if (isOpened()) {
- super.processDecodes(context);
- } else {
- if (context == null) {
- throw new NullPointerException();
- }
- // Skip processing if our rendered flag is false
- if (!isRendered()) {
- return;
- }
- decode(context);
- }
- }
+ /**
+ * @throws NullPointerException {@inheritDoc}
+ */
+ public void processDecodes(FacesContext context) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ // Skip processing if our rendered flag is false
+ if (!isRendered()) {
+ return;
+ }
+
+ if (isWasOpened()) {
+ // Process all facets and children of this component
+ Iterator<UIComponent> kids = getFacetsAndChildren();
+ while (kids.hasNext()) {
+ UIComponent kid = kids.next();
+ kid.processDecodes(context);
+ }
+ }
+
+ // Process this component itself
+ try {
+ decode(context);
+ } catch (RuntimeException e) {
+ context.renderResponse();
+ throw e;
+ }
+
+ }
+
+
+ /**
+ * @throws NullPointerException {@inheritDoc}
+ */
+ public void processValidators(FacesContext context) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ // Skip processing if our rendered flag is false
+ if (!isRendered()) {
+ return;
+ }
+
+ if (isWasOpened()) {
+ // Process all the facets and children of this component
+ Iterator<UIComponent> kids = getFacetsAndChildren();
+ while (kids.hasNext()) {
+ UIComponent kid = kids.next();
+ kid.processValidators(context);
+ }
+ }
+ }
+
+
+ /**
+ * @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;
+ }
+
+ if (isWasOpened()) {
+ // Process all facets and children of this component
+ Iterator<UIComponent> kids = getFacetsAndChildren();
+ while (kids.hasNext()) {
+ UIComponent kid = kids.next();
+ kid.processUpdates(context);
+ }
+ }
+ }
Modified:
trunk/ui/simpleTogglePanel/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanelRenderer.java
===================================================================
---
trunk/ui/simpleTogglePanel/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanelRenderer.java 2008-06-26
22:29:09 UTC (rev 9258)
+++
trunk/ui/simpleTogglePanel/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanelRenderer.java 2008-06-26
22:35:48 UTC (rev 9259)
@@ -24,25 +24,22 @@
*/
package org.richfaces.renderkit.html;
+import java.io.IOException;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseId;
+
import org.ajax4jsf.component.AjaxSupport;
import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.RendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.UISimpleTogglePanel;
import org.richfaces.event.SimpleToggleEvent;
-import javax.faces.component.UIComponent;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.event.ActionEvent;
-import javax.faces.event.PhaseId;
-import java.io.IOException;
-import java.util.Map;
-
//public class SimpleTogglePanelRenderer extends AjaxCommandLinkRenderer {
public class SimpleTogglePanelRenderer extends
org.ajax4jsf.renderkit.HeaderResourcesRendererBase {
@@ -105,8 +102,9 @@
event.queue();
} else {
- if (panel.isOpened()!= new Boolean((String) clnId).booleanValue()){
- panel.setAjaxSingle(false);
+ boolean submittedState = Boolean.parseBoolean((String) clnId);
+ if (panel.isOpened() != submittedState){
+ //panel.setAjaxSingle(false);
SimpleToggleEvent event = new SimpleToggleEvent(panel,
(panel.isOpened()));
if (panel.isImmediate()) {
event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
@@ -116,7 +114,7 @@
event.queue();
}
if (null == panel.getValueBinding("value"))
- panel.setOpened(new Boolean((String) clnId).booleanValue());
+ panel.setOpened(submittedState);
}
// in case of "ajax" request and "ajax" switch mode of
toggle panel