• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Alerts

 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I am using struts application. I had all Field Names configured in an message-resources file. So i can support internationalizaion. My problem i show all the error messages in an Javascript alert box. For example front end validations at client side. Since i cant access the message resources in javascript i am hardcoding it. So, is there anyway out so that i can change the alert messages in javascript based on locale.

Thanks in advance.

Regards,
Arul.
 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You just can't do that in Javascript (unless you use Ajax and request messages from the server). Once the HTML Response is flushed to the client you can't have javascript access the resource bundle (Javascript is meant for client side & resource bundles are at server side). . Here is how you can solve this issue.
- Have Javascript generated through JSP. You populate the messages from resource bundle into a javascript array through JSP.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Struts validation framework client-side validation solves this problem by generating the JavaScript code dynamically at runtime. That way the message keys are evaluated to the locale of the current user.

You may want to look into using the Struts Validation Framework for your validation.
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Merrill,
Is there a URL which explains about the client-side validation. I didn't pay too much attention after seeing that javascript are embedded at using CDATA section. I am looking for sort of simple example. Thanks
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Purushothaman,

Sorry it took me a while to respond. This thread kind of got lost in the shuffle.

In answer to your question, this link has a good, simple example of Struts client-side validation.
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Merrill, I will take a look, haven't tried client side validation till this day.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic