SWF-543 - Add support for calculating immediate attribute value on Spring Faces command buttons from current view-state transition
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user