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);
}
}
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);
}
}
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);
}
}
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);
}
}
}
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);
}
}
}
Aggregations