Struts validation before form is displayed

Discussion in 'Java' started by Jack, Jul 19, 2005.

  1. Jack

    Jack Guest

    Hello,
    I'm currently having a problem with the Struts validator.
    I have a very simple Struts bean "EditionPersonneForm" (extending
    ValidatorForm) associated with an action "EditerPersonneAction" and a
    JSP form "EditerPersonne.jsp"

    [From struts-config.xml]
    <action path="/EditionPersonne"

    type="com.myproject.actions.EditerPersonneAction"
    scope="session" name="EditerPersonneForm"
    input="/pages/EditerPersonne.jsp"
    parameter="do"
    validate="true">
    <forward name="afficherEditionPersonne"
    path="/pages/EditionPersonne.jsp"/>
    <forward name="afficherAjoutPersonne"
    path="/pages/AjoutPersonne.jsp" />
    </action>
    [end of listing]

    The matter is that the method validate() is called BEFORE the form is
    displayed. So if the Struts bean is filled in with wrong values at this

    very moment, the validator causes an error and Struts redirects me to
    the "input" error page, and the action (which populates the form
    with the right data) is never called !
    I have another quite alike project where the validate is not called
    before the JSP (to me it should be the normal behaviour), so I guess
    this is a simple problem of configuration, but I just was not able to
    find it.
    Does anyone have a clue ?
    Thanks in advance,
    Olivier
     
    Jack, Jul 19, 2005
    #1
    1. Advertising

  2. Jack

    Billy Guest

    Hi again
    More details:
    My problem seems to be related to the Struts Tiles (the main difference
    between my project and the example is that one do use the Tiles plugin
    while the other don't). I still can't figure out what's wrong (for I
    didn't have the time to understand the Tiles very well yet, my new
    project is a copy from the basic struts-blank). Am I right ? I am still
    trying, but a little help would be welcome.
    Cheers
    Olivier
     
    Billy, Jul 19, 2005
    #2
    1. Advertising

  3. Jack

    Wendy Smoak Guest

    "Billy" <> wrote

    > My problem seems to be related to the Struts Tiles (the main difference
    > between my project and the example is that one do use the Tiles plugin
    > while the other don't). I still can't figure out what's wrong (for I
    > didn't have the time to understand the Tiles very well yet, my new
    > project is a copy from the basic struts-blank). Am I right ? I am still
    > trying, but a little help would be welcome.


    The quickest way to get help is to post on the Struts Users mailing list:
    http://struts.apache.org/mail.html

    --
    Wendy Smoak
     
    Wendy Smoak, Jul 19, 2005
    #3
  4. Jack

    Ramza Brown Guest

    Jack wrote:
    > Hello,
    > I'm currently having a problem with the Struts validator.
    > I have a very simple Struts bean "EditionPersonneForm" (extending
    > ValidatorForm) associated with an action "EditerPersonneAction" and a
    > JSP form "EditerPersonne.jsp"
    >
    > [From struts-config.xml]
    > <action path="/EditionPersonne"
    >
    > type="com.myproject.actions.EditerPersonneAction"
    > scope="session" name="EditerPersonneForm"
    > input="/pages/EditerPersonne.jsp"
    > parameter="do"
    > validate="true">
    > <forward name="afficherEditionPersonne"
    > path="/pages/EditionPersonne.jsp"/>
    > <forward name="afficherAjoutPersonne"
    > path="/pages/AjoutPersonne.jsp" />
    > </action>
    > [end of listing]
    >
    > The matter is that the method validate() is called BEFORE the form is
    > displayed. So if the Struts bean is filled in with wrong values at this
    >
    > very moment, the validator causes an error and Struts redirects me to
    > the "input" error page, and the action (which populates the form
    > with the right data) is never called !
    > I have another quite alike project where the validate is not called
    > before the JSP (to me it should be the normal behaviour), so I guess
    > this is a simple problem of configuration, but I just was not able to
    > find it.
    > Does anyone have a clue ?
    > Thanks in advance,
    > Olivier
    >


    This is interesting.
     
    Ramza Brown, Jul 19, 2005
    #4
  5. Jack

    Billy Guest

    Thank you Wendy for the good tip !
     
    Billy, Jul 20, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. PC Leung
    Replies:
    0
    Views:
    790
    PC Leung
    Aug 10, 2004
  2. Sumith Mathur
    Replies:
    0
    Views:
    2,226
    Sumith Mathur
    Sep 23, 2004
  3. olivier
    Replies:
    0
    Views:
    347
    olivier
    Jul 19, 2005
  4. boney
    Replies:
    1
    Views:
    591
  5. bnp
    Replies:
    4
    Views:
    344
Loading...

Share This Page