Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Struts and external javascript files

Posted on 2003-11-11
5
Medium Priority
?
800 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 375 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Geo-targeting is the practice of distributing content based on a person’s location, as best as you can determine it. Let’s look at some ways you could successfully use this tactic. The following tips and case studies could lead to meaningful results.
Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

610 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