I found the answer to my extra credit question, you can use input="forwardName" in your action if you have inputForward set to true in your controller config. I have this set up, but it doesn't change any thing. Here is the log of what happens when I fill in a username and no password:
Processing a 'POST' for path '/myaccount/loginAction' Storing ActionForm bean instance in scope 'request' under attribute key 'LoginForm' Populating bean properties from this request Validating input form properties Validation failed, returning to 'myaccount/login' processForwardConfig(ForwardConfig[name=myaccount/login,path=/myaccount/login.do,redirect=false,contextRelative=false]) Processing a 'POST' for path '/myaccount/login' Storing ActionForm bean instance in scope 'request' under attribute key 'LoginForm' Populating bean properties from this request Looking for Action instance for class myapp.struts.actions.ForwardAction Returning existing Action instance From toString in my ForwardAction -> Path=[/WEB-INF/jsp/myaccount/login.jsp],Form=[Username=sdfdsf,Password=] processForwardConfig(ForwardConfig[name=null,path=/WEB-INF/jsp/myaccount/login.jsp,redirect=false,contextRelative=true])
I have removed all the info from these messages to make it easier to read. All of these messages are DEBUG messages that come from the RequestProcessor, except the toString that I am printing out near the end. This all looks like exactly what I would want to happen. The original POST goes to loginAction, the validate method is called and fails, so it forwards to myaccount/login. The form is stored in the request scope. When I call the toString method after the form has been populated, you can see the username property is populated. This makes sense. The request was forwarded from the original action to this action. The request parameters are still the same as the original request, so when the form is populated, the username field is populated.
What doesn't make sense to me is that when I look at my form on the HTML page (which is /WEB-INF/jsp/myaccount/login.jsp in this case), the username property is not populated. This doesn't make sense to me. The html:form tag should see that the form property for username is populated, so therefore the 'html:test property="username"' field should be populated with that value. What am I missing here?
Subject: Re: Re-populating form after validate fails From: [EMAIL PROTECTED] Date: Wed, 4 Feb 2004 12:50:17 +1100 To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
oops, you could be right. I left that out when I was genericising my action tag... just trying to make it more generic.
However, my point is still that when validate fails then the errors will not be empty... that is where your action tells struts to forward as:
forward = mapping.findForward("failure");
and in your struts entry you can see (in my example) that "failure" is defined as the same form (but it could be anything)
an example of this is in the sample struts project in the struts tutorial where the login screen forwards to "welcome" if login was okay, or back to "login" if it failed.
so I'm not sure if the input parameter is responsible for the forward... it could be the default?
Cheers, Heya Gosper CSC Australia 212 Northbourne Ave, Braddon ACT 2612 Ph: +61 (0) 2 6246 8155 Fax: +61 (0) 2 62468100 MOB: 0401 611779
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]