You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Stelios Togias <st...@gmail.com> on 2007/04/30 20:02:08 UTC

Ajax

Hi,

In the following code the children(${id}) function is called when you click
on the children button. Now ajax works ok and I get the correct results
back(I'm using prototype.js). My problem is that I want to use the <s:iterator
tag in order to iterate through the returned values. Is this possible or I
can't do it because <s:iterate is used to render the page and its not
available on the ajax call?

<table>
>     <tr>
>     <th>Id</th>
>     <th>First Name</th>
>     <th>Last Name</th>
>     </tr>
>     <s:iterator value="persons">
>     <tr id="${id}">
>         <td><s:property value="id"/></td>
>         <td><s:property value="firstName"/></td>
>         <td><s:property value="lastName"/></td>
>         <td><input type="button" onclick="children(${id})"
> value="children"/></td>
>     </tr>
>     <s:iterator id="result" value="children">
>     <tr>
>         <td><s:property value="id"/></td>
>         <td><s:property value="firstName"/></td>
>         <td><s:property value="lastName"/></td>
>     </tr>
>     </s:iterator>
>     </s:iterator>
> </table>


Thanks
stelios

Re: Ajax

Posted by Stelios Togias <st...@gmail.com>.
great, thanks for the help guys

On 30/04/07, Musachy Barroso <mu...@gmail.com> wrote:
>
> yes, that should work.
>
> musachy
>
> On 4/30/07, Stelios Togias <st...@gmail.com> wrote:
> >
> > yes but I can call an action that has as a result another jsp page, so I
> > can
> > use the iterator in that page and then fetch back the results and input
> > them
> > in the initial page(where the ajax call has been done from). At least
> > thats
> > what I'm trying now and it works, not exactly as I want yet but it seems
> > it
> > will.
> > does this make sense or am I talking nonsense?
> >
> > On 30/04/07, Musachy Barroso <mu...@gmail.com> wrote:
> > >
> > > I thought so too. In any case, you can use any Struts 2 on you JSP
> > pages,
> > > even if it is an ajax call, it doesn't matter to Struts. If what you
> are
> > > trying to use is the iterator tag on you javascript code, then no, the
> > > tags
> > > get executed when your page is rendered, on the *server*, while the
> > > response
> > > can be processes on the *client*.
> > >
> > > regards
> > > musachy
> > >
> > > On 4/30/07, Dave Newton <ne...@yahoo.com> wrote:
> > > >
> > > > --- Stelios Togias <st...@gmail.com> wrote:
> > > > >> You could make your Ajax call to a Struts Action
> > > > and
> > > > >> return the results of *that* if you wanted.
> > > > > Can you elaborate a bit more on this? The ajax call
> > > > > is calling a struts action already so I'm not sure I
> > > >
> > > > > understand you...
> > > >
> > > > Oh. Hrm.
> > > >
> > > > I guess I'm not sure what the problem is then; maybe
> > > > you could describe all the steps. I had assumed that
> > > > you were calling an S2 action and using the results of
> > > > the rendered JSP to set innerHTML or something
> > > > similar.
> > > >
> > > > d.
> > > >
> > > >
> > > > __________________________________________________
> > > > Do You Yahoo!?
> > > > Tired of spam?  Yahoo! Mail has the best spam protection around
> > > > http://mail.yahoo.com
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail: user-help@struts.apache.org
> > > >
> > > >
> > >
> > >
> > > --
> > > "Hey you! Would you help me to carry the stone?" Pink Floyd
> > >
> >
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>

Re: Ajax

Posted by Musachy Barroso <mu...@gmail.com>.
yes, that should work.

musachy

On 4/30/07, Stelios Togias <st...@gmail.com> wrote:
>
> yes but I can call an action that has as a result another jsp page, so I
> can
> use the iterator in that page and then fetch back the results and input
> them
> in the initial page(where the ajax call has been done from). At least
> thats
> what I'm trying now and it works, not exactly as I want yet but it seems
> it
> will.
> does this make sense or am I talking nonsense?
>
> On 30/04/07, Musachy Barroso <mu...@gmail.com> wrote:
> >
> > I thought so too. In any case, you can use any Struts 2 on you JSP
> pages,
> > even if it is an ajax call, it doesn't matter to Struts. If what you are
> > trying to use is the iterator tag on you javascript code, then no, the
> > tags
> > get executed when your page is rendered, on the *server*, while the
> > response
> > can be processes on the *client*.
> >
> > regards
> > musachy
> >
> > On 4/30/07, Dave Newton <ne...@yahoo.com> wrote:
> > >
> > > --- Stelios Togias <st...@gmail.com> wrote:
> > > >> You could make your Ajax call to a Struts Action
> > > and
> > > >> return the results of *that* if you wanted.
> > > > Can you elaborate a bit more on this? The ajax call
> > > > is calling a struts action already so I'm not sure I
> > >
> > > > understand you...
> > >
> > > Oh. Hrm.
> > >
> > > I guess I'm not sure what the problem is then; maybe
> > > you could describe all the steps. I had assumed that
> > > you were calling an S2 action and using the results of
> > > the rendered JSP to set innerHTML or something
> > > similar.
> > >
> > > d.
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam?  Yahoo! Mail has the best spam protection around
> > > http://mail.yahoo.com
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> >
> > --
> > "Hey you! Would you help me to carry the stone?" Pink Floyd
> >
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: Ajax

Posted by Stelios Togias <st...@gmail.com>.
yes but I can call an action that has as a result another jsp page, so I can
use the iterator in that page and then fetch back the results and input them
in the initial page(where the ajax call has been done from). At least thats
what I'm trying now and it works, not exactly as I want yet but it seems it
will.
does this make sense or am I talking nonsense?

On 30/04/07, Musachy Barroso <mu...@gmail.com> wrote:
>
> I thought so too. In any case, you can use any Struts 2 on you JSP pages,
> even if it is an ajax call, it doesn't matter to Struts. If what you are
> trying to use is the iterator tag on you javascript code, then no, the
> tags
> get executed when your page is rendered, on the *server*, while the
> response
> can be processes on the *client*.
>
> regards
> musachy
>
> On 4/30/07, Dave Newton <ne...@yahoo.com> wrote:
> >
> > --- Stelios Togias <st...@gmail.com> wrote:
> > >> You could make your Ajax call to a Struts Action
> > and
> > >> return the results of *that* if you wanted.
> > > Can you elaborate a bit more on this? The ajax call
> > > is calling a struts action already so I'm not sure I
> >
> > > understand you...
> >
> > Oh. Hrm.
> >
> > I guess I'm not sure what the problem is then; maybe
> > you could describe all the steps. I had assumed that
> > you were calling an S2 action and using the results of
> > the rendered JSP to set innerHTML or something
> > similar.
> >
> > d.
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>

Re: Ajax

Posted by Musachy Barroso <mu...@gmail.com>.
I thought so too. In any case, you can use any Struts 2 on you JSP pages,
even if it is an ajax call, it doesn't matter to Struts. If what you are
trying to use is the iterator tag on you javascript code, then no, the tags
get executed when your page is rendered, on the *server*, while the response
can be processes on the *client*.

regards
musachy

On 4/30/07, Dave Newton <ne...@yahoo.com> wrote:
>
> --- Stelios Togias <st...@gmail.com> wrote:
> >> You could make your Ajax call to a Struts Action
> and
> >> return the results of *that* if you wanted.
> > Can you elaborate a bit more on this? The ajax call
> > is calling a struts action already so I'm not sure I
>
> > understand you...
>
> Oh. Hrm.
>
> I guess I'm not sure what the problem is then; maybe
> you could describe all the steps. I had assumed that
> you were calling an S2 action and using the results of
> the rendered JSP to set innerHTML or something
> similar.
>
> d.
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: Ajax

Posted by Dave Newton <ne...@yahoo.com>.
--- Stelios Togias <st...@gmail.com> wrote:
>> You could make your Ajax call to a Struts Action
and
>> return the results of *that* if you wanted.
> Can you elaborate a bit more on this? The ajax call
> is calling a struts action already so I'm not sure I

> understand you...

Oh. Hrm.

I guess I'm not sure what the problem is then; maybe
you could describe all the steps. I had assumed that
you were calling an S2 action and using the results of
the rendered JSP to set innerHTML or something
similar.

d.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Ajax

Posted by Stelios Togias <st...@gmail.com>.
wow! that was quick!

You could make your Ajax call to a Struts Action and
> return the results of *that* if you wanted.


Can you elaborate a bit more on this? The ajax call is calling a struts
action already so I'm not sure I understand you...

thanks
stelios



On 30/04/07, Dave Newton <ne...@yahoo.com> wrote:
>
> --- Stelios Togias <st...@gmail.com> wrote:
> > My problem is that I want to use the
> <s:iterator.../>
> > tag in order to iterate through the returned values.
> > Is this possible or I can't do it because <s:iterate
>
> > is used to render the page and its not available on
> > the ajax call?
>
> If you are getting back text or JavaScript values from
> a Prototype Ajax call then <s:iterator.../> won't
> work: JSP tags execute on the server side, not the
> client side.
>
> You could make your Ajax call to a Struts Action and
> return the results of *that* if you wanted.
>
> d.
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Ajax

Posted by Dave Newton <ne...@yahoo.com>.
--- Stelios Togias <st...@gmail.com> wrote:
> My problem is that I want to use the
<s:iterator.../>
> tag in order to iterate through the returned values.
> Is this possible or I can't do it because <s:iterate

> is used to render the page and its not available on 
> the ajax call?

If you are getting back text or JavaScript values from
a Prototype Ajax call then <s:iterator.../> won't
work: JSP tags execute on the server side, not the
client side.

You could make your Ajax call to a Struts Action and
return the results of *that* if you wanted.

d.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org