Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Re: Ajax - obtaining a method result

Musachy Barroso

2007-02-13

Replies:

If you are making the call using the anchor or submit tag in the ajax
theme, the returned text is available as a parameter(first parameter,
when "type" is load) to the "notifyTopics", see:

http://cwiki.apache.org/WW/ajax-tags.html

If you are going to use Dojo directly,:

dojo.io.bind({
       url: "/youraction",
       handler: function(type, data, e) {
        var id = data;
        //use your id
       },
       mimetype: "text/html"
     });

That's assuming you are going to return just the id in the response. You
can also returned a JSON string if you need to return more data. Or you
can (but it will hurt :) ) return xml, which I wouldn't recommend unless
you have to. If you happen to be using GWT, you can just return the int
from your method, and you will just get it back on your GWT(javascript)
code. These are just a few ideas, there's got to be zillion ways of
doing it these days.

musachy

Monttez wrote:
> Hi all
>
> I want to make an ajax call to a method and get its returning.. (for use
> in a javascript fragment)
>
>
> For example: I want to get the Id for the inserted person (in an ajax
> insert..)..
>
>
> How it is possible?
>
>
> This method could be in an action or directly in my Service class..
>
>
>
> Thanks in advance
>
> Luciano
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.