Link to home
Start Free TrialLog in
Avatar of ldbkutty
ldbkuttyFlag for India

asked on

struts+javascript alert/confirm i18n texts

I include an external JS file for my struts JSP.

How i can specify <bean:message key="blah.blah"/> (Application Resources messages) for my JS alert and confirm Texts !?

At present, i have only direct german messages in the alert JS function. However if my project is internationalized, i will need english texts there.

Should i pass the <bean:message key="blah.blah"/> as arugument for the JS function i am calling from my JSP !? If yes, please tell me how it should be ?

Thanks.
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

can't you simply do:

  myFunction( <bean:message key="blah.blah"/> ) ;

or doesn't that work?
Sorry:

  myFunction( '<bean:message key="blah.blah"/>' ) ;

Otherwise, you can do:

<%
   ResourceBundle bundle = ResourceBundle.getBundle( "ApplicationResources" ) ;
%>

then;

  ...
  myFunction( '<%= bundle.getString( "blah.blah" ) %>' ) ;

(I think)
ASKER CERTIFIED SOLUTION
Avatar of sbockelman
sbockelman

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ldbkutty

ASKER

Problem is my JS is an external file, so i cannot use the <bean:message....> directly into the file.

sbockelman,
could you please explain me more ?
>  Problem is my JS is an external file, so i cannot use the <bean:message....> directly into the file.

But surely you can call it with <bean:message tags in the function calls?
yes, i can call with function calls, but just thinking if there is a way to put <bean:message > directly in the JS

If it is not possible, i have to go with function calls.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
:-)  It's a really cool way of doing it :-)

I just had to give it a go, to see if it would work right ;-)  

Tim

PS:  The CAPITALS idea is a really good one :-)