use of jakarta.faces.event.ValueChangeListener in project myfaces by apache.
the class ValueChangeListenerHandler method applyAttachedObject.
@Override
public void applyAttachedObject(FacesContext context, UIComponent parent) {
// Retrieve the current FaceletContext from FacesContext object
FaceletContext faceletContext = (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
EditableValueHolder evh = (EditableValueHolder) parent;
ValueExpression b = null;
if (this.binding != null) {
b = this.binding.getValueExpression(faceletContext, ValueChangeListener.class);
}
ValueChangeListener listener = new LazyValueChangeListener(this.listenerType, b);
evh.addValueChangeListener(listener);
}
use of jakarta.faces.event.ValueChangeListener in project myfaces by apache.
the class FaceletViewDeclarationLanguage method applyValueChangeListenerMethodExpressionTarget.
private void applyValueChangeListenerMethodExpressionTarget(FacesContext context, FaceletCompositionContext mctx, ELContext elContext, UIComponent topLevelComponent, UIComponent innerComponent, String attributeName, String targetAttributeName, String attributeExpressionString, ValueExpression attributeNameValueExpression, boolean ccAttrMeRedirection) {
ValueChangeListener o = (ValueChangeListener) mctx.removeMethodExpressionTargeted(innerComponent, targetAttributeName);
if (o != null) {
((EditableValueHolder) innerComponent).removeValueChangeListener(o);
}
// target is EditableValueHolder
ValueChangeListener valueChangeListener = null;
// If it is a redirection, a wrapper is used to locate the right instance and call it properly.
if (ccAttrMeRedirection) {
valueChangeListener = new RedirectMethodExpressionValueExpressionValueChangeListener(attributeNameValueExpression);
} else {
MethodExpression methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().createMethodExpression(elContext, attributeExpressionString, Void.TYPE, VALUE_CHANGE_LISTENER_SIGNATURE), attributeNameValueExpression);
MethodExpression methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().createMethodExpression(elContext, attributeExpressionString, Void.TYPE, EMPTY_CLASS_ARRAY), attributeNameValueExpression);
if (mctx.isUsingPSSOnThisView()) {
valueChangeListener = new PartialMethodExpressionValueChangeListener(methodExpression, methodExpression2);
} else {
valueChangeListener = new MethodExpressionValueChangeListener(methodExpression, methodExpression2);
}
}
((EditableValueHolder) innerComponent).addValueChangeListener(valueChangeListener);
mctx.addMethodExpressionTargeted(innerComponent, targetAttributeName, valueChangeListener);
}
use of jakarta.faces.event.ValueChangeListener in project mojarra by eclipse-ee4j.
the class ValueChangeListenerHandler method applyAttachedObject.
@Override
public void applyAttachedObject(FacesContext context, UIComponent parent) {
FaceletContext ctx = (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
EditableValueHolder evh = (EditableValueHolder) parent;
ValueExpression b = null;
if (binding != null) {
b = binding.getValueExpression(ctx, ValueChangeListener.class);
}
ValueChangeListener listener = new LazyValueChangeListener(listenerType, b);
evh.addValueChangeListener(listener);
}
use of jakarta.faces.event.ValueChangeListener in project mojarra by eclipse-ee4j.
the class UIComponentBaseAttachedStateTestCase method testAttachedObjectsMap.
public void testAttachedObjectsMap() throws Exception {
Map<String, ValueChangeListener> returnedAttachedObjects = null, attachedObjects = new HashMap<>();
ValueChangeListener toAdd = new ValueChangeListenerTestImpl();
attachedObjects.put("one", toAdd);
toAdd = new ValueChangeListenerTestImpl();
attachedObjects.put("two", toAdd);
toAdd = new ValueChangeListenerTestImpl();
attachedObjects.put("three", toAdd);
Object result = UIComponentBase.saveAttachedState(facesContext, attachedObjects);
returnedAttachedObjects = (Map<String, ValueChangeListener>) UIComponentBase.restoreAttachedState(facesContext, result);
}
use of jakarta.faces.event.ValueChangeListener in project mojarra by eclipse-ee4j.
the class UIComponentBaseAttachedStateTestCase method testAttachedObjectsStack.
public void testAttachedObjectsStack() throws Exception {
Stack<ValueChangeListener> returnedAttachedObjects = null, attachedObjects = new Stack<>();
ValueChangeListener toAdd = new ValueChangeListenerTestImpl();
attachedObjects.add(toAdd);
toAdd = new ValueChangeListenerTestImpl();
attachedObjects.add(toAdd);
toAdd = new ValueChangeListenerTestImpl();
attachedObjects.add(toAdd);
Object result = UIComponentBase.saveAttachedState(facesContext, attachedObjects);
returnedAttachedObjects = (Stack<ValueChangeListener>) UIComponentBase.restoreAttachedState(facesContext, result);
}
Aggregations