Ok, I guess you
could but
should you? I tend to shy away from this practice just because it's another point of duplication: if you ever change the form name in struts-config, you are going to have to remember to change the setAttribute() parameter value wherever you do this. To me, there's a high likelihood that this will be overlooked by a maintenance programmer. Also, it will not be very easy to debug because it probably won't cause a RuntimeException if the names get out of synch.
Since a form can be associated with multiple actions, I would just associate the first action with the same form that the second action requires. Might have to add a flag field in the form to indicate normal use (values taken from request) vs. initial use (values assigned by action). The flag can be implemented in several ways but my first cut would be a hidden field in one of the JSPs and a method in the form that checks for the presence of a value in that field to indicate normal use. The reset method would then be implemented to reset the flag field and other fields that you want to have "cleared".
When the first action is invoked, it receives a request with a blank form (since reset is called on the form before it is passed to the perform/execute method). The action would then query the flag on the form and prepopulate it accordingly, then forward the request to the second action. This approach will eliminate the problem I mentioned above and I'm pretty sure I've used it before if not recently.
---
edit: (doing a lot of refactoring in my head here
)
Of course, the above approach wouldn't work if the first action was processing another type of form. In that case, I would probably just implement the reset in the form then check the flag and prepopulate accordingly in the second action's perform/execute. Come to think of it, I'd probably end up refactoring the approach above to this second approach.
Sorry if I'm rambling--woke up in the middle of the night with some reflux and I'm trying to get my stomach to settle down, maybe the acid is fogging up my thinking as well
[ January 31, 2003: Message edited by: Junilu Lacar ]