Tom Bednarz wrote:
David Durham wrote:
Tom Bednarz wrote:
I think the validator fires too early, but probably I am doing something wrong. Maybe somebody can hp!

Basically, you need 2 actions, one to populate the form and one to change the personal data.

Or at least two action mappings, if you want to use automatic validation. If you're happy to invoke validation manually, you can get by with just one action and one mapping.

This is EXACTLY what I like to AVOID! With this concept I have to write dozends of useless action classes!

Nope, with that approach you would simply *seperate* your one action class into two classes which each encapsulate one branch or your if statement below -- i.e. an action that does 'Populate the form' and one that does 'Perform update operation'.

If you don't like having two separate classes, there are various options for combining them, including the various flavours of dispatch action and the approach you illustrate below.

In my Action class I did:

public ActionForward execute(ActionMapping mapping, ActionForm form,
          HttpServletRequest request, HttpServletResponse response)
{
    ActionForward af = null;
    ......

    String operation = request.getParameter("operation");
    .....

    if (operation != null &&
        operation.compareToIgnoreCase("update") == 0)
    {
    ..... Perform update operation here
    }
   else  // showData
   {
    .... Populate form here
   }
   return (new ActionForward("/showPersonalData.do"));
}

The surprising thing (at least for me...) is, that when running in the debugger, execute method is NEVER called (does not stop at any breakpoint) !!!

Do you have validate="true" on your action mapping? If validate is set to true, the framework will perform validation for you automatically before invoking the action. Hence, you need to either a) have two action mappings in your config (note: two mappings, not necessarily two action classes), one with validate=false and operation set to null and one with validate=true and operation set to whatever; or b) using a single action mapping, set validate=false and call validate() manually as appropriate.

Is there no more intelligent way then creating lots of actions?? Maybe this is a motivation to move to JSF!!

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to