Search in sources :

Example 1 with ActionSource

use of jakarta.faces.component.ActionSource in project myfaces by apache.

the class ActionListenerHandler 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);
    ActionSource as = (ActionSource) parent;
    ValueExpression b = null;
    if (this.binding != null) {
        b = this.binding.getValueExpression(faceletContext, ActionListener.class);
    }
    ActionListener listener = new LazyActionListener(this.listenerType, b);
    as.addActionListener(listener);
}
Also used : ActionListener(jakarta.faces.event.ActionListener) ValueExpression(jakarta.el.ValueExpression) FaceletContext(jakarta.faces.view.facelets.FaceletContext) ActionSource(jakarta.faces.component.ActionSource)

Example 2 with ActionSource

use of jakarta.faces.component.ActionSource in project mojarra by eclipse-ee4j.

the class SetPropertyActionListenerHandler method applyAttachedObject.

@Override
public void applyAttachedObject(FacesContext context, UIComponent parent) {
    FaceletContext faceletContext = (FaceletContext) context.getAttributes().get(FACELET_CONTEXT_KEY);
    ActionSource src = (ActionSource) parent;
    ValueExpression valueExpr = value.getValueExpression(faceletContext, Object.class);
    ValueExpression targetExpr = target.getValueExpression(faceletContext, Object.class);
    src.addActionListener(new SetPropertyListener(valueExpr, targetExpr));
}
Also used : ValueExpression(jakarta.el.ValueExpression) FaceletContext(jakarta.faces.view.facelets.FaceletContext) ActionSource(jakarta.faces.component.ActionSource)

Example 3 with ActionSource

use of jakarta.faces.component.ActionSource in project mojarra by eclipse-ee4j.

the class ActionListenerHandler method applyAttachedObject.

@Override
public void applyAttachedObject(FacesContext context, UIComponent parent) {
    FaceletContext ctx = (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
    ActionSource as = (ActionSource) parent;
    ValueExpression b = null;
    if (binding != null) {
        b = binding.getValueExpression(ctx, ActionListener.class);
    }
    ActionListener listener = new LazyActionListener(listenerType, b);
    as.addActionListener(listener);
}
Also used : ActionListener(jakarta.faces.event.ActionListener) ValueExpression(jakarta.el.ValueExpression) FaceletContext(jakarta.faces.view.facelets.FaceletContext) ActionSource(jakarta.faces.component.ActionSource)

Example 4 with ActionSource

use of jakarta.faces.component.ActionSource in project mojarra by eclipse-ee4j.

the class ResetValuesHandler method applyAttachedObject.

@Override
public void applyAttachedObject(FacesContext context, UIComponent parent) {
    FaceletContext ctx = (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
    ActionSource as = (ActionSource) parent;
    String renderStr = (String) render.getObject(ctx, String.class);
    ActionListener listener = new LazyActionListener(toList(renderStr));
    as.addActionListener(listener);
}
Also used : ActionListener(jakarta.faces.event.ActionListener) FaceletContext(jakarta.faces.view.facelets.FaceletContext) ActionSource(jakarta.faces.component.ActionSource)

Example 5 with ActionSource

use of jakarta.faces.component.ActionSource in project myfaces by apache.

the class ResetValuesActionListenerHandler method applyAttachedObject.

public void applyAttachedObject(FacesContext context, UIComponent parent, boolean checkForParentCC) {
    UIComponent topParentComponent = null;
    // Retrieve the current FaceletContext from FacesContext object
    FaceletContext faceletContext = (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
    if (checkForParentCC) {
        FaceletCompositionContext mctx = FaceletCompositionContext.getCurrentInstance(faceletContext);
        UIComponent parentComponent = parent;
        while (parentComponent != null) {
            if (UIComponent.isCompositeComponent(parentComponent)) {
                List<AttachedObjectHandler> handlerList = mctx.getAttachedObjectHandlers(parentComponent);
                if (handlerList != null && handlerList.contains(this)) {
                    // Found, but we need to go right to the top for it.
                    topParentComponent = parentComponent;
                }
            }
            parentComponent = parentComponent.getParent();
        }
    }
    ActionSource as = (ActionSource) parent;
    ActionListener listener = null;
    if (_render.isLiteral()) {
        listener = new LiteralResetValuesActionListener(_clientIds, topParentComponent != null ? (Location) topParentComponent.getAttributes().get(CompositeComponentELUtils.LOCATION_KEY) : null);
    } else {
        listener = new ResetValuesActionListener(_render.getValueExpression(faceletContext, Object.class), topParentComponent != null ? (Location) topParentComponent.getAttributes().get(CompositeComponentELUtils.LOCATION_KEY) : null);
    }
    as.addActionListener(listener);
}
Also used : FaceletCompositionContext(org.apache.myfaces.view.facelets.FaceletCompositionContext) ActionListener(jakarta.faces.event.ActionListener) UIComponent(jakarta.faces.component.UIComponent) FaceletContext(jakarta.faces.view.facelets.FaceletContext) ActionSource2AttachedObjectHandler(jakarta.faces.view.ActionSource2AttachedObjectHandler) AttachedObjectHandler(jakarta.faces.view.AttachedObjectHandler) ActionSource(jakarta.faces.component.ActionSource)

Aggregations

ActionSource (jakarta.faces.component.ActionSource)8 FaceletContext (jakarta.faces.view.facelets.FaceletContext)6 ValueExpression (jakarta.el.ValueExpression)5 ActionListener (jakarta.faces.event.ActionListener)4 ActionSource2 (jakarta.faces.component.ActionSource2)2 ExpressionFactory (jakarta.el.ExpressionFactory)1 MethodExpression (jakarta.el.MethodExpression)1 FacesException (jakarta.faces.FacesException)1 EditableValueHolder (jakarta.faces.component.EditableValueHolder)1 UIComponent (jakarta.faces.component.UIComponent)1 ValueHolder (jakarta.faces.component.ValueHolder)1 ClientBehaviorContext (jakarta.faces.component.behavior.ClientBehaviorContext)1 MethodExpressionActionListener (jakarta.faces.event.MethodExpressionActionListener)1 MethodExpressionValueChangeListener (jakarta.faces.event.MethodExpressionValueChangeListener)1 MethodExpressionValidator (jakarta.faces.validator.MethodExpressionValidator)1 ActionSource2AttachedObjectHandler (jakarta.faces.view.ActionSource2AttachedObjectHandler)1 AttachedObjectHandler (jakarta.faces.view.AttachedObjectHandler)1 TagException (jakarta.faces.view.facelets.TagException)1 Attributes (org.apache.myfaces.tobago.component.Attributes)1 Visual (org.apache.myfaces.tobago.component.Visual)1