Réf. : Re: [Opensource] Struts Validation in Expresso

Raul DAVIDOVICH R.DAVIDOVICH at caconcology.com
Mon Mar 15 04:42:02 PST 2004



Peter,


>>I presume you are allowing the Struts MVC to automatically the validate
>>the action form bean in the struts-config.xml file.

Exactly


>>Have you tried making it work manually inside an Expresso Controller?
>>Get the ActionForm from the `ServletControllerRequest'. I believe the
method
>>is:
>>org.apache.struts.action.ActionForm getForm()
>>            Gets the action form as a convenience for pure Struts writer.

>>then call validate() on the form bean.

>>ActionErrors errors =  formBean.validate( httpServletRequest,
actionMapping );

>>See also

>>HttpServletRequest  getHttpServletRequest()
>>            Gets the http servlet response object Important: A Controller
should only use this
>>method if strictly necessary, and not write output that is otherwise able
to be handled with
>>inputs, outputs and transitions.

>>org.apache.struts.action.ActionMapping getMapping()
>>            Gets the action mapping as a convenience for pure Struts
writer.

Yes. it works.




In fact, I have the validation working correctly. I modified
ExpressoRequestProcessor overriding the processValidate() method so custom
logic can be performed there.
Normally, in pure Struts, the mapping is done one input -> one action. This
input is either a JSP or an action mapping (/something.do), and
RequestProcessor forwards back to it if the validation fails.

In Expresso an action mapping maps to a controller, with many states, so we
have many inputs -> many states, and the input comes usually from a prompt
state.

So my problem is: how to get the prompt state in the processValidate()
method so we can forward back to it if validation fails, and keep it as
transparent as possible to the developer.

1) is it cached somewhere? if it is, how could I retrieve it?
  if not,
   2)would it be clean to cache it somewhere? (like the session for
instance)
   3)would it be better to define the input parameter in struts-config.xml
as input="promptState, controller.of.prompState, processState;
promptOtherState, OtherController, anotherProcessState", somewhat similar
to workflow definitions in controllers
   4)can a different option be to define it in a separate XML config file?
or customizing config.xml or validation.xml?


this is the original code where it forwards back to the input:
...
        if (moduleConfig.getControllerConfig().getInputForward()) {
            ForwardConfig forward = mapping.findForward(input);
            processForwardConfig( request, response, forward);
        } else {
            internalModuleRelativeForward(input, request, response);
        }
...


Thanks for your help!

Best regards,

---------------------------------------------------
Raul Davidovich
Responsable Informatique
Cvitkovic & Associés Consultants

(33) 1 45 15 40 68
(33) 1 45 15 40 41 Fax
-------------------------------------------------------
http://www.caconcology.com






More information about the Opensource mailing list