Solved

Struts and external javascript files

Posted on 2003-11-11
5
791 Views
Last Modified: 2012-05-04
Hi,

I use the Struts 1.1 Framework and I want to use external javascript files to validate my forms.
But the files depend on the Locale of the Web browser. If it's ES --> src="js/es/myfile.js" and if it's US --> src="js/us/myfile.js"
Unfortunately there is no tag "srckey" with Struts 1.1.

Any suggestions ?

Thanks a lot in advance,

Highlander1536
0
Comment
Question by:highlander1536
5 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 9724661
You can get the Locale of the user out of the HTTP headers...

http://www.w3.org/International/questions/qa-accept-lang-locales.html

What does:

<%
  String bigLoc = request.getHeader( "accept-language" ) ;
  out.println( "<b>" + bigLoc + "</b>" ) ;
  if( bigLoc != null && bigLoc.length() > 2 )
    bigLoc = bigLoc.substring( 0, 2 ) ;
  out.println( "<tt>" + bigLoc + "</tt>" ) ;
%>

give you?
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9728335
In struts, you should be using Action.getLocale() to get client's current locale. Based on current local, you should try to see if the a js file exists, if not you should fall back to default js file.

Let us know if you have further enquires.
0
 
LVL 2

Accepted Solution

by:
DidierD earned 125 total points
ID: 9762134
You can use the Struts Validator for this.
In validation.xml you can define a locale specific formSet. For example
<form name="loginForm" locale="fr" country="CA">

There are already some basic validators available. The mask can be very usefull. But you can also add your own (Javascript) to the validator-rules.xml.

For more information about this see http://jakarta.apache.org/struts/userGuide/dev_validator.html
0
 

Author Comment

by:highlander1536
ID: 9762420
OK, thanks a lot.
Last question : do you know where I can download some usefull validator-rules.xml ?
0
 
LVL 2

Expert Comment

by:DidierD
ID: 9762540
Thanks for the points :)

If you look in the validator-rules.xml that comes with Struts validator, you see that there are already basic validators in it. These should help you, to create your own validators. Basic validators are required, mask, range, maxLength, minLength, date, creditCard, email, byte, short, integer, long, float, double.
I don't know where you can download other examples.

Hope this helps.

Greetz,
Didier

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article outlines the process to identify and resolve account lockout in an Active Directory environment.
Each year, investment in cloud platforms grows more than 20% (https://www.immun.io/hubfs/Immunio_2016/Content/Marketing/Cloud-Security-Report-2016.pdf?submissionGuid=a8d80a00-6fee-4b85-81db-a4e28f681762) as an increasing number of companies begin to…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question