ldbkutty
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.
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.
Sorry:
myFunction( '<bean:message key="blah.blah"/>' ) ;
Otherwise, you can do:
<%
ResourceBundle bundle = ResourceBundle.getBundle( "ApplicationResources" ) ;
%>
then;
...
myFunction( '<%= bundle.getString( "blah.blah" ) %>' ) ;
(I think)
myFunction( '<bean:message key="blah.blah"/>' ) ;
Otherwise, you can do:
<%
ResourceBundle bundle = ResourceBundle.getBundle( "ApplicationResources" ) ;
%>
then;
...
myFunction( '<%= bundle.getString( "blah.blah" ) %>' ) ;
(I think)
Maybe the follow ups of this Q are useful: http://www.mail-archive.com/struts-user@jakarta.apache.org/msg01956.html
(Especially http://www.mail-archive.com/struts-user@jakarta.apache.org/msg01981.html)
(Especially http://www.mail-archive.com/struts-user@jakarta.apache.org/msg01981.html)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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 ?
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?
But surely you can call it with <bean:message tags in the function calls?
ASKER
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.
If it is not possible, i have to go with function calls.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:-) 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 :-)
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 :-)
myFunction( <bean:message key="blah.blah"/> ) ;
or doesn't that work?