Solved

Struts and external javascript files

Posted on 2003-11-11
5
788 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
JSP Popup page 2 95
rebasing and merging used in SCM 1 63
maven project in eclipse 11 57
Coldfusion 10 - JSP File Not Found - 404 Error 5 75
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now