facebook

struts and validator question

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #223135 Reply

    gemino
    Member

    i have defined a DynaValidatorActionBean and a Action Class with extends DispatchAction. in the Action class there are the methods

    – prepareAdd (forwards to edit.jsp)
    – prepareEdit (forwards also to edit.jsp but gets chosen userinfos from database)
    – save (saves user)

    in the struts-config.xml there is an action-mapping where validate is true and the input source is edit.jsp.
    the edit.jsp is the add AND edit site with logic tags to choose if it is an edit or add action.
    and i have defined a validation rule in my validators validation.xml

    now the problem: everytime i call the edit or add action the validator is executed. even BEFORE i have inserted some values. that happens because the Action Class is meant to be validated. but i don’t want the prepareAdd and prepareEdit functions to be validated only when save is executed i hope its a bit clear what i mean.

    the problem is that error messages show up even if i just have called the site to edit.

    can someone gve me a solution how i have to organize my action-mappings and so on…. or do i find the solution at the validation configuration?!??

    #223137 Reply

    Riyad Kalla
    Member

    Moving to OT > Soft Dev, this isn’t about ME.

    The validate method applies to the ActionForm that is populated before the Action is called, if you have this set to “true” ANY time there is a String match against that action-mapping the ActionForm will be validated. If you only want certain action-mappings to trigger this, I suggest validation be set to ‘false’ and you can manually call the ActionForm’s validate method from your Action before processing it if you need to.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: struts and validator question

You must be logged in to post in the forum log in