use of jakarta.faces.event.ActionListener in project myfaces by apache.
the class UIViewAction method broadcast.
@Override
public void broadcast(FacesEvent event) throws AbortProcessingException {
super.broadcast(event);
FacesContext context = getFacesContext();
if (context.getResponseComplete()) {
return;
}
UIComponent c = event.getComponent();
UIViewRoot sourceViewRoot = null;
do {
if (c instanceof UIViewRoot) {
sourceViewRoot = (UIViewRoot) c;
break;
} else {
c = c.getParent();
}
} while (c != null);
if (!context.getViewRoot().equals(sourceViewRoot)) {
return;
}
if (event instanceof ActionEvent) {
ActionListener defaultActionListener = context.getApplication().getActionListener();
if (defaultActionListener != null) {
String viewIdBeforeAction = context.getViewRoot().getViewId();
Boolean oldBroadcastProcessing = (Boolean) context.getAttributes().get(BROADCAST_PROCESSING_KEY);
try {
context.getAttributes().put(BROADCAST_PROCESSING_KEY, Boolean.TRUE);
ViewActionFacesContextWrapper wrappedFacesContext = new ViewActionFacesContextWrapper(context);
try {
wrappedFacesContext.setWrapperAsCurrentFacesContext();
if (event instanceof ViewActionEvent) {
((ViewActionEvent) event).setFacesContext(wrappedFacesContext);
}
defaultActionListener.processAction((ActionEvent) event);
// Decrement count
Integer count = (Integer) context.getAttributes().get(EVENT_COUNT_KEY);
count = (count == null) ? 0 : count - 1;
context.getAttributes().put(EVENT_COUNT_KEY, count);
} finally {
wrappedFacesContext.restoreCurrentFacesContext();
}
} finally {
context.getAttributes().put(BROADCAST_PROCESSING_KEY, oldBroadcastProcessing == null ? Boolean.FALSE : oldBroadcastProcessing);
}
if (context.getResponseComplete()) {
return;
} else {
Integer count = (Integer) context.getAttributes().get(EVENT_COUNT_KEY);
count = (count == null) ? 0 : count;
String viewIdAfterAction = context.getViewRoot().getViewId();
if (viewIdBeforeAction.equals(viewIdAfterAction) && count == 0) {
context.renderResponse();
}
// "... Otherwise, execute the lifecycle on the new UIViewRoot ..."
// Note these words are implemented in the NavigationHandler, but
// the original proposal from seam s:viewAction did a trick here
// to restart the JSF lifecycle.
}
}
}
}
use of jakarta.faces.event.ActionListener in project myfaces by apache.
the class UICommand method broadcast.
@Override
public void broadcast(FacesEvent event) throws AbortProcessingException {
super.broadcast(event);
if (event instanceof ActionEvent) {
FacesContext context = getFacesContext();
ActionListener defaultActionListener = context.getApplication().getActionListener();
if (defaultActionListener != null) {
defaultActionListener.processAction((ActionEvent) event);
}
}
}
use of jakarta.faces.event.ActionListener in project myfaces by apache.
the class ActionListenerHandler method applyAttachedObject.
@Override
public void applyAttachedObject(FacesContext context, UIComponent parent) {
// Retrieve the current FaceletContext from FacesContext object
FaceletContext faceletContext = (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
ActionSource as = (ActionSource) parent;
ValueExpression b = null;
if (this.binding != null) {
b = this.binding.getValueExpression(faceletContext, ActionListener.class);
}
ActionListener listener = new LazyActionListener(this.listenerType, b);
as.addActionListener(listener);
}
use of jakarta.faces.event.ActionListener in project mojarra by eclipse-ee4j.
the class ActionListenerHandler method applyAttachedObject.
@Override
public void applyAttachedObject(FacesContext context, UIComponent parent) {
FaceletContext ctx = (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
ActionSource as = (ActionSource) parent;
ValueExpression b = null;
if (binding != null) {
b = binding.getValueExpression(ctx, ActionListener.class);
}
ActionListener listener = new LazyActionListener(listenerType, b);
as.addActionListener(listener);
}
use of jakarta.faces.event.ActionListener in project mojarra by eclipse-ee4j.
the class ResetValuesHandler method applyAttachedObject.
@Override
public void applyAttachedObject(FacesContext context, UIComponent parent) {
FaceletContext ctx = (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
ActionSource as = (ActionSource) parent;
String renderStr = (String) render.getObject(ctx, String.class);
ActionListener listener = new LazyActionListener(toList(renderStr));
as.addActionListener(listener);
}
Aggregations