struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Lister <alis...@MIT.EDU>
Subject Re: Struts2+YUI
Date Fri, 17 Oct 2008 16:43:29 GMT
I am not a YUI guy, but I'm assuming YUI is expecting a javascript array 
of string. What does your struts.xml look like?  What have you defined 
for the SUCCESS result?  Is it a jsp?  If it is a jsp, you should make 
the jsp write out the array as YUI is expecting it.  The jsp will have 
access to what is in your action via the standard struts tags. Another 
option is to use a stream result and stream the javascript fragment 
directly from the action class.  Ultimately your action must probably 
produce something like ["foo", "bar", "whatever"] as it's response.  You 
can test this by first hitting the action directly with your browser.

aum strut wrote:
> HI All,
>
> DO any one have any clue about this probelm.......???
>
> i am really stuck here.....
>
> On Thu, Oct 16, 2008 at 3:33 PM, shekher awasthi
> <shekher.awasthi@gmail.com>wrote:
>
>   
>> Hi All,
>>
>> I am trying to integrate struts2 with YUI ,but facing some problems with
>> this. I want that when my action get called by YUI it must return a
>> arrayList of string which i must be able to handle using the YUI.
>>
>> For this i took the help of example from YUI site and able to hit the
>> action
>> but my problem is that how can i get the access to the arraylist which my
>> action is populating when its execute methos is called .below i m pasting
>> the code from my action calss as well as the YUI code.
>> Plaese let me know how can i get this arraylist in my YUI code
>> *
>> YUI CODE*
>>
>> <div id="container"></div>
>> <script type="text/javascript" language="javascript">
>>
>>    var div = document.getElementById('container');
>>
>>    var handleSuccess = function(o){
>>    alert("pass");
>>
>>
>>    if(o.responseText !== undefined){
>>        alert("test11");
>>
>>        div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
>>        div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
>>        div.innerHTML += "<li>Status code message: " + o.statusText +
>> "</li>";
>>        div.innerHTML += "<li>HTTP headers: <ul>" + o.getAllResponseHeaders
>> + "</ul></li>";
>>        div.innerHTML += "<li>Server response: " + o.getList().toString +
>> "</li>";
>>        div.innerHTML += "<li>Argument object: Object ( [foo] => " +
>> o.argument.foo +
>>                         " [bar] => " + o.argument.bar +" )</li>";
>>    }
>>
>>
>> }
>>
>> var handleFailure = function(o){
>>        alert("fail");
>>        YAHOO.log("The failure handler was called.  tId: " + o.tId + ".",
>> "info", "example");
>>
>>    if(o.responseText !== undefined){
>>        div.innerHTML = "<ul><li>Transaction id: " + o.tId + "</li>";
>>        div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
>>        div.innerHTML += "<li>Status code message: " + o.statusText +
>> "</li></ul>";
>>    }
>> }
>>
>> var callback =
>> {
>>  success:handleSuccess,
>>  failure:handleFailure,
>>  argument: { foo:"foo", bar:"bar" }
>> };
>>
>> var sUrl = "YUITestAction.action";
>>
>>
>>
>>    function makeRequest(){
>>    alert("test");
>>
>>    var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
>>
>>
>>
>> }
>>    </script>
>>
>> *MY ACTION CLASS*
>>
>> public class YUITestAction extends ActionSupport{
>>
>>    /**
>>     *
>>     */
>>    private static final long serialVersionUID = 1926031204500756104L;
>>    ArrayList<String> list=new ArrayList<String>();
>>    public String execute() throws Exception{
>>        System.out.println("inside the execute method");
>>
>>        return SUCCESS;
>>    }
>>
>>    public ArrayList<String> getList(){
>>
>>        list.add("test1");
>>        list.add("test2");
>>        list.add("aum");
>>        list.add("arun");
>>        list.add("mannu");
>>        list.add("umesh");
>>
>>        return list;
>>    }
>> }
>>
>> any help in this regard is much appricaited
>>
>> --shekher
>>
>>     
>
>   

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


Mime
View raw message