@@ -0,0 +1,2327 @@
+/*%0A * Copyright 2002-2005 the original author or authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.springframework.web.flow.action;%0A%0Aimport org.springframework.util.Assert;%0Aimport org.springframework.web.flow.ActionExecutionException;%0Aimport org.springframework.web.flow.Event;%0Aimport org.springframework.web.flow.RequestContext;%0Aimport org.springframework.web.flow.TransitionCriteria;%0A%0A/**%0A * A transitional precondition that will bind and validate input in a submitting%0A * event to a backing domain object and validate it, using the configured%0A * FormAction. This precondition will return %3Ccode%3Etrue%3C/code%3E if binding and%0A * validation is successful (no errors), %3Ccode%3Efalse%3C/code%3E otherwise.%0A * %0A * @author Keith Donald%0A */%0Apublic class BindAndValidateTransitionPrecondition implements TransitionCriteria %7B%0A%0A%09/**%0A%09 * The form action that will do the bind and validate.%0A%09 */%0A%09private FormAction formAction;%0A%0A%09/**%0A%09 * Create a bind and validate precondition delegating to the specified form%0A%09 * action.%0A%09 * %0A%09 * @param formAction%0A%09 *            The form action%0A%09 */%0A%09public BindAndValidateTransitionPrecondition(FormAction formAction) %7B%0A%09%09Assert.notNull(formAction, %22The form action is required%22);%0A%09%09this.formAction = formAction;%0A%09%7D%0A%0A%09/* Allow the transition if the formAction returns success() on binding and validation.%0A%09 * @see org.springframework.web.flow.TransitionCriteria#test(org.springframework.web.flow.RequestContext)%0A%09 */%0A%09public boolean test(RequestContext context) %7B%0A%09%09try %7B%0A%09%09%09Event result = formAction.bindAndValidate(context);%0A%09%09%09if (result.getId().equals(%22success%22)) %7B%0A%09%09%09%09return true;%0A%09%09%09%7D%0A%09%09%09else %7B%0A%09%09%09%09return false;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09catch (Exception e) %7B%0A%09%09%09throw new ActionExecutionException(%22Unable to invoke bindAndValidate on target formAction %22 + formAction, e);%0A%09%09%7D%0A%09%7D%0A%7D%0A

support precondition