protected String getRequestName(ActionEvent event) { final String actionName; if (event.getComponent() instanceof ActionSource2) { // actionSource est une UICommand en général final ActionSource2 actionSource = (ActionSource2) event.getComponent(); if (actionSource.getActionExpression() != null) { actionName = actionSource.getActionExpression().getExpressionString(); } else { actionName = actionSource.getClass().getName(); } } else { actionName = event.getComponent().getClass().getName(); } return actionName; } }
@Override public void applyMetadata(FaceletContext ctx, Object instance) { ((ActionSource2) instance).setActionExpression(this.attr .getMethodExpression(ctx, Object.class, ActionSourceRule.ACTION_SIG)); }
public void applyMetadata(FaceletContext ctx, Object instance) { ((ActionSource2) instance) .addActionListener(new MethodExpressionActionListener( this.attr.getMethodExpression(ctx, null, ActionSourceRule.ACTION_LISTENER_SIG))); }
attributeExpressionString, null, EMPTY_CLASS_ARRAY), attributeNameValueExpression); ((ActionSource2)innerComponent).setActionExpression(methodExpression); if (o != null) ((ActionSource2)innerComponent).removeActionListener(o); ((ActionSource2)innerComponent).addActionListener(actionListener); mctx.addMethodExpressionTargeted(innerComponent, targetAttributeName, actionListener);
if (o != null) ((ActionSource2) innerComponent).removeActionListener(o); ((ActionSource2) innerComponent).addActionListener(actionListener); mctx.addMethodExpressionTargeted(innerComponent, targetAttributeName, actionListener);
public void processAction(ActionEvent actionEvent) throws AbortProcessingException { if (!JsfUtils.isFlowRequest()) { this.delegate.processAction(actionEvent); return; } FacesContext context = FacesContext.getCurrentInstance(); ActionSource2 source = (ActionSource2) actionEvent.getSource(); String eventId = null; if (source.getActionExpression() != null) { if (logger.isDebugEnabled()) { logger.debug("Invoking action " + source.getActionExpression()); } eventId = (String) source.getActionExpression().invoke(context.getELContext(), null); } if (StringUtils.hasText(eventId)) { if (logger.isDebugEnabled()) { logger.debug("Event '" + eventId + "' detected"); } if (source.isImmediate() || validateModel(context, eventId)) { context.getExternalContext().getRequestMap().put(JsfView.EVENT_KEY, eventId); } } else { logger.debug("No action event detected"); context.getExternalContext().getRequestMap().remove(JsfView.EVENT_KEY); } // tells JSF lifecycle that rendering should now happen and any subsequent phases should be skipped // required in the case of this action listener firing immediately (immediate=true) before validation context.renderResponse(); }
/** * Returns a list of all action expressions and listeners associated with given component. This covers expressions * in <code>action</code> attribute of command components and <code>listener</code> attribute of ajax components. * Any method expressions are in format <code>#{bean.method}</code> and any action listeners are added as fully * qualified class names. This list is primarily useful for logging postback actions in a phase listener. You can * use {@link #getCurrentActionSource()} to obtain the current action source. * @param component The component to retrieve all action expressions and listeners from. * @return A list of all action expressions and listeners associated with given component. * @since 2.4 */ public static List<String> getActionExpressionsAndListeners(UIComponent component) { List<String> actions = new ArrayList<>(); if (component instanceof ActionSource2) { ActionSource2 source = (ActionSource2) component; addExpressionStringIfNotNull(source.getActionExpression(), actions); for (ActionListener actionListener : source.getActionListeners()) { actions.add(actionListener.getClass().getName()); } } if (component instanceof ClientBehaviorHolder) { String behaviorEvent = getRequestParameter(BEHAVIOR_EVENT_PARAM_NAME); if (behaviorEvent != null) { for (BehaviorListener listener : getBehaviorListeners((ClientBehaviorHolder) component, behaviorEvent)) { addExpressionStringIfNotNull(getField(listener.getClass(), MethodExpression.class, listener), actions); } } } return unmodifiableList(actions); }
public void applyMetadata(FaceletContext ctx, Object instance) { MethodExpression expr = _attr.getMethodExpression(ctx, null, ActionSourceRule.ACTION_SIG); ((ActionSource2) instance).setActionExpression(expr); } }
/** * @since 1.2 */ public static void addActionListenerProperty(FacesContext context, UIComponent component, MethodExpression actionListener) { if (actionListener != null) { if (!(component instanceof ActionSource2)) { throw new IllegalArgumentException("Component " + component.getClientId(context) + " is no ActionSource"); } ((ActionSource2)component).addActionListener(new MethodExpressionActionListener(actionListener)); } }
attributeExpressionString, null, EMPTY_CLASS_ARRAY), attributeNameValueExpression); ((ActionSource2)innerComponent).setActionExpression(methodExpression); if (o != null) ((ActionSource2)innerComponent).removeActionListener(o); ((ActionSource2)innerComponent).addActionListener(actionListener); mctx.addMethodExpressionTargeted(innerComponent, attributeName, actionListener);
public void processAction(ActionEvent actionEvent) throws AbortProcessingException { if (!JsfUtils.isFlowRequest()) { this.delegate.processAction(actionEvent); return; } FacesContext context = FacesContext.getCurrentInstance(); ActionSource2 source = (ActionSource2) actionEvent.getSource(); String eventId = null; if (source.getActionExpression() != null) { if (logger.isDebugEnabled()) { logger.debug("Invoking action " + source.getActionExpression()); } eventId = (String) source.getActionExpression().invoke(context.getELContext(), null); } if (StringUtils.hasText(eventId)) { if (logger.isDebugEnabled()) { logger.debug("Event '" + eventId + "' detected"); } if (source.isImmediate() || validateModel(context, eventId)) { context.getExternalContext().getRequestMap().put(JsfView.EVENT_KEY, eventId); } } else { logger.debug("No action event detected"); context.getExternalContext().getRequestMap().remove(JsfView.EVENT_KEY); } // tells JSF lifecycle that rendering should now happen and any subsequent phases should be skipped // required in the case of this action listener firing immediately (immediate=true) before validation context.renderResponse(); }
/** * Returns a list of all action expressions and listeners associated with given component. This covers expressions * in <code>action</code> attribute of command components and <code>listener</code> attribute of ajax components. * Any method expressions are in format <code>#{bean.method}</code> and any action listeners are added as fully * qualified class names. This list is primarily useful for logging postback actions in a phase listener. You can * use {@link #getCurrentActionSource()} to obtain the current action source. * @param component The component to retrieve all action expressions and listeners from. * @return A list of all action expressions and listeners associated with given component. * @since 2.4 */ public static List<String> getActionExpressionsAndListeners(UIComponent component) { List<String> actions = new ArrayList<>(); if (component instanceof ActionSource2) { ActionSource2 source = (ActionSource2) component; addExpressionStringIfNotNull(source.getActionExpression(), actions); for (ActionListener actionListener : source.getActionListeners()) { actions.add(actionListener.getClass().getName()); } } if (component instanceof ClientBehaviorHolder) { String behaviorEvent = getRequestParameter(BEHAVIOR_EVENT_PARAM_NAME); if (behaviorEvent != null) { for (BehaviorListener listener : getBehaviorListeners((ClientBehaviorHolder) component, behaviorEvent)) { addExpressionStringIfNotNull(getField(listener.getClass(), MethodExpression.class, listener), actions); } } } return unmodifiableList(actions); }
@Override public void applyMetadata(FaceletContext ctx, Object instance) { ((ActionSource2) instance).setActionExpression(this.attr .getMethodExpression(ctx, Object.class, ActionSourceRule.ACTION_SIG)); }
/** * @since 1.2 */ public static void addActionListenerProperty(FacesContext context, UIComponent component, MethodExpression actionListener) { if (actionListener != null) { if (!(component instanceof ActionSource2)) { throw new IllegalArgumentException("Component " + component.getClientId(context) + " is no ActionSource"); } ((ActionSource2)component).addActionListener(new MethodExpressionActionListener(actionListener)); } }
protected String getRequestName(ActionEvent event) { final String actionName; if (event.getComponent() instanceof ActionSource2) { // actionSource est une UICommand en général final ActionSource2 actionSource = (ActionSource2) event.getComponent(); if (actionSource.getActionExpression() != null) { actionName = actionSource.getActionExpression().getExpressionString(); } else { actionName = actionSource.getClass().getName(); } } else { actionName = event.getComponent().getClass().getName(); } return actionName; } }
@Override public void applyMetadata(FaceletContext ctx, Object instance) { ((ActionSource2) instance).setActionExpression(this.attr .getMethodExpression(ctx, Object.class, ActionSourceRule.ACTION_SIG)); }
/** * @since 1.2 */ public static void addActionListenerProperty(FacesContext context, UIComponent component, MethodExpression actionListener) { if (actionListener != null) { if (!(component instanceof ActionSource2)) { throw new IllegalArgumentException("Component " + component.getClientId(context) + " is no ActionSource"); } ((ActionSource2)component).addActionListener(new MethodExpressionActionListener(actionListener)); } }
@Override public void processAction(ActionEvent event) { if (LOGGER.isLoggable(FINE)) { LOGGER.fine(format("processAction({0})", event.getComponent().getId())); } UIComponent source = event.getComponent(); FacesContext context = event.getFacesContext(); MethodExpression expression = ((ActionSource2) source).getActionExpression(); invokeNavigationHandling( context, source, expression, getNavigationOutcome(context, expression)); // Trigger a switch to Render Response if needed context.renderResponse(); }
public void applyMetadata(FaceletContext ctx, Object instance) { ((ActionSource2) instance).setActionExpression(this.attr .getMethodExpression(ctx, Object.class, ActionSourceRule.ACTION_SIG)); }
/** * @since 1.2 */ public static void addActionListenerProperty(FacesContext context, UIComponent component, MethodExpression actionListener) { if (actionListener != null) { if (!(component instanceof ActionSource2)) { throw new IllegalArgumentException("Component " + component.getClientId(context) + " is no ActionSource"); } ((ActionSource2) component) .addActionListener(new MethodExpressionActionListener( actionListener)); } }