Re: JavaScript / AJAX + Struts 2?

2009-12-18 Thread Brian Thompson
On Fri, Dec 18, 2009 at 6:37 AM, Jim Collings wrote: > Here is the answer that I was provided & used: > > 1. You can use the ${somethingFromTheValueStack} notation like so: > > onclick="onjavaScriptMethod('${value}');" > > I tried this but missed the ' marks because it's been so long since I > di

Re: JavaScript / AJAX + Struts 2?

2009-12-18 Thread Jim Collings
Here is the answer that I was provided & used: 1. You can use the ${somethingFromTheValueStack} notation like so: onclick="onjavaScriptMethod('${value}');" I tried this but missed the ' marks because it's been so long since I did any JavaScript. I haven't tried this trick in an actual embedded s

Re: JavaScript / AJAX + Struts 2?

2009-12-17 Thread Brian Thompson
Thanks :) Oh, and to the OP ... my (somewhat sloppy) pseudocode is only one way to do it. You could also set up Ajax calls to get data in JSON format from the server. It's simpler to start out by writing javascript values for whatever you need from the value stack, though. -Brian On Thu, Dec

Re: JavaScript / AJAX + Struts 2?

2009-12-17 Thread dusty
I like how code is declared #fail because there probably is not a toString method. lawl. Please do not be distractedBrian's code was a perfectly good example. Brian Thompson-5 wrote: > > In context of the other two examples, you're right; I should have used > something like > > var foo

Re: JavaScript / AJAX + Struts 2?

2009-12-17 Thread Brian Thompson
In context of the other two examples, you're right; I should have used something like var foo = ; //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

Re: JavaScript / AJAX + Struts 2?

2009-12-17 Thread Paweł Wielgus
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

Re: JavaScript / AJAX + Struts 2?

2009-12-17 Thread Brian Thompson
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 "//st

Re: JavaScript / AJAX + Struts 2?

2009-12-17 Thread Paweł Wielgus
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 = ; //int, boolean, etc. will not work too. Best greetings, Paweł Wielgus. 2009/12/17 Brian Thompson : > Bwuh?  Just because your fridge doesn't have a buil

Re: JavaScript / AJAX + Struts 2?

2009-12-17 Thread Paweł Wielgus
Hi James, the code You have shown is generating java script on server side, and then on browser side you run it in browser. For example You can't do this: var myList = ''; myList.toUpperCase(); and expect that on server side inside action, zipCodes variable is updated with new uppereCased value. A

Re: JavaScript / AJAX + Struts 2?

2009-12-17 Thread Johannes Geppert
Hello Jim, if you like to use AJAX with struts2 take a look at the build in dojo plugin or to one of the other (jquery, yui) plugins you can found in the Plugin Registry. http://cwiki.apache.org/S2PLUGINS/home.html Best Regards Johannes Geppert jcllings wrote: > > So I have two actions and

Re: JavaScript / AJAX + Struts 2?

2009-12-17 Thread john feng
You can use the action to get data from server to display in the thru JS. e.g., in your jsp, user selects a dropdown element of country name, then it will get the state/province names data to be displayed in the . You can invoke an action for the dropdown value-change event to get the data back (s

Re: JavaScript / AJAX + Struts 2?

2009-12-17 Thread Brian Thompson
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: var foo = ; //int, bool

Re: JavaScript / AJAX + Struts 2?

2009-12-17 Thread james billa
Pawel, I am doing something like shown below and it works good for me. Isn't it calling the values from model/stack value from java script? zipCodes is in my model. Please tell me ur option. that would help me underst it better. I am using struts 2.1.6. Thanks. function showmylist() { var myL

Re: JavaScript / AJAX + Struts 2?

2009-12-17 Thread Jim Collings
So it's impossible? JavaScript and Struts 2 don't interact at all? What good is Struts 2 then? 2009/12/17 Paweł Wielgus : > 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

Re: JavaScript / AJAX + Struts 2?

2009-12-17 Thread Paweł Wielgus
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 : > So I have two actions an

JavaScript / AJAX + Struts 2?

2009-12-17 Thread Jim Collings
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 via a JavaScript method. Question: How do I get items off of the value stack for use in JavaScript? Jim C. - To