struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Riyad Kalla <>
Subject Re: struts repopulate bug?
Date Wed, 05 May 2004 01:26:32 GMT
Yes Struts should and does do this. It actually does this so well, that 
for login forms you need to manually clear the beans or else it 
repopulates the values :)

1) Are you syncing up the names/properties of your fields on your JSP 
page in the form with the property names of the Form?
.. Java snippet ..
public String getUserName();
public void setUserName(String userName);

... JSP Snippet ...
<html:text name="userForm" property="userName" />

2) Did you implement your reset method cleanly?

3) Is your validate method straight forward?
if(userName == null || userName.length() == 0)
  // make/add some errors
return actionErrors;

4) How is your action defined in your struts-config? Did you specify a 
scope for the bean? Have you tried NOT specifying the scope?

I want to reassure you that Struts does this very well and doesn't need 
you to hack around it, so if this is not working for you, we just need 
to keep trying.

Dana Jeffrey Hata wrote:

>I'm using Struts with WSAD, and I am attempting something very simple, which should happen
automagically.  Basically, I just need to have the form re-populate after submitting a form
which doesn't pass the form bean's validate method.  Should happen without any special coding
from me, as this is supposed to be a feature of struts.  Well, it didn't happen for me.  I
checked things like form-bean scope.  By plugging in some strategically placed System.outs,
I realized that struts was creating a new formbean object, and populating it, but when it
came back to my JSP, that was using a different formbean object.  Shouldn't it be getting
the form bean which (should have been) placed in the request/session by the actionservlet?
 Well, it apparently wasn't, because the way I got it to work was simply putting the following
line at the end of my formbean validate():
>request.setAttribute(<my formbean name>,this);
>This made everhything work, so my question is, why the hell didn't struts do this?  Isn't
it supposed to?  Is there anything I could have done to make struts not do this, or maybe
place a different form bean instance on the request?  It works now, but I don't like hacks.
>Thanks in advance,
>To unsubscribe, e-mail:
>For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message