retrive results from javascript

Hello, I’m having some problems with a JQuery component that I added to my project, It’s almost working but I haven’t been able to retrieve an array of a method on the javascript. I was trying to find some example of how to do it but I couldn’t find anything, so I did this:

The component is a simple div with the ‘Sortable’ widget called SortableView. Im catching the events and calling the methods I need.

So basically what I did was to create a the method
on my javascript
and added a ‘event’ called
on my AbstractJavaScriptComponent:


  $(function() {

        getArray = function(id, info) { 
            //console.log("*********currentSelf:" + );

        viewMod = function(info) {
            //console.log("*********currentSelf:" + );


 this.conArray = function(id) {
     var array = $("#" + id + "").sortable("toArray");

public class SortableView extends AbstractJavaScriptComponent {

this.addFunction(“triggerGetArray”, new JavaScriptFunction(){

        public void call(JSONArray arguments) throws JSONException {        
            System.out.println( "id:" +  getViewId() + " ls2:"+ sortArraylistener.size()+ "  array:" + arguments.toString() );             
            for( SortArrayListener ls2 : sortArraylistener){

public void getArray(){
this.callFunction(“conArray”, this.getViewId());
I have two SortableView:

SortableView  svCatalog = new SortableView ("gCatalog") //Items on the db.
svCatalog.addOnSortArrayListener(  return new SortArrayListener(){
                private static final long serialVersionUID = -8212235728223500129L;

                public void handleAction(Object sender, Object target) {


                public void sortArrayReceived(JSONArray a) {
          "JSON recived", Notification.Type.TRAY_NOTIFICATION);

SortableView svSearch = new SortableView ("gSearch") //searchResults;

if a get the array without any changes on the
, the svCatalog works fine:

tomcat console: id:gCatalog ls2:1 array:[[{ … }]
] //all values are correct

but after a do a search then this is what I get when I get the array:

tomcat console: id:gSearch ls2:0 array:[[{ … }]

the id of the component is
0 listeners
, even when I call

Im guessing its because of the
scoope of ‘this’
on my javascript, changes to the component ‘gSearch’,

So my questions are two:

  1. The way Im using to retrieve the results of the .toArray(), Its OK? or there are other more correct method?, If so, where I can see examples.

  2. If this is OK, how do I
    to the method I use to get the getArray, I did it with the event on
    but I dont know if I can do the same thing with a method.

    $(“#” + id + “”).bind(‘sortchange’, function(e, ui) {
    viewMod(‘some info…’);

Thanks in advance.