Search in sources :

Example 1 with ConfirmBehavior

use of org.primefaces.behavior.confirm.ConfirmBehavior in project primefaces by primefaces.

the class MenuItemAwareRenderer method setConfirmationScript.

protected void setConfirmationScript(FacesContext context, MenuItem item) {
    if (item instanceof ClientBehaviorHolder) {
        Map<String, List<ClientBehavior>> behaviors = ((ClientBehaviorHolder) item).getClientBehaviors();
        List<ClientBehavior> clickBehaviors = (behaviors == null) ? null : behaviors.get("click");
        if (clickBehaviors != null && !clickBehaviors.isEmpty()) {
            for (int i = 0; i < clickBehaviors.size(); i++) {
                ClientBehavior clientBehavior = clickBehaviors.get(i);
                if (clientBehavior instanceof ConfirmBehavior) {
                    ClientBehaviorContext cbc = ClientBehaviorContext.createClientBehaviorContext(context, (UIComponent) item, "click", item.getClientId(), Collections.emptyList());
                    clientBehavior.getScript(cbc);
                    break;
                }
            }
        }
    }
}
Also used : ClientBehaviorHolder(javax.faces.component.behavior.ClientBehaviorHolder) ConfirmBehavior(org.primefaces.behavior.confirm.ConfirmBehavior) ClientBehavior(javax.faces.component.behavior.ClientBehavior) ClientBehaviorContext(javax.faces.component.behavior.ClientBehaviorContext)

Aggregations

ClientBehavior (javax.faces.component.behavior.ClientBehavior)1 ClientBehaviorContext (javax.faces.component.behavior.ClientBehaviorContext)1 ClientBehaviorHolder (javax.faces.component.behavior.ClientBehaviorHolder)1 ConfirmBehavior (org.primefaces.behavior.confirm.ConfirmBehavior)1