struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gundersen, Richard" <Richard.Gunder...@london-scottish.com>
Subject RE: 2 Validation questions
Date Wed, 06 Aug 2008 08:15:11 GMT
Thanks for the reply Jeromy, appreciate all the extra info you've given
me. It's the client side validation by the way, so I'll go down the
controlHeader.ftl route and see how I get on.

Someone else (Gabriel) mentioned a Javascript bug, so I think you're
right. I'll check out the relevant code when I get chance

Thanks again

Richard Gundersen
Java Developer
 
Email: richard.gundersen@london-scottish.com
Phone: 01618302398
Fax: 01618342536
London Scottish Bank plc
24 Mount Street
Manchester
M2 3LS

-----Original Message-----
From: Jeromy Evans [mailto:jeromy.evans@blueskyminds.com.au] 
Sent: Wednesday, August 06, 2008 8:28 AM
To: Struts Users Mailing List
Subject: Re: 2 Validation questions

Gundersen, Richard wrote:
> Hi
>
> Basic question sorry (looked all over but can't find the answer)
>
> 1) When validation fails for my 'username' textfield, the error
message
> is displayed ABOVE the text box. 
>
> Is it possible to have more fine-grained control over how to position
> the error message. Ideally I would like it below (and in line with)
the
> text box.
>
> 2) If I enter an invalid value twice, the original message is still
> there, so I have two 'username is invalid' messages on the screen now.
I
> know this is done by the javascript so I want to know the recommended
> way of overriding this behaviour.
>
> Thanks
>   

I presume you're referring purely to client-side validation.

Struts2 includes a javascript file validation.js that includes most of 
the logic.  It contains a simple for-loop that searches for the location

to insert each validation message relative to the input.  I think you'll

need to create your own version of validation.js that changes this 
search algorithm.

The templates for the tags dictate the location of the validation 
messages (divs or table cells).  The controlHeader.ftl file imported by 
all tags will need to be updated to the structure you prefer (ie. to 
include the relevant div after the input).  See the struts2 documents on

creating a custom template.

You may also need to edit the form.ftl file, or whatever, to make it 
import your validation.js file instead of the default.

#2 sounds like a bug in validation.js.  I recall there is logic in there

to detect if a validation message is already present and not show it 
again. It was buggy and may only be fixed in 2.1.x.

If you're referring to server side validation, the repeated message 
indicates the list of errors is not being cleared between invocations of

the same each, which implies to action is validated twice for the same 
request or a new instance is not being created for each request (which 
is bad, and only possible if you're using spring and have incorrect 
spring config).

Hope that helps,
Jeromy Evans





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


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

As a responsible corporate citizen, London Scottish Bank plc asks you to consider the environment
before printing this email.

*** Disclaimer *** 

This electronic communication is confidential and for the exclusive use of the addressee.
It may contain private and confidential information. The information, attachments and opinions
contained in this E-mail are those of its author only and do not necessarily represent those
of London Scottish Bank PLC or any other members of the London Scottish Group. 

If you are not the intended addressee, you are prohibited from any disclosure, distribution
or further copying or use of this communication or the information in it or taking any action
in reliance on it. If you have received this communication in error please notify the Information
Security Manager at ISM@London-Scottish.com as soon as possible and delete the message from
all places in your computer where it is stored. 

We utilise virus scanning software but we cannot guarantee the security of electronic communications
and you are advised to check any attachments for viruses. We do not accept liability for any
loss resulting from any corruption or alteration of data or importation of any virus as a
result of receiving this electronic communication. 

Replies to this E-mail may be monitored for operational or business reasons. London Scottish
Bank PLC is regulated by the Financial Services Authority.


London Scottish Bank plc, Registered Office: 201 Deansgate, Manchester M3 3NW Registered Number
973008 England.

Subsidiary Companies:-

London Scottish Finance Limited, Registered Office: 201 Deansgate, Manchester M3 3NW Registered
Number 233259 England.

London Scottish Broking Limited, Registered Office: 201 Deansgate, Manchester M3 3NW Registered
Number 230110 England.

London Scottish Invoice Finance Limited, Registered Office: 201 Deansgate, Manchester M3 3NW
Registered Number 2643766 England.

Robinson Way & Company Limited, Registered Office: 201 Deansgate, Manchester M3 3NW Registered
Number 885896 England.

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.

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


Mime
View raw message