EMPIREDB-235
allow client behavior updates
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 @@
// attach objects
addAttachedObjects(context, inputComponent);
}
+ else
+ { // update attached objects
+ updateAttachedObjects(context, inputComponent);
+ }
// render components
inputComponent.encodeAll(context);
// default
@@ -274,4 +278,11 @@
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);
+ }
}
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 @@
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
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.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 @@
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 @@
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 @@
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++)