In context of the other two examples, you're right; I should have used something like
var foo = <s:property value="%{foo.foobar}"/>; //int, boolean, etc. instead to be more clear. The lack of quotes was deliberate, though ... you wouldn't want to quote a numeric value when you're setting it up that way. -Brian 2009/12/17 Paweł Wielgus <poulw...@gmail.com> > Hi Brian, > i din't notice that it is a continuation of comment, so You are wright. > As for first assignement, there are no ' or " chars around scriptlet > so it will not work because most probably there is no variable named > as the foo's toString value. > Second and third assignement has them an will work. > > Best greetings, > Pawel Wielgus. > > 2009/12/17, Brian Thompson <elephant...@gmail.com>: > > TBH, I just wrote it as a quick "off the top of my head" example. The > basic > > structure is sound, though -- I did that sort of thing all the time in my > > struts project earlier this year. What do you think is wrong with it? > > > > n.b. "foo.getBat()" does not belong on its own line - it's part of the > > "//string retrieved..." comment. > > > > -Brian > > > > > > > > 2009/12/17 Paweł Wielgus <poulw...@gmail.com> > > > >> Hi Brian, > >> have You tried running this code? > >> i have a doubt about: > >> foo.getBat() line. > >> As far as i know it will not work. > >> > >> Also line: > >> var foo = <s:property value="%{foo}"/>; //int, boolean, etc. > >> will not work too. > >> > >> Best greetings, > >> Paweł Wielgus. > >> > >> > >> 2009/12/17 Brian Thompson <elephant...@gmail.com>: > >> > Bwuh? Just because your fridge doesn't have a built-in toaster, it's > >> > worthless? > >> > > >> > Struts is helpful for stuff you'd want to do on the server side. > >> > > >> > An easy way to make stuff from the value stack available in javascript > >> > is > >> to > >> > do this in the jsp: > >> > > >> > <script type="text/javascript"> > >> > > >> > var foo = <s:property value="%{foo}"/>; //int, boolean, etc. > >> > var bar = '<s:property value="%{bar}"/>'; //string > >> > var bat = '<s:property value="%{foo.bat}"/>'; //string retrieved by > >> > foo.getBat() > >> > > >> > //javascript logic goes here > >> > > >> > </script> > >> > > >> > Hope that helps, > >> > > >> > -Brian > >> > > >> > On Thu, Dec 17, 2009 at 8:33 AM, Jim Collings <jlistn...@gmail.com> > >> wrote: > >> > > >> >> So it's impossible? JavaScript and Struts 2 don't interact at all? > >> >> What good is Struts 2 then? > >> >> > >> >> 2009/12/17 Paweł Wielgus <poulw...@gmail.com>: > >> >> > Hi Jim, > >> >> > action is on server side and javascript is on browser side, > >> >> > they don't interact, You can generate js server side but that's it. > >> >> > Js will be run in browser so it has no access to stack or action > >> >> variables. > >> >> > > >> >> > Best greetings, > >> >> > Paweł Wielgus. > >> >> > > >> >> > > >> >> > > >> >> > 2009/12/17 Jim Collings <jlistn...@gmail.com>: > >> >> >> So I have two actions and one jsp. The idea is that one is for > the > >> >> >> entire page and another is for putting into a <div> via a > JavaScript > >> >> >> method. > >> >> >> > >> >> >> Question: How do I get items off of the value stack for use in > >> >> JavaScript? > >> >> >> > >> >> >> > >> >> >> Jim C. > >> >> >> > >> >> >> > --------------------------------------------------------------------- > >> >> >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > >> >> >> For additional commands, e-mail: user-h...@struts.apache.org > >> >> >> > >> >> >> > >> >> > > >> >> > > --------------------------------------------------------------------- > >> >> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > >> >> > For additional commands, e-mail: user-h...@struts.apache.org > >> >> > > >> >> > > >> >> > >> >> --------------------------------------------------------------------- > >> >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > >> >> For additional commands, e-mail: user-h...@struts.apache.org > >> >> > >> >> > >> > > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > >> For additional commands, e-mail: user-h...@struts.apache.org > >> > >> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >