struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Thompson <elephant...@gmail.com>
Subject Re: JavaScript / AJAX + Struts 2?
Date Thu, 17 Dec 2009 14:38:26 GMT
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 <jlistnews@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 <poulwiel@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 <jlistnews@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-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
> >
> >
>
> ---------------------------------------------------------------------
> 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