struts javascript validator message problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alex M

    struts javascript validator message problem

    I'm trying to use the jakarta struts client side javascript validators
    and the validators are working, but they are not showing the popup
    messages. I have the message keys defined in the
    ApplicationReso urces.propertie s file, the propertise file is in the
    right location, it is referenced from the struts-config.xml, but still
    no messages. For example, submitting a form that violates the
    required field validator, just causes it to do nothing but shift focus
    to that field, no messages are shown.

    Am I missing something?
  • Peter Astbury

    #2
    Re: struts javascript validator message problem

    Alex M wrote:[color=blue]
    > I'm trying to use the jakarta struts client side javascript validators
    > and the validators are working, but they are not showing the popup
    > messages. I have the message keys defined in the
    > ApplicationReso urces.propertie s file, the propertise file is in the
    > right location, it is referenced from the struts-config.xml, but still
    > no messages. For example, submitting a form that violates the
    > required field validator, just causes it to do nothing but shift focus
    > to that field, no messages are shown.
    >
    > Am I missing something?[/color]

    javascript? This is the java newsgroup - try posting that to
    comp.lang.javas cript instead.

    Comment

    • Matt Parker

      #3
      Re: struts javascript validator message problem

      Peter Astbury wrote:
      [color=blue]
      > Alex M wrote:[color=green]
      >> I'm trying to use the jakarta struts client side javascript validators
      >> and the validators are working, but they are not showing the popup
      >> messages. I have the message keys defined in the
      >> ApplicationReso urces.propertie s file, the propertise file is in the
      >> right location, it is referenced from the struts-config.xml, but still
      >> no messages. For example, submitting a form that violates the
      >> required field validator, just causes it to do nothing but shift focus
      >> to that field, no messages are shown.
      >>
      >> Am I missing something?[/color]
      >
      > javascript? This is the java newsgroup - try posting that to
      > comp.lang.javas cript instead.[/color]

      He is right to post here, this is a Struts question. As it is, I don't know
      the answer since I've only used the server-side validator component, not
      the client-side component. Maybe someone else will have an idea.

      OS, browser etc would be some useful information...

      Matt

      --
      Not so interesting...

      Comment

      • Ryan Stewart

        #4
        Re: struts javascript validator message problem

        "Alex M" <alx@acm.org> wrote in message
        news:ac45876e.0 402231157.7499f 7d5@posting.goo gle.com...[color=blue]
        > I'm trying to use the jakarta struts client side javascript validators
        > and the validators are working, but they are not showing the popup
        > messages. I have the message keys defined in the
        > ApplicationReso urces.propertie s file, the propertise file is in the
        > right location, it is referenced from the struts-config.xml, but still
        > no messages. For example, submitting a form that violates the
        > required field validator, just causes it to do nothing but shift focus
        > to that field, no messages are shown.
        >
        > Am I missing something?[/color]

        Do you have all the javascript elements and files in the proper places? I'm
        learning Struts now and just tinkered with that feature yesterday. If you
        look at the example application that comes with it, you'll see an example of
        Javascript validation in their logon.jsp. First of all, the Javascript
        itself is specified in validator-rules.xml. You need an <html:javascrip t>
        tag in the file where you want to do the validation as well as a script tag
        to include an external js file, staticJavascrip t.jsp (that's their name for
        it). See the example app for this file's contents (it's tiny, not sure how
        it does what it does yet). Finally, in the form you want to validate add to
        the form tag:
        onsubmit="retur n validateLogonFo rm(this);"

        Or whatever function you want to call. I think that's everything.


        Comment

        • strutsman

          #5
          Re: struts javascript validator message problem

          Hi
          I have the same frustrating problem. I fix it with the following
          code in validation.xml. Not neat, Strangly,
          <arg0 key="error.user name.required"/> doesn't work. Probabably
          a bug.

          <form-validation>
          <formset>
          <form name="logonForm ">
          <field property="usern ame" depends="requir ed,maxlength">
          <msg name="required" key="error.user name.required"/>
          <msg name="maxlength " key="error.maxl ength"/>
          <var>
          <var-name>maxlength</var-name>
          <var-value>5</var-value>
          </var>
          </field>
          <field property="passw ord" depends="requir ed">
          <msg name="required" key="error.pass word.required"/>
          </field>
          </form>
          </formset>
          </form-validation>

          <!-- doesn't work

          <form-validation>
          <formset>
          <form name="logonForm ">
          <field property="usern ame" depends="requir ed">
          <arg0 key="error.user name.required"/>
          </field>
          <field property="passw ord" depends="requir ed">
          <arg0 key="error.pass word.required"/>
          </field>
          </form>
          </formset>
          </form-validation>

          -->


          Regards

          StrutsMan

          Comment

          • Nam

            #6
            Re: struts javascript validator message problem

            you can use regexp package from apache.org. it is great.

            strutsman@sling shot.co.nz (strutsman) wrote in message news:<f6036c9a. 0403260334.411f 3fcf@posting.go ogle.com>...[color=blue]
            > Hi
            > I have the same frustrating problem. I fix it with the following
            > code in validation.xml. Not neat, Strangly,
            > <arg0 key="error.user name.required"/> doesn't work. Probabably
            > a bug.
            >
            > <form-validation>
            > <formset>
            > <form name="logonForm ">
            > <field property="usern ame" depends="requir ed,maxlength">
            > <msg name="required" key="error.user name.required"/>
            > <msg name="maxlength " key="error.maxl ength"/>
            > <var>
            > <var-name>maxlength</var-name>
            > <var-value>5</var-value>
            > </var>
            > </field>
            > <field property="passw ord" depends="requir ed">
            > <msg name="required" key="error.pass word.required"/>
            > </field>
            > </form>
            > </formset>
            > </form-validation>
            >
            > <!-- doesn't work
            >
            > <form-validation>
            > <formset>
            > <form name="logonForm ">
            > <field property="usern ame" depends="requir ed">
            > <arg0 key="error.user name.required"/>
            > </field>
            > <field property="passw ord" depends="requir ed">
            > <arg0 key="error.pass word.required"/>
            > </field>
            > </form>
            > </formset>
            > </form-validation>
            >
            > -->
            >
            >
            > Regards
            >
            > StrutsMan[/color]

            Comment

            Working...