Pierre Métras wrote:

> As my design seems to be the *bad* one, I think I will have to change my
> code (explode my actions in struts-config.xml to create action
> /doSomethingInit and /doSomethingValid, and attach an "input" value only to
> /doSomethingValid, change all my JSP forms with these URL, and in the move
> suppress the now unused "action" parameter...). And Craig will have to
> rollback the CVS :,-(

I'm not convinced that it would need to be rolled back -- or at least not
completely.

Independent of the actions versus sub-actions question on application
organization, you also pointed out a real problem -- in the Struts 1.0 code as
it was before this change, consider the following scenario:
* You declare your action to require a form bean
* Your form bean wants to do validation
* You forget to define an "input" parameter
  in the action mapping
* Struts never calls your validate() method
* Your action method gets called, probably
  assuming that validation was successful,
  and relies on incorrect assumptions.

This seems like a Bad Thing for a framework to allow when the developer simply
forgets to update a configuration file :-(.

As the code sits right this minute, processValdiate() performs the following
steps, where a "true" return says "go ahead and call the action".
(A) If there is no form bean, simply return true
(B) If the request was cancelled, simply return true
     (higher level logic will skip the call to the action)
(C) Call the validate() method.  If it returns no errors,
     simply return true
---------- from here on you know an error occurred ----------
(D) If this is a multipart request, roll it back
(E) Was an input form defined?  If not, throw
     an error 500 (internal server error) to document
     the mis-configuration problem.
(F) Do a RequestDispatcher.forward() to the input form,
     and return false.

>From what it sounds like, there are particular concerns about step (C) --
validate() is always called -- and step (E) -- multipart requests are rolled
back on validation errors.  I don't really have a problem with either one of
them, but others might.

Can we come to agreement on what the recommended sequence of steps should be?

Craig


>
> Am I alone to have fallen in that trap?
>
> Pierre Métras

Reply via email to