You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mike Millson <mm...@meritonlinesystems.com> on 2004/02/25 19:57:40 UTC

Bug in Validator javascript, not showing all errors?

I have a form with 1 text field and 1 password field:
username: required and maxlength 10
password: required

The return statement for the validateLoginForm function generated in the
dynamic javascript:

return validateMaxLength(form) && validateRequired(form); 

If I enter a username that is too long, validateMaxLength returns false, so validateRequired is never evaluated. The result is that only the error about username being too long is displayed, even if password is empty.

This is not how it works on the server side. If I disable javascript and submit, the server side displays both errors: username too long and password required.

Is this a bug? Why aren't the client side and server side validation
results equal?

Thank you,
Mike


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Bug in Validator javascript, not showing all errors?

Posted by ru...@albany.edu.
Mike:
I see what you're saying now.

It's only showing all the errors of the same type at any one time
dependending on the order the Validator functions are called.

Sorry for the confusion.
-Ryan ( <---darn newbies )

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Bug in Validator javascript, not showing all errors?

Posted by Mike Millson <mm...@meritonlinesystems.com>.
On Wed, 2004-02-25 at 15:20, russo@albany.edu wrote:
> Hi Mike:
> 
> > Thank you. And if I understand correctly, this feature is not available
> > in the latest release build, v1.1. I guess I have to wait until v1.2
> > comes out?
> >
> I'm using stable release of Struts 1.1

I found that you can set this property on v1.1, but it doesn't do
anything. Have you verified that you get both maxlength and required
errors at the same time in one alert box?

> 
> I assume you changed your calls to specific Validator functions to the
> wrapper function built by Validator and named the way I specified?

Yes. In your example below, if you do a view source on index.jsp you
will see javascript function called validateLoginForm. If userid is
required and has a maxlength and passwd is required, the return
statement for validateLoginForm will be: return validateMaxLength(form)
&& validateRequired(form).

So, it will only show the maxlength error or the required errors, but
not both.

> 
> To the best of my limited knowledge you shouldn't be calling the
> individual Validator functions. Unless you're doing something special?
> 
> See my complete index.jsp below sig
> 
> In my app I have:
>  LoginForm.java (extends ValidatorForm)
> 
> If that's not helping give me an idea of where you're still having problems.
> -Ryan
> 
> File = index.jsp:
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
> <link href="lib/style.css" rel="stylesheet" type="text/css">
> <title><bean:message key="index.title" /></title>
> 
> <html:javascript formName="loginForm"/>
> 
> </head>
> <body bgcolor="White">
>   <html:form action="console" onsubmit="return validateLoginForm(this)">
>     <table cellspacing="0" cellpadding="3" border="0" width="60%">
>       <tr><td colspan="3"><img src="images/afr.jpg" width="514"
> height="110" alt="<bean:message key="index.title" />"></td></tr>
>       <tr>
>         <td align="right">User Name</td>
>         <td>
>           <html:text property="userid"></html:text>
>         </td>
>         <td rowspan="3"><html:errors /></td>
>       </tr>
>       <tr>
>         <td align="right">Password</td>
>         <td>
>           <html:password property="passwd"></html:password>
>         </td>
>       </tr>
>       <tr>
>         <td>&nbsp;</td>
>         <td>
>           <html:submit></html:submit>
>         </td>
>       </tr>
>     </table>
>   </html:form>
> </body>
> </html>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Bug in Validator javascript, not showing all errors?

Posted by ru...@albany.edu.
Sorry:
 I missed the declarations at the top of my index.jsp
The following precedes the <html> tag:

<%@ page session="false" %>
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>


-Ryan

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Bug in Validator javascript, not showing all errors?

Posted by ru...@albany.edu.
Hi Mike:

> Thank you. And if I understand correctly, this feature is not available
> in the latest release build, v1.1. I guess I have to wait until v1.2
> comes out?
>
I'm using stable release of Struts 1.1

I assume you changed your calls to specific Validator functions to the
wrapper function built by Validator and named the way I specified?

To the best of my limited knowledge you shouldn't be calling the
individual Validator functions. Unless you're doing something special?

See my complete index.jsp below sig

In my app I have:
 LoginForm.java (extends ValidatorForm)

If that's not helping give me an idea of where you're still having problems.
-Ryan

File = index.jsp:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link href="lib/style.css" rel="stylesheet" type="text/css">
<title><bean:message key="index.title" /></title>

<html:javascript formName="loginForm"/>

</head>
<body bgcolor="White">
  <html:form action="console" onsubmit="return validateLoginForm(this)">
    <table cellspacing="0" cellpadding="3" border="0" width="60%">
      <tr><td colspan="3"><img src="images/afr.jpg" width="514"
height="110" alt="<bean:message key="index.title" />"></td></tr>
      <tr>
        <td align="right">User Name</td>
        <td>
          <html:text property="userid"></html:text>
        </td>
        <td rowspan="3"><html:errors /></td>
      </tr>
      <tr>
        <td align="right">Password</td>
        <td>
          <html:password property="passwd"></html:password>
        </td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>
          <html:submit></html:submit>
        </td>
      </tr>
    </table>
  </html:form>
</body>
</html>

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Bug in Validator javascript, not showing all errors?

Posted by Mike Millson <mm...@meritonlinesystems.com>.
Thank you. And if I understand correctly, this feature is not available
in the latest release build, v1.1. I guess I have to wait until v1.2
comes out?

On Wed, 2004-02-25 at 14:18, russo@albany.edu wrote:
> File = struts-config.xml >> Validator plugin elements:
>   <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
>     <set-property property="pathnames"
>            value="/WEB-INF/validator-rules.xml, /WEB-INF/validation.xml"/>
>     <set-property property="stopOnFirstError" value="false"/>
>   </plug-in>
> 
> File = login.jsp >> form declaration:
> ...
> <html:form action="console" onsubmit="return validate[BLAH](this)">
> ...
> 
> Where [BLAH] is the name of the action which handles your form submition.
> 
> I'm a newbie, so if there's a better way fire away people.
> -Ryan
> 
> On Wed, 25 Feb 2004, Mike Millson wrote:
> 
> > I have a form with 1 text field and 1 password field:
> > username: required and maxlength 10
> > password: required
> >
> > The return statement for the validateLoginForm function generated in the
> > dynamic javascript:
> >
> > return validateMaxLength(form) && validateRequired(form);
> >
> > If I enter a username that is too long, validateMaxLength returns false, so validateRequired is never evaluated. The result is that only the error about username being too long is displayed, even if password is empty.
> >
> > This is not how it works on the server side. If I disable javascript and submit, the server side displays both errors: username too long and password required.
> >
> > Is this a bug? Why aren't the client side and server side validation
> > results equal?
> >
> > Thank you,
> > Mike
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> 
> |----------------------------------|
> | Ryan Russo                       |
> | russo@[noSPAM].albany.edu        |
> | University at Albany--Computing  |
> | <<remove [noSPAM] to e-mail>>    |
> | Technical Services Web Team      |
> |__________________________________|
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Bug in Validator javascript, not showing all errors?

Posted by ru...@albany.edu.

File = struts-config.xml >> Validator plugin elements:
  <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property property="pathnames"
           value="/WEB-INF/validator-rules.xml, /WEB-INF/validation.xml"/>
    <set-property property="stopOnFirstError" value="false"/>
  </plug-in>

File = login.jsp >> form declaration:
...
<html:form action="console" onsubmit="return validate[BLAH](this)">
...

Where [BLAH] is the name of the action which handles your form submition.

I'm a newbie, so if there's a better way fire away people.
-Ryan

On Wed, 25 Feb 2004, Mike Millson wrote:

> I have a form with 1 text field and 1 password field:
> username: required and maxlength 10
> password: required
>
> The return statement for the validateLoginForm function generated in the
> dynamic javascript:
>
> return validateMaxLength(form) && validateRequired(form);
>
> If I enter a username that is too long, validateMaxLength returns false, so validateRequired is never evaluated. The result is that only the error about username being too long is displayed, even if password is empty.
>
> This is not how it works on the server side. If I disable javascript and submit, the server side displays both errors: username too long and password required.
>
> Is this a bug? Why aren't the client side and server side validation
> results equal?
>
> Thank you,
> Mike
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>

|----------------------------------|
| Ryan Russo                       |
| russo@[noSPAM].albany.edu        |
| University at Albany--Computing  |
| <<remove [noSPAM] to e-mail>>    |
| Technical Services Web Team      |
|__________________________________|

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org