Search in sources :

Example 1 with FacesEvent

use of javax.faces.event.FacesEvent in project gdmatrix by gdmatrix.

the class HtmlTreeMenu method broadcast.

@Override
public void broadcast(FacesEvent event) throws AbortProcessingException {
    if (event instanceof FacesEventWrapper) {
        MenuItemCursor cursor = getCurrentMenuItem();
        setMenuItemVar(((FacesEventWrapper) event).getMenuItem());
        try {
            FacesEvent originalEvent = ((FacesEventWrapper) event).getWrappedFacesEvent();
            originalEvent.getComponent().broadcast(originalEvent);
        } finally {
            setMenuItemVar(cursor);
        }
    } else {
        super.broadcast(event);
    }
}
Also used : MenuItemCursor(org.santfeliu.faces.menu.model.MenuItemCursor) FacesEvent(javax.faces.event.FacesEvent)

Example 2 with FacesEvent

use of javax.faces.event.FacesEvent in project acs-community-packaging by Alfresco.

the class UISelectList method broadcast.

/**
 * Override event broadcasting to look for event wrappers to set the current row context
 * correctly for components that have been rendered multiple times in the list.
 */
@Override
public void broadcast(FacesEvent event) throws AbortProcessingException {
    if (event instanceof FacesEventWrapper) {
        FacesEvent originalEvent = ((FacesEventWrapper) event).getWrappedFacesEvent();
        int eventRowIndex = ((FacesEventWrapper) event).getRowIndex();
        int currentRowIndex = getRowIndex();
        setRowIndex(eventRowIndex);
        try {
            originalEvent.getComponent().broadcast(originalEvent);
        } finally {
            setRowIndex(currentRowIndex);
        }
    } else {
        super.broadcast(event);
    }
}
Also used : FacesEvent(javax.faces.event.FacesEvent)

Example 3 with FacesEvent

use of javax.faces.event.FacesEvent in project primefaces by primefaces.

the class CascadeSelect method queueEvent.

@Override
public void queueEvent(FacesEvent event) {
    FacesContext context = getFacesContext();
    if (ComponentUtils.isRequestSource(this, context) && event instanceof AjaxBehaviorEvent) {
        Map<String, String> params = context.getExternalContext().getRequestParameterMap();
        String eventName = params.get(Constants.RequestParams.PARTIAL_BEHAVIOR_EVENT_PARAM);
        FacesEvent wrapperEvent = null;
        AjaxBehaviorEvent behaviorEvent = (AjaxBehaviorEvent) event;
        if ("itemSelect".equals(eventName)) {
            Renderer renderer = ComponentUtils.getUnwrappedRenderer(context, "javax.faces.SelectOne", "javax.faces.Listbox");
            Object item = renderer.getConvertedValue(context, this, getSubmittedValue());
            wrapperEvent = new SelectEvent(this, behaviorEvent.getBehavior(), item);
            wrapperEvent.setPhaseId(behaviorEvent.getPhaseId());
        }
        super.queueEvent(wrapperEvent);
    } else {
        super.queueEvent(event);
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) Renderer(javax.faces.render.Renderer) AjaxBehaviorEvent(javax.faces.event.AjaxBehaviorEvent) FacesEvent(javax.faces.event.FacesEvent) SelectEvent(org.primefaces.event.SelectEvent)

Example 4 with FacesEvent

use of javax.faces.event.FacesEvent in project primefaces by primefaces.

the class PickList method validate.

@Override
public void validate(FacesContext context) {
    super.validate(context);
    if (isValid() && customEvents != null) {
        for (Map.Entry<String, AjaxBehaviorEvent> event : customEvents.entrySet()) {
            String eventName = event.getKey();
            AjaxBehaviorEvent behaviorEvent = event.getValue();
            Map<String, String> params = context.getExternalContext().getRequestParameterMap();
            String clientId = getClientId(context);
            DualListModel<?> list = (DualListModel<?>) getValue();
            FacesEvent wrapperEvent = null;
            if ("select".equals(eventName)) {
                String listName = params.get(clientId + "_listName");
                int itemIndex = Integer.parseInt(params.get(clientId + "_itemIndex"));
                if ("target".equals(listName)) {
                    wrapperEvent = new SelectEvent(this, behaviorEvent.getBehavior(), list.getTarget().get(itemIndex));
                } else {
                    wrapperEvent = new SelectEvent(this, behaviorEvent.getBehavior(), list.getSource().get(itemIndex));
                }
            } else if ("unselect".equals(eventName)) {
                String listName = params.get(clientId + "_listName");
                int itemIndex = Integer.parseInt(params.get(clientId + "_itemIndex"));
                if ("target".equals(listName)) {
                    wrapperEvent = new UnselectEvent(this, behaviorEvent.getBehavior(), list.getTarget().get(itemIndex));
                } else {
                    wrapperEvent = new UnselectEvent(this, behaviorEvent.getBehavior(), list.getSource().get(itemIndex));
                }
            } else if ("reorder".equals(eventName)) {
                wrapperEvent = behaviorEvent;
            }
            if (wrapperEvent == null) {
                throw new FacesException("Component " + this.getClass().getName() + " does not support event " + eventName + "!");
            }
            wrapperEvent.setPhaseId(behaviorEvent.getPhaseId());
            super.queueEvent(wrapperEvent);
        }
    }
}
Also used : DualListModel(org.primefaces.model.DualListModel) UnselectEvent(org.primefaces.event.UnselectEvent) AjaxBehaviorEvent(javax.faces.event.AjaxBehaviorEvent) FacesEvent(javax.faces.event.FacesEvent) SelectEvent(org.primefaces.event.SelectEvent) FacesException(javax.faces.FacesException)

Example 5 with FacesEvent

use of javax.faces.event.FacesEvent in project primefaces by primefaces.

the class OrderList method validate.

@Override
public void validate(FacesContext context) {
    super.validate(context);
    if (isValid() && customEvents != null) {
        for (Map.Entry<String, AjaxBehaviorEvent> event : customEvents.entrySet()) {
            String eventName = event.getKey();
            AjaxBehaviorEvent behaviorEvent = event.getValue();
            Map<String, String> params = context.getExternalContext().getRequestParameterMap();
            String clientId = getClientId(context);
            List<?> list = (List) getValue();
            FacesEvent wrapperEvent = null;
            if ("select".equals(eventName)) {
                int itemIndex = Integer.parseInt(params.get(clientId + "_itemIndex"));
                boolean metaKey = Boolean.parseBoolean(params.get(clientId + "_metaKey"));
                boolean ctrlKey = Boolean.parseBoolean(params.get(clientId + "_ctrlKey"));
                wrapperEvent = new SelectEvent(this, behaviorEvent.getBehavior(), list.get(itemIndex), metaKey, ctrlKey);
            } else if ("unselect".equals(eventName)) {
                int itemIndex = Integer.parseInt(params.get(clientId + "_itemIndex"));
                wrapperEvent = new UnselectEvent(this, behaviorEvent.getBehavior(), list.get(itemIndex));
            } else if ("reorder".equals(eventName)) {
                wrapperEvent = behaviorEvent;
            }
            if (wrapperEvent == null) {
                throw new FacesException("Component " + this.getClass().getName() + " does not support event " + eventName + "!");
            }
            wrapperEvent.setPhaseId(behaviorEvent.getPhaseId());
            super.queueEvent(wrapperEvent);
        }
    }
}
Also used : UnselectEvent(org.primefaces.event.UnselectEvent) AjaxBehaviorEvent(javax.faces.event.AjaxBehaviorEvent) FacesEvent(javax.faces.event.FacesEvent) SelectEvent(org.primefaces.event.SelectEvent) FacesException(javax.faces.FacesException)

Aggregations

FacesEvent (javax.faces.event.FacesEvent)11 AjaxBehaviorEvent (javax.faces.event.AjaxBehaviorEvent)9 FacesException (javax.faces.FacesException)7 FacesContext (javax.faces.context.FacesContext)7 SelectEvent (org.primefaces.event.SelectEvent)4 UnselectEvent (org.primefaces.event.UnselectEvent)2 LocalDateTime (java.time.LocalDateTime)1 ZoneId (java.time.ZoneId)1 Renderer (javax.faces.render.Renderer)1 UIColumn (org.primefaces.component.api.UIColumn)1 PageEvent (org.primefaces.event.data.PageEvent)1 SortEvent (org.primefaces.event.data.SortEvent)1 ConnectEvent (org.primefaces.event.diagram.ConnectEvent)1 ConnectionChangeEvent (org.primefaces.event.diagram.ConnectionChangeEvent)1 DisconnectEvent (org.primefaces.event.diagram.DisconnectEvent)1 PositionChangeEvent (org.primefaces.event.diagram.PositionChangeEvent)1 OrganigramNodeCollapseEvent (org.primefaces.event.organigram.OrganigramNodeCollapseEvent)1 OrganigramNodeDragDropEvent (org.primefaces.event.organigram.OrganigramNodeDragDropEvent)1 OrganigramNodeExpandEvent (org.primefaces.event.organigram.OrganigramNodeExpandEvent)1 OrganigramNodeSelectEvent (org.primefaces.event.organigram.OrganigramNodeSelectEvent)1