From b1097736557d2b59517d028be1847dec7c22716b Mon Sep 17 00:00:00 2001 From: Jeremy Grelle Date: Thu, 3 Apr 2008 20:02:01 +0000 Subject: [PATCH] SWF-543 - Add support for calculating immediate attribute value on Spring Faces command buttons from current view-state transition --- .../faces/ui/ProgressiveCommandButton.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandButton.java b/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandButton.java index cd71ca67..77a83ec2 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandButton.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandButton.java @@ -4,6 +4,11 @@ import javax.faces.component.UICommand; import javax.faces.context.FacesContext; import javax.faces.el.ValueBinding; +import org.springframework.webflow.definition.TransitionDefinition; +import org.springframework.webflow.engine.TransitionableState; +import org.springframework.webflow.execution.RequestContext; +import org.springframework.webflow.execution.RequestContextHolder; + public class ProgressiveCommandButton extends UICommand { private String type = "submit"; @@ -44,6 +49,19 @@ public class ProgressiveCommandButton extends UICommand { this.ajaxEnabled = ajaxEnabled; } + public boolean isImmediate() { + RequestContext context = RequestContextHolder.getRequestContext(); + if (context != null && getActionExpression().isLiteralText() + && context.getCurrentState() instanceof TransitionableState) { + TransitionDefinition transition = ((TransitionableState) context.getCurrentState()) + .getTransition(getActionExpression().getExpressionString()); + if (transition.getAttributes().contains("bind")) { + return Boolean.FALSE.equals(transition.getAttributes().getBoolean("bind")); + } + } + return super.isImmediate(); + } + public Object saveState(FacesContext context) { Object[] values = new Object[4]; values[0] = super.saveState(context);