myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r1751784 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/event/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/ tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/toba...
Date Thu, 07 Jul 2016 12:17:27 GMT
Author: lofwyr
Date: Thu Jul  7 12:17:27 2016
New Revision: 1751784

URL: http://svn.apache.org/viewvc?rev=1751784&view=rev
Log:
TOBAGO 1565: Specification for "collapsible" for Popup, Box, Section, ...
-listener must be a state holder

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/CollapsibleActionListener.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommand.java
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/CollapsibleController.java
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/10-collapsible-popup/collapsible-popup.xhtml

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/CollapsibleActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/CollapsibleActionListener.java?rev=1751784&r1=1751783&r2=1751784&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/CollapsibleActionListener.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/CollapsibleActionListener.java
Thu Jul  7 12:17:27 2016
@@ -24,6 +24,7 @@ import org.apache.myfaces.tobago.util.Co
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.faces.component.StateHolder;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIViewRoot;
 import javax.faces.context.FacesContext;
@@ -31,15 +32,19 @@ import javax.faces.event.AbortProcessing
 import javax.faces.event.ActionEvent;
 import javax.faces.event.ActionListener;
 
-public class CollapsibleActionListener implements ActionListener {
+public class CollapsibleActionListener implements ActionListener, StateHolder {
 
   private static final Logger LOG = LoggerFactory.getLogger(CollapsibleActionListener.class);
 
-  private UIComponent component;
   private String forId;
 
-  public CollapsibleActionListener(final UIComponent component, final String forId) {
-    this.component = component;
+  private boolean transientFlag;
+
+  public CollapsibleActionListener() {
+    // for state holder
+  }
+
+  public CollapsibleActionListener(final String forId) {
     this.forId = forId;
   }
 
@@ -48,7 +53,7 @@ public class CollapsibleActionListener i
     final FacesContext facesContext = FacesContext.getCurrentInstance();
     final UIViewRoot viewRoot = facesContext.getViewRoot();
     if (viewRoot != null) {
-      final String forClientId = ComponentUtils.evaluateClientId(facesContext, component,
forId);
+      final String forClientId = ComponentUtils.evaluateClientId(facesContext, actionEvent.getComponent(),
forId);
 
       final UIComponent component = viewRoot.findComponent(forClientId);
       if (component instanceof AbstractUICollapsiblePanel) {
@@ -59,4 +64,24 @@ public class CollapsibleActionListener i
       }
     }
   }
+
+  @Override
+  public Object saveState(FacesContext context) {
+    return forId;
+  }
+
+  @Override
+  public void restoreState(FacesContext context, Object state) {
+    this.forId = (String) state;
+  }
+
+  @Override
+  public boolean isTransient() {
+    return transientFlag;
+  }
+
+  @Override
+  public void setTransient(boolean transientFlag) {
+    this.transientFlag = transientFlag;
+  }
 }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommand.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommand.java?rev=1751784&r1=1751783&r2=1751784&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommand.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommand.java
Thu Jul  7 12:17:27 2016
@@ -63,7 +63,7 @@ public abstract class AbstractUICommand
 
     final List<AbstractUIOperation> list = ComponentUtils.findDescendantList(this,
AbstractUIOperation.class);
     for (AbstractUIOperation operation : list) {
-      addActionListener(new CollapsibleActionListener(this, operation.getFor()));
+      addActionListener(new CollapsibleActionListener(operation.getFor()));
     }
   }
 

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/CollapsibleController.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/CollapsibleController.java?rev=1751784&r1=1751783&r2=1751784&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/CollapsibleController.java
(original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/CollapsibleController.java
Thu Jul  7 12:17:27 2016
@@ -23,6 +23,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.enterprise.context.SessionScoped;
+import javax.faces.context.FacesContext;
 import javax.inject.Named;
 import java.io.Serializable;
 
@@ -34,6 +35,11 @@ public class CollapsibleController imple
 
   private boolean collapsed = true;
 
+  public String submit() {
+    LOG.info("submit(): collapsed={}", collapsed);
+    return FacesContext.getCurrentInstance().getViewRoot().getViewId();
+  }
+
   public String action() {
     LOG.info("action(): collapsed={}", collapsed);
     return null;

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/10-collapsible-popup/collapsible-popup.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/10-collapsible-popup/collapsible-popup.xhtml?rev=1751784&r1=1751783&r2=1751784&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/10-collapsible-popup/collapsible-popup.xhtml
(original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/10-collapsible-popup/collapsible-popup.xhtml
Thu Jul  7 12:17:27 2016
@@ -55,7 +55,7 @@
     <!--<tc:out value="#{collapsibleController.collapsed}" label="collapsed"/>-->
 
     <tc:flowLayout textAlign="right">
-      <tc:button label="Submit"/>
+      <tc:button label="Submit" action="#{collapsibleController.submit}"/>
     </tc:flowLayout>
   </tc:section>
 



Mime
View raw message