use of javax.faces.event.AjaxBehaviorEvent in project liferay-faces-alloy by liferay.
the class Accordion method queueEvent.
@Override
public void queueEvent(FacesEvent facesEvent) {
// behavior event, then
if (facesEvent instanceof AjaxBehaviorEvent) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
Map<String, String> requestParameterMap = externalContext.getRequestParameterMap();
String eventName = requestParameterMap.get("javax.faces.behavior.event");
// If the AjaxBehaviorEvent indicates a tab being collapsed/expanded, then
if (TabCollapseEvent.TAB_COLLAPSE.equals(eventName) || TabExpandEvent.TAB_EXPAND.equals(eventName)) {
// Determine the client-side state of the selected tab index.
String clientId = getClientId(facesContext);
int index;
if (TabCollapseEvent.TAB_COLLAPSE.equals(eventName)) {
index = IntegerHelper.toInteger(requestParameterMap.get(clientId + "collapsedTabIndex"));
} else {
index = IntegerHelper.toInteger(requestParameterMap.get(clientId + "selectedIndex"));
}
// If iterating over a data model, then determine the row data and tab associated with the data model
// iteration.
Object rowData = null;
Tab tab = null;
String var = getVar();
if (var != null) {
setRowIndex(index);
rowData = getRowData();
tab = TabUtil.getFirstChildTab(this);
setRowIndex(-1);
} else // Otherwise, determine the tab associated with the client-side state of the selected tab index.
{
List<Tab> childTabs = TabUtil.getChildTabs(this);
if (childTabs.size() >= (index + 1)) {
tab = childTabs.get(index);
}
}
// Queue a tab collapse/expand event rather than the specified faces event.
AjaxBehaviorEvent behaviorEvent = (AjaxBehaviorEvent) facesEvent;
Behavior behavior = behaviorEvent.getBehavior();
if (TabCollapseEvent.TAB_COLLAPSE.equals(eventName)) {
facesEvent = new TabCollapseEvent(this, behavior, tab, rowData);
} else {
facesEvent = new TabExpandEvent(this, behavior, tab, rowData);
}
}
}
super.queueEvent(facesEvent);
}
use of javax.faces.event.AjaxBehaviorEvent in project primefaces by primefaces.
the class AjaxBehaviorRenderer method decode.
@Override
public void decode(FacesContext context, UIComponent component, ClientBehavior behavior) {
AjaxBehavior ajaxBehavior = (AjaxBehavior) behavior;
if (!ajaxBehavior.isDisabled()) {
AjaxBehaviorEvent event = new AjaxBehaviorEvent(component, behavior);
PhaseId phaseId = isImmediate(component, ajaxBehavior) ? PhaseId.APPLY_REQUEST_VALUES : PhaseId.INVOKE_APPLICATION;
event.setPhaseId(phaseId);
component.queueEvent(event);
}
}
use of javax.faces.event.AjaxBehaviorEvent in project primefaces by primefaces.
the class AccordionPanel 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);
String clientId = getClientId(context);
boolean repeating = isRepeating();
AjaxBehaviorEvent behaviorEvent = (AjaxBehaviorEvent) event;
if ("tabChange".equals(eventName)) {
String tabClientId = params.get(clientId + "_newTab");
TabChangeEvent changeEvent = new TabChangeEvent(this, behaviorEvent.getBehavior(), findTab(tabClientId));
if (repeating) {
int index = Integer.parseInt(params.get(clientId + "_tabindex"));
setIndex(index);
changeEvent.setData(getIndexData());
changeEvent.setTab(getDynamicTab());
}
changeEvent.setPhaseId(behaviorEvent.getPhaseId());
super.queueEvent(changeEvent);
if (repeating) {
setIndex(-1);
}
} else if ("tabClose".equals(eventName)) {
String tabClientId = params.get(clientId + "_tabId");
TabCloseEvent closeEvent = new TabCloseEvent(this, behaviorEvent.getBehavior(), findTab(tabClientId));
if (repeating) {
int index = Integer.parseInt(params.get(clientId + "_tabindex"));
setIndex(index);
closeEvent.setData(getIndexData());
closeEvent.setTab(getDynamicTab());
}
closeEvent.setPhaseId(behaviorEvent.getPhaseId());
super.queueEvent(closeEvent);
if (repeating) {
setIndex(-1);
}
}
} else {
super.queueEvent(event);
}
}
use of javax.faces.event.AjaxBehaviorEvent in project primefaces by primefaces.
the class DialogReturnAware method queueDialogReturnEvent.
default void queueDialogReturnEvent(FacesEvent event, FacesContext context, UIComponent source, Consumer<FacesEvent> queueEvent) {
Map<String, String> params = context.getExternalContext().getRequestParameterMap();
AjaxBehaviorEvent behaviorEvent = (AjaxBehaviorEvent) event;
Map<String, Object> session = context.getExternalContext().getSessionMap();
String dcid = params.get(source.getClientId(context) + "_pfdlgcid");
Object selectedValue = session.get(dcid);
session.remove(dcid);
queueEvent.accept(new SelectEvent(source, behaviorEvent.getBehavior(), selectedValue));
}
use of javax.faces.event.AjaxBehaviorEvent in project primefaces by primefaces.
the class InputTextarea 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)) {
String selectedItemValue = params.get(getClientId(context) + "_itemSelect");
SelectEvent selectEvent = new SelectEvent(this, ajaxBehaviorEvent.getBehavior(), selectedItemValue);
selectEvent.setPhaseId(ajaxBehaviorEvent.getPhaseId());
super.queueEvent(selectEvent);
} else {
// e.g. blur, focus, change
super.queueEvent(event);
}
} else {
// e.g. valueChange, autoCompleteEvent
super.queueEvent(event);
}
}
Aggregations