struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nauke. <nau...@gmail.com>
Subject Re: ApplicationResources.properties and JavaScript
Date Thu, 07 Aug 2008 23:36:37 GMT
Hi Owen,

Thanks for your reply.
I think I did try that.
The only solution I have found to work was to do this:

Application.properties:
my.message=Hi There!

myJSPFile.jsp:
<input type="hidden" name="myMessage" value="my.message"/>

myJSFile.js
var msg = document.myform.myMessage.value;
alert(msg);

The deadline is today so I'll have to do what works so far :(((

Thanks heaps to all for trying to help.
There must be a more elegant solution than this!

Cheers

On Fri, Aug 8, 2008 at 8:58 AM, Owen Berry <owen.berry@gmail.com> wrote:

> In your jsp code set a variable to be the value you want, as shown
> earlier in this thread by Balwinder, and then read that variable in
> your Javascript code. If you're using OO javascript, you can make it
> nice and tidy by passing the parameter in your "constructor", or set
> it in a method. Example:
>
> var obj = new FancyObject('<bean:message key="app.mykey"
> bundle="MESSAGE">');
> // -- or --
> obj.setSomeValue('<bean:message key="app.mykey" bundle="MESSAGE">');
>
> Make sense?
>
> On Thu, Aug 7, 2008 at 7:03 PM, nauke. <nauke0@gmail.com> wrote:
> > Thanks for that.
> > I think that only works if the javascript is within the JSP file right?
> > My javascript functions are in it's on .js file ...
> >
> > On Thu, Aug 7, 2008 at 8:23 PM, Balwinder <balwinderk@saigun.com> wrote:
> >
> >> nauke. wrote:
> >>
> >>> Hi all,
> >>>
> >>> Is there a way to access values in ApplicationResources.properties in
> >>> Javascript functions?
> >>> I've found a way where I can just pass a value from the app resource
> file
> >>> as
> >>> a parameter, but discovered that I return alerts with different
> messages
> >>> based on some criteria.
> >>>
> >>> Any ideas?
> >>>
> >>> Thanks heaps
> >>>
> >>>
> >>>
> >> Try this
> >> <script>
> >> var someVar = '<bean:message key="app.mykey" bundle="MESSAGE">';
> >> </script>
> >>
> >>
> >> hope this will serve the purpose.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message