You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by do...@apache.org on 2016/04/07 13:28:42 UTC

empire-db git commit: EMPIREDB-235 allow client behavior updates

Repository: empire-db
Updated Branches:
  refs/heads/master f5717af33 -> a812088bc


EMPIREDB-235
allow client behavior updates


Project: http://git-wip-us.apache.org/repos/asf/empire-db/repo
Commit: http://git-wip-us.apache.org/repos/asf/empire-db/commit/a812088b
Tree: http://git-wip-us.apache.org/repos/asf/empire-db/tree/a812088b
Diff: http://git-wip-us.apache.org/repos/asf/empire-db/diff/a812088b

Branch: refs/heads/master
Commit: a812088bc78f7d98d19842d6abe0f4a7727deb83
Parents: f5717af
Author: Rainer Döbele <do...@apache.org>
Authored: Thu Apr 7 13:28:35 2016 +0200
Committer: Rainer Döbele <do...@apache.org>
Committed: Thu Apr 7 13:28:35 2016 +0200

----------------------------------------------------------------------
 .../empire/jsf2/components/SelectTag.java       | 11 ++++++++++
 .../controls/InputAttachedObjectsHandler.java   | 12 +++++++++++
 .../empire/jsf2/controls/InputControl.java      | 21 +++++++++++++++++++-
 3 files changed, 43 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/empire-db/blob/a812088b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/SelectTag.java
----------------------------------------------------------------------
diff --git a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/SelectTag.java b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/SelectTag.java
index 91a18c8..b007e51 100644
--- a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/SelectTag.java
+++ b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/SelectTag.java
@@ -121,6 +121,10 @@ public class SelectTag extends UIInput implements NamingContainer
             // attach objects
             addAttachedObjects(context, inputComponent);
         }
+        else
+        {   // update attached objects
+            updateAttachedObjects(context, inputComponent);
+        }
         // render components
         inputComponent.encodeAll(context);
         // default
@@ -274,4 +278,11 @@ public class SelectTag extends UIInput implements NamingContainer
         if (aoh!=null)
             aoh.addAttachedObjects(this, context, null, inputComponent);
     }
+    
+    protected void updateAttachedObjects(FacesContext context, UIInput inputComponent)
+    {
+        InputAttachedObjectsHandler aoh = InputControlManager.getAttachedObjectsHandler();
+        if (aoh!=null)
+            aoh.updateAttachedObjects(this, context, null, inputComponent);
+    }
 }

http://git-wip-us.apache.org/repos/asf/empire-db/blob/a812088b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputAttachedObjectsHandler.java
----------------------------------------------------------------------
diff --git a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputAttachedObjectsHandler.java b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputAttachedObjectsHandler.java
index 41975aa..61b388a 100644
--- a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputAttachedObjectsHandler.java
+++ b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputAttachedObjectsHandler.java
@@ -61,6 +61,18 @@ public class InputAttachedObjectsHandler
         result.clear();
         parent.getAttributes().remove("javax.faces.RetargetableHandlers");
     }
+    
+    /**
+     * updates objects such as events, validators, etc on dynamically created input components 
+     * @param parent the CompositeComponent parent
+     * @param context the faces context
+     * @param column the column for which to attach the objects (optional, i.e. may be null) 
+     * @param inputComponent the input component created by the InputControl implementation
+     */
+    public void updateAttachedObjects(UIComponent parent, FacesContext context, Column column, UIComponentBase inputComponent)
+    {
+        // Normally nothing to do
+    }
 
     /**
      * helper to get a tag attribute value

http://git-wip-us.apache.org/repos/asf/empire-db/blob/a812088b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java
----------------------------------------------------------------------
diff --git a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java
index f64dfa6..63cf2de 100644
--- a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java
+++ b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java
@@ -28,6 +28,7 @@ import javax.faces.component.UIComponent;
 import javax.faces.component.UIComponentBase;
 import javax.faces.component.UIData;
 import javax.faces.component.UIInput;
+import javax.faces.component.behavior.ClientBehaviorHolder;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 
@@ -196,7 +197,7 @@ public abstract class InputControl
                 if (resetChildId && child.getId()!=null)
                     child.setId(child.getId());
                 // check type
-                if (!(child instanceof UIComponentBase))
+                if (!(child instanceof ClientBehaviorHolder))
                     continue;
                 // add attached objects
                 addAttachedObjects(parent, context, ii, ((UIComponentBase)child));
@@ -232,6 +233,17 @@ public abstract class InputControl
         if (cl.isEmpty())
             return;
         updateInputState(cl, ii, context, setValue);
+        // update attached objects
+        List<UIComponent> children = parent.getChildren();
+        while (!(parent instanceof UIInput))
+            parent = parent.getParent();
+        for (UIComponent child : children)
+        {   // check type
+            if (!(child instanceof ClientBehaviorHolder))
+                continue;
+            // update attached objects
+            updateAttachedObjects(parent, context, ii, ((UIComponentBase)child));
+        }
     }
     
     public void postUpdateModel(UIComponent comp, InputInfo ii, FacesContext fc)
@@ -320,6 +332,13 @@ public abstract class InputControl
             aoh.addAttachedObjects(parent, context, ii.getColumn(), inputComponent);
     }
     
+    protected void updateAttachedObjects(UIComponent parent, FacesContext context, InputInfo ii, UIComponentBase inputComponent)
+    {
+        InputAttachedObjectsHandler aoh = InputControlManager.getAttachedObjectsHandler();
+        if (aoh!=null)
+            aoh.updateAttachedObjects(parent, context, ii.getColumn(), inputComponent);
+    }
+    
     protected UIInput getFirstInput(List<UIComponent> compList)
     {
         for (int i=0; i<compList.size(); i++)