From 1be8fac47be0fcedcd4658bcddcaff124d4e09c1 Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Thu, 13 Nov 2008 18:50:51 +0000 Subject: [PATCH] polish --- .../webflow/mvc/view/AbstractMvcView.java | 60 +++++++++++++------ 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java index 202a719b..3f471be4 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java @@ -170,7 +170,7 @@ public abstract class AbstractMvcView implements View { } public void processUserEvent() { - determineEventId(requestContext); + eventId = determineEventId(requestContext); if (eventId == null) { return; } @@ -230,6 +230,46 @@ public abstract class AbstractMvcView implements View { */ protected abstract void doRender(Map model) throws Exception; + /** + * Obtain the user event from the current flow request. The default implementation returns the value of the request + * parameter with name {@link #setEventIdParameterName(String) eventIdParameterName}. Subclasses may override. + * @param context the current flow request context + * @return the user event that occurred + */ + protected String determineEventId(RequestContext context) { + return WebUtils.findParameterValue(context.getRequestParameters().asMap(), eventIdParameterName); + } + + /** + * Determines if model data binding should be invoked given the Transition that matched the current user event being + * processed. Returns true unless the bind attribute of the Transition has been set to false. + * Subclasses may override. + * @param model the model data binding would be performed on + * @param transition the matched transition + * @return true if binding should occur, false if not + */ + protected boolean shouldBind(Object model, TransitionDefinition transition) { + if (transition == null) { + return true; + } + return transition.getAttributes().getBoolean("bind", Boolean.TRUE).booleanValue(); + } + + /** + * Determines if model validation should execute given the Transition that matched the current user event being + * processed. Returns true unless the validate attribute of the Transition has been set to false. + * Subclasses may override. + * @param model the model data binding would be performed on + * @param transition the matched transition + * @return true if binding should occur, false if not + */ + private boolean shouldValidate(Object model, TransitionDefinition transition) { + if (transition == null) { + return true; + } + return transition.getAttributes().getBoolean("validate", Boolean.TRUE).booleanValue(); + } + // internal helpers private Map flowScopes() { @@ -267,13 +307,6 @@ public abstract class AbstractMvcView implements View { return (Expression) requestContext.getCurrentState().getAttributes().get("model"); } - private boolean shouldBind(Object model, TransitionDefinition transition) { - if (transition == null) { - return true; - } - return transition.getAttributes().getBoolean("bind", Boolean.TRUE).booleanValue(); - } - private MappingResults bind(Object model) { if (logger.isDebugEnabled()) { logger.debug("Setting up view->model mappings"); @@ -399,22 +432,11 @@ public abstract class AbstractMvcView implements View { .defaultText(errorCode + " on " + field).build(); } - private boolean shouldValidate(Object model, TransitionDefinition transition) { - if (transition == null) { - return true; - } - return transition.getAttributes().getBoolean("validate", Boolean.TRUE).booleanValue(); - } - private void validate(Object model) { new ValidationHelper(model, requestContext, eventId, getModelExpression().getExpressionString(), expressionParser, mappingResults).validate(); } - private void determineEventId(RequestContext context) { - eventId = WebUtils.findParameterValue(context.getRequestParameters().asMap(), eventIdParameterName); - } - // accessors for mapping results public String getEventId() {