Search in sources :

Example 6 with ClientBehaviorHolder

use of javax.faces.component.behavior.ClientBehaviorHolder in project empire-db by apache.

the class InputControl method createInput.

/* createInput */
public void createInput(UIComponent comp, InputInfo ii, FacesContext context) {
    // createInputComponents
    List<UIComponent> children = comp.getChildren();
    try {
        this.creatingComponents = true;
        createInputComponents(comp, ii, context, children);
        // check
        boolean resetChildId = ii.isInsideUIData();
        if (resetChildId && log.isDebugEnabled()) {
            // Debug-Info only
            UIComponent c1 = comp.getChildren().get(0);
            String clientId = c1.getClientId();
            log.debug("Performing ChildId-reset for {}", clientId);
        }
        // add attached objects
        UIComponent parent = comp;
        while (!(parent instanceof UIInput)) parent = parent.getParent();
        for (UIComponent child : children) {
            // reset child-id
            if (resetChildId && child.getId() != null)
                child.setId(child.getId());
            // check type
            if (!(child instanceof ClientBehaviorHolder))
                continue;
            // add attached objects
            addAttachedObjects(parent, context, ii, ((UIComponentBase) child));
        }
    } finally {
        this.creatingComponents = false;
    }
}
Also used : UIComponent(javax.faces.component.UIComponent) ClientBehaviorHolder(javax.faces.component.behavior.ClientBehaviorHolder) UIInput(javax.faces.component.UIInput) UIComponentBase(javax.faces.component.UIComponentBase)

Example 7 with ClientBehaviorHolder

use of javax.faces.component.behavior.ClientBehaviorHolder in project empire-db by apache.

the class InputControl method updateInputState.

public void updateInputState(UIComponent parent, InputInfo ii, FacesContext context, PhaseId phaseId) {
    List<UIComponent> cl = parent.getChildren();
    if (cl.isEmpty())
        return;
    updateInputState(cl, ii, context, phaseId);
    // 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));
    }
}
Also used : UIComponent(javax.faces.component.UIComponent) ClientBehaviorHolder(javax.faces.component.behavior.ClientBehaviorHolder) UIInput(javax.faces.component.UIInput) UIComponentBase(javax.faces.component.UIComponentBase)

Example 8 with ClientBehaviorHolder

use of javax.faces.component.behavior.ClientBehaviorHolder in project primefaces by primefaces.

the class ComponentUtils method decodeBehaviors.

public static void decodeBehaviors(FacesContext context, UIComponent component) {
    if (!(component instanceof ClientBehaviorHolder)) {
        return;
    }
    Map<String, List<ClientBehavior>> behaviors = ((ClientBehaviorHolder) component).getClientBehaviors();
    if (behaviors.isEmpty()) {
        return;
    }
    Map<String, String> params = context.getExternalContext().getRequestParameterMap();
    String behaviorEvent = params.get(Constants.RequestParams.PARTIAL_BEHAVIOR_EVENT_PARAM);
    if (null != behaviorEvent) {
        List<ClientBehavior> behaviorsForEvent = behaviors.get(behaviorEvent);
        if (behaviorsForEvent != null && !behaviorsForEvent.isEmpty()) {
            String behaviorSource = params.get(Constants.RequestParams.PARTIAL_SOURCE_PARAM);
            String clientId = component.getClientId(context);
            if (behaviorSource != null && clientId.equals(behaviorSource)) {
                for (ClientBehavior behavior : behaviorsForEvent) {
                    behavior.decode(context, component);
                }
            }
        }
    }
}
Also used : ClientBehaviorHolder(javax.faces.component.behavior.ClientBehaviorHolder) ClientBehavior(javax.faces.component.behavior.ClientBehavior)

Aggregations

ClientBehaviorHolder (javax.faces.component.behavior.ClientBehaviorHolder)8 ClientBehavior (javax.faces.component.behavior.ClientBehavior)4 List (java.util.List)2 UIComponent (javax.faces.component.UIComponent)2 UIComponentBase (javax.faces.component.UIComponentBase)2 UIInput (javax.faces.component.UIInput)2 ClientBehaviorContext (javax.faces.component.behavior.ClientBehaviorContext)2 BeanDescriptor (java.beans.BeanDescriptor)1 BeanInfo (java.beans.BeanInfo)1 ArrayList (java.util.ArrayList)1 Application (javax.faces.application.Application)1 FacesContext (javax.faces.context.FacesContext)1 AttachedObjectTarget (javax.faces.view.AttachedObjectTarget)1 BehaviorHolderAttachedObjectTarget (javax.faces.view.BehaviorHolderAttachedObjectTarget)1 ConfirmBehavior (org.primefaces.behavior.confirm.ConfirmBehavior)1 MixedClientBehaviorHolder (org.primefaces.component.api.MixedClientBehaviorHolder)1 PrimeEnvironment (org.primefaces.config.PrimeEnvironment)1