You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by priya <pr...@gmail.com> on 2006/10/03 21:01:04 UTC

Avoiding multiple validation messages

I am using client-side and server-side validation in my login form.

Both work and when I dont enter the required fields I recieve a javascript
alert box saying that the fields "username or password are required". After
I click okay it does a serverside validation as well and prints on the
screen that the "username or password are required"..

I was wondering if its possible to show "username or password are required"
only once. When there is javascript enabled on the browser, to show the
client side version only and when javascript is disabled use the serverside
version?

Re: URL parameters separator

Posted by Antonio Petrelli <an...@gmail.com>.
2007/4/23, Christopher Schultz <ch...@christopherschultz.net>:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Harring,
>
> Harring Figueiredo wrote:
> > I am not sure if the DTD declares that (I did not take a look at it), but
> > basically the way to pass param on a HTML URL is the way it was generated -
> > Every single HTTP server will not parse the parameters correctly if it
> > is in the form that you want.
>
> No, Marcello is right. If you're using some minimum version of HTML or
> any version of XHTML, the URLs must use &amp; instead of bare & symbols
> in URLs. It's the browser's job to send the URL with bare & symbols to
> the server, but the HTML source should have them encoded.

Wait a minute! the <c:url> tag produces the URL itself, not the <a>
tag! So, the URL must not be escaped, but, when put into a <a> it
should. As I wrote in my previous post, he should use the "escapeXml"
EL function.

Antonio

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


Re: URL parameters separator

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Harring,

Harring Figueiredo wrote:
> I am not sure if the DTD declares that (I did not take a look at it), but
> basically the way to pass param on a HTML URL is the way it was generated -
> Every single HTTP server will not parse the parameters correctly if it
> is in the form that you want.

No, Marcello is right. If you're using some minimum version of HTML or
any version of XHTML, the URLs must use &amp; instead of bare & symbols
in URLs. It's the browser's job to send the URL with bare & symbols to
the server, but the HTML source should have them encoded.

Marcello, is there any configuration for the c:url tag (or possibly the
c:html tag?) that allows you to set a flag like "xhtml" or something
similar?

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGLLUP9CaO5/Lv0PARAmQMAKCDsMnu3Lewj1NGFpBR0neTRTobiACgsUwL
3TVeiQRyuUa/rKx5s5vcESM=
=1sDF
-----END PGP SIGNATURE-----

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


Re: URL parameters separator

Posted by Harring Figueiredo <ha...@gmail.com>.
 I am not sure if the DTD declares that (I did not take a look at it), but
basically the way to pass param on a HTML URL is the way it was generated -
Every single HTTP server will not parse the parameters correctly if it is in
the form that you want. If you have some special parser or that is indeed
what you want, I guess you will have to pass the entire parameter as one,
and not have multiple parameter arguments on the c:url.

Cheers,

hf



On 4/20/07, Marcello Savino <Ma...@aldebra.com> wrote:
>
> In my jsp i've a code like this:
>
> <logic:iterate id="index" name="list" type="myList">
> <c:url value="/myAction.do" var="url1">
>   <c:param name="id"><bean:write name="index" property="id" /></c:param>
>   <c:param name="year"><bean:write name="index" property="year"
> /></c:param>
> </c:url>
> <logic:iterate>
>
> The code works good. But the generated url are in this form:
>
> http://localhost:8080/myApp/myAction.do?id=161298&year=2005
>
> Instead of
>
> http://localhost:8080/myApp/myAction.do?id=161298&amp;year=2005
>
> As required by the DTD declared (xhtml 1.0 strict)
>
> Does anybody have some idea to get the right url parameter separator
> (&->&amp;) ?
> Thanks in advance.
> Marcello
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

[OT] Re: URL parameters separator

Posted by Antonio Petrelli <an...@gmail.com>.
2007/4/20, Marcello Savino <Ma...@aldebra.com>:
> The code works good. But the generated url are in this form:
>
> http://localhost:8080/myApp/myAction.do?id=161298&year=2005
>
> Instead of
>
> http://localhost:8080/myApp/myAction.do?id=161298&amp;year=2005
>
> As required by the DTD declared (xhtml 1.0 strict)

The URL itself is OK, but it needs to be encoded.

>
> Does anybody have some idea to get the right url parameter separator
> (&->&amp;) ?

Try:
http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/fn/escapeXml.fn.html

HTH
Antonio

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


URL parameters separator

Posted by Marcello Savino <Ma...@aldebra.com>.
In my jsp i've a code like this:

<logic:iterate id="index" name="list" type="myList">
 <c:url value="/myAction.do" var="url1">			
  <c:param name="id"><bean:write name="index" property="id" /></c:param>
  <c:param name="year"><bean:write name="index" property="year"
/></c:param>
 </c:url>
<logic:iterate>

The code works good. But the generated url are in this form:

http://localhost:8080/myApp/myAction.do?id=161298&year=2005

Instead of 

http://localhost:8080/myApp/myAction.do?id=161298&amp;year=2005

As required by the DTD declared (xhtml 1.0 strict)

Does anybody have some idea to get the right url parameter separator
(&->&amp;) ?
Thanks in advance.
Marcello


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


Re: Avoiding multiple validation messages

Posted by priya <pr...@gmail.com>.
Hi Ed,

Thank you for the clarification! That worked out great!

Priya

On 10/3/06, Ed Griebel <ed...@gmail.com> wrote:
>
> Let me clarify, in your html:form statement, try adding a return like so:
>
> <html:form action="/login" method="post" onsubmit="return
> validateLoginForm(this)">
>
> On 10/3/06, priya <pr...@gmail.com> wrote:
> >
> > Hi Ed,
> >
> > Thank you for your response!
> > Since I am using Struts client side validation, I am not creating the
> > validate method.. Struts is creating it for me..
> > Do you mean I should create another method ? I am not sure if I can add
> > return to the javascript which Struts creates for me?
> >
> > <%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>
> > <%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>
> > <html:html>
> > <HEAD></HEAD>
> > <BODY>
> > <html:errors/>
> > <TABLE>
> >     <html:form action="/login" method="post"
> > onsubmit="validateLoginForm(this)">
> >         <TR>
> >             <TD>Username:</TD>
> >             <TD><html:text property="userName" /></TD>
> >         </TR>
> >         <TR>
> >             <TD>Password:</TD>
> >             <TD><html:password property="password" /></TD>
> >         <TR>
> >             <TD>Submit</TD>
> >             <TD><html:submit value="Login"
> onclick="anotherValidateHere?()
> > "/></TD>
> >         </TR>
> >     </html:form>
> > <html:javascript formName="loginForm"/>
> > </BODY>
> > </html:html>
> >
> > Priya
> >
> > On 10/3/06, Ed Griebel <ed...@gmail.com> wrote:
> >
> > > In your form's onclick="validate()" method (or whatever it may be
> > > called in your case), it may work to add "return" to the javascript
> > > method call. The validate method will return false if validation
> > > fails, and the form will not be submitted back to the server.
> > >
> > > HTH,
> > > -ed
> > >
> > > On 10/3/06, priya <pr...@gmail.com> wrote:
> > > > I am using client-side and server-side validation in my login form.
> > > >
> > > > Both work and when I dont enter the required fields I recieve a
> > > javascript
> > > > alert box saying that the fields "username or password are
> required".
> > > After
> > > > I click okay it does a serverside validation as well and prints on
> the
> > >
> > > > screen that the "username or password are required"..
> > > >
> > > > I was wondering if its possible to show "username or password are
> > > required"
> > > > only once. When there is javascript enabled on the browser, to show
> > > the
> > > > client side version only and when javascript is disabled use the
> > > serverside
> > > > version?
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
>
>

Re: Avoiding multiple validation messages

Posted by Ed Griebel <ed...@gmail.com>.
Let me clarify, in your html:form statement, try adding a return like so:

<html:form action="/login" method="post" onsubmit="return
validateLoginForm(this)">

On 10/3/06, priya <pr...@gmail.com> wrote:
>
> Hi Ed,
>
> Thank you for your response!
> Since I am using Struts client side validation, I am not creating the
> validate method.. Struts is creating it for me..
> Do you mean I should create another method ? I am not sure if I can add
> return to the javascript which Struts creates for me?
>
> <%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>
> <%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>
> <html:html>
> <HEAD></HEAD>
> <BODY>
> <html:errors/>
> <TABLE>
>     <html:form action="/login" method="post"
> onsubmit="validateLoginForm(this)">
>         <TR>
>             <TD>Username:</TD>
>             <TD><html:text property="userName" /></TD>
>         </TR>
>         <TR>
>             <TD>Password:</TD>
>             <TD><html:password property="password" /></TD>
>         <TR>
>             <TD>Submit</TD>
>             <TD><html:submit value="Login" onclick="anotherValidateHere?()
> "/></TD>
>         </TR>
>     </html:form>
> <html:javascript formName="loginForm"/>
> </BODY>
> </html:html>
>
> Priya
>
> On 10/3/06, Ed Griebel <ed...@gmail.com> wrote:
>
> > In your form's onclick="validate()" method (or whatever it may be
> > called in your case), it may work to add "return" to the javascript
> > method call. The validate method will return false if validation
> > fails, and the form will not be submitted back to the server.
> >
> > HTH,
> > -ed
> >
> > On 10/3/06, priya <pr...@gmail.com> wrote:
> > > I am using client-side and server-side validation in my login form.
> > >
> > > Both work and when I dont enter the required fields I recieve a
> > javascript
> > > alert box saying that the fields "username or password are required".
> > After
> > > I click okay it does a serverside validation as well and prints on the
> >
> > > screen that the "username or password are required"..
> > >
> > > I was wondering if its possible to show "username or password are
> > required"
> > > only once. When there is javascript enabled on the browser, to show
> > the
> > > client side version only and when javascript is disabled use the
> > serverside
> > > version?
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>

Re: Avoiding multiple validation messages

Posted by Ed Griebel <ed...@gmail.com>.
In your form's onclick="validate()" method (or whatever it may be
called in your case), it may work to add "return" to the javascript
method call. The validate method will return false if validation
fails, and the form will not be submitted back to the server.

HTH,
-ed

On 10/3/06, priya <pr...@gmail.com> wrote:
> I am using client-side and server-side validation in my login form.
>
> Both work and when I dont enter the required fields I recieve a javascript
> alert box saying that the fields "username or password are required". After
> I click okay it does a serverside validation as well and prints on the
> screen that the "username or password are required"..
>
> I was wondering if its possible to show "username or password are required"
> only once. When there is javascript enabled on the browser, to show the
> client side version only and when javascript is disabled use the serverside
> version?
>
>

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