use of org.primefaces.event.UnselectEvent in project primefaces by primefaces.
the class Chips method queueEvent.
@Override
public void queueEvent(FacesEvent event) {
FacesContext context = getFacesContext();
Map<String, String> params = context.getExternalContext().getRequestParameterMap();
String eventName = params.get(Constants.RequestParams.PARTIAL_BEHAVIOR_EVENT_PARAM);
if (eventName != null && event instanceof AjaxBehaviorEvent) {
AjaxBehaviorEvent ajaxBehaviorEvent = (AjaxBehaviorEvent) event;
if ("itemSelect".equals(eventName)) {
Object selectedItemValue = ComponentUtils.getConvertedValue(context, this, params.get(getClientId(context) + "_itemSelect"));
SelectEvent selectEvent = new SelectEvent(this, ajaxBehaviorEvent.getBehavior(), selectedItemValue);
selectEvent.setPhaseId(ajaxBehaviorEvent.getPhaseId());
super.queueEvent(selectEvent);
} else if ("itemUnselect".equals(eventName)) {
Object unselectedItemValue = ComponentUtils.getConvertedValue(context, this, params.get(getClientId(context) + "_itemUnselect"));
UnselectEvent unselectEvent = new UnselectEvent(this, ajaxBehaviorEvent.getBehavior(), unselectedItemValue);
unselectEvent.setPhaseId(ajaxBehaviorEvent.getPhaseId());
super.queueEvent(unselectEvent);
} else {
// e.g. blur, focus, change
super.queueEvent(event);
}
} else {
// e.g. valueChange
super.queueEvent(event);
}
}
use of org.primefaces.event.UnselectEvent in project primefaces by primefaces.
the class AutoComplete method queueEvent.
@Override
public void queueEvent(FacesEvent event) {
FacesContext context = getFacesContext();
Map<String, String> params = context.getExternalContext().getRequestParameterMap();
String eventName = params.get(Constants.RequestParams.PARTIAL_BEHAVIOR_EVENT_PARAM);
if (eventName != null && event instanceof AjaxBehaviorEvent) {
AjaxBehaviorEvent ajaxBehaviorEvent = (AjaxBehaviorEvent) event;
if ("itemSelect".equals(eventName)) {
Object selectedItemValue = ComponentUtils.getConvertedValue(context, this, params.get(getClientId(context) + "_itemSelect"));
SelectEvent selectEvent = new SelectEvent(this, ajaxBehaviorEvent.getBehavior(), selectedItemValue);
selectEvent.setPhaseId(ajaxBehaviorEvent.getPhaseId());
super.queueEvent(selectEvent);
} else if ("itemUnselect".equals(eventName)) {
Object unselectedItemValue = ComponentUtils.getConvertedValue(context, this, params.get(getClientId(context) + "_itemUnselect"));
UnselectEvent unselectEvent = new UnselectEvent(this, ajaxBehaviorEvent.getBehavior(), unselectedItemValue);
unselectEvent.setPhaseId(ajaxBehaviorEvent.getPhaseId());
super.queueEvent(unselectEvent);
} else if ("moreTextSelect".equals(eventName) || "emptyMessageSelect".equals(eventName) || "clear".equals(eventName)) {
ajaxBehaviorEvent.setPhaseId(event.getPhaseId());
super.queueEvent(ajaxBehaviorEvent);
} else {
// e.g. blur, focus, change
super.queueEvent(event);
}
} else {
// e.g. valueChange, autoCompleteEvent
super.queueEvent(event);
}
}
use of org.primefaces.event.UnselectEvent 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 org.primefaces.event.UnselectEvent 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);
}
}
}
use of org.primefaces.event.UnselectEvent in project primefaces by primefaces.
the class SelectCheckboxMenu method queueEvent.
@Override
public void queueEvent(FacesEvent event) {
FacesContext context = getFacesContext();
Map<String, String> params = context.getExternalContext().getRequestParameterMap();
String eventName = params.get(Constants.RequestParams.PARTIAL_BEHAVIOR_EVENT_PARAM);
if (eventName != null && event instanceof AjaxBehaviorEvent) {
AjaxBehaviorEvent ajaxBehaviorEvent = (AjaxBehaviorEvent) event;
if ("toggleSelect".equals(eventName)) {
String clientId = getClientId(context);
boolean checked = Boolean.parseBoolean(params.get(clientId + "_checked"));
ToggleSelectEvent toggleSelectEvent = new ToggleSelectEvent(this, ((AjaxBehaviorEvent) event).getBehavior(), checked);
toggleSelectEvent.setPhaseId(event.getPhaseId());
super.queueEvent(toggleSelectEvent);
} else if ("itemUnselect".equals(eventName)) {
Object unselectedItemValue = ComponentUtils.getConvertedValue(context, this, params.get(getClientId(context) + "_itemUnselect"));
UnselectEvent unselectEvent = new UnselectEvent(this, ajaxBehaviorEvent.getBehavior(), unselectedItemValue);
unselectEvent.setPhaseId(ajaxBehaviorEvent.getPhaseId());
super.queueEvent(unselectEvent);
} else {
super.queueEvent(event);
}
} else {
super.queueEvent(event);
}
}
Aggregations