سؤال

I'm trying to add a Forgot Password path to an existing view. I created a new view, action, model bean, and some states in my webflow. Instead of seeing the view, I keep getting the error java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'forgotPassword' available as request attribute. I know the bean exists, and it should be visible. I think I set up the webflow properly, but I'm not 100% sure. Does anybody know what I might be doing wrong?

casLoginView.jsp:

<a href="/cas/login?execution=${flowExecutionKey}&_eventId=forgotPassword">Forgot Password</a>

login-webflow.xml:

<var name="credentials" class="org.jasig.cas.authentication.principal.UsernamePasswordCredentials" />
<var name="forgotPasswordBean" class="com.mycompany.authentication.ForgotPasswordBean" />

<view-state id="viewLoginForm" view="casLoginView" model="credentials">
    <binder>
        <binding property="username" />
        <binding property="password" />
    </binder>
    <on-entry>
        <set name="viewScope.commandName" value="'credentials'" />
    </on-entry>
    <transition on="submit" bind="true" validate="true" to="realSubmit">
        <evaluate expression="authenticationViaFormAction.doBind(flowRequestContext, flowScope.credentials)" />
    </transition>
    <transition on="forgotPassword" bind="false" validate="false" to="forgotPasswordView"/>
</view-state>

<view-state id="forgotPasswordView" view="myForgotPasswordView.jsp" model="forgotPasswordBean">
     <binder>
        <binding property="username" required="true"/>
    </binder>
    <transition on="submit" to="forgotPassword"/>
</view-state>

<action-state id="forgotPassword">
    <evaluate expression="forgotPasswordAction.submit(flowScope.forgotPasswordBean)" />
    <transition on="success" to="newPasswordSentView"/>
    <transition on="forbidden" to="forgotPasswordForbiddenView"/>
    <transition on="error" to="forgotPasswordView"/>
</action-state>

<end-state id="newPasswordSentView" view="myNewPasswordSentView" />
<end-state id="forgotPasswordForbiddenView" view="forgotPasswordForbiddenView" />
هل كانت مفيدة؟

المحلول

Your <form:form ... > tag should reference the correct bean. Your configuration mentions a forgotPasswordBean and not a forgotPassword one.

Either your form object should reference the correct bean

<form:form modelAttribute="forgotPasswordBean" ... >

Or you should rename the bean in your webflow configuration (including all the references to it).

<var name="forgotPassword" class="com.mycompany.authentication.ForgotPasswordBean" />
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top