1. #1
    Ext User
    Join Date
    Nov 2007
    Posts
    3
    Vote Rating
    0
    Axel is on a distinguished road

      0  

    Lightbulb DwrProxy

    DwrProxy


    Hello all,

    Here is a DwrProxy that works better than anything else currently out there on the forums.

    Differences to the other ones:
    -NO use of global objects
    -properly passes a variable number of arguments
    -proper error handling
    -fires events

    Code:
    Ext.data.DWRProxy = function (f) {
    	Ext.data.DWRProxy.superclass.constructor.call(this);
    	this.func = f;
    };
    
    Ext.extend(Ext.data.DWRProxy, Ext.data.DataProxy, {
    	load : function(params, reader, loadCallback, scope, arg) {
    		var dataProxy = this;
    		dataProxy.fireEvent("beforeload", dataProxy, params);
    		var args = [];
    		for (var param in params) {
    			args[args.length] = params[param];
    		}
    		args[args.length] = {
    			callback: function(response) {
    				dataProxy.fireEvent("load", dataProxy, response, loadCallback);
    				var records = reader.read(response);
    		        loadCallback.call(scope, records, arg, true);
    			},
      			exceptionHandler: function(message) {
    		    	dataProxy.fireEvent("loadexception", dataProxy, response, loadCallback, e);
    		        loadCallback.call(scope, null, arg, false);
    		    }
    		};
    		
    		this.func.apply(this, args);
    	}
    });
    Cheers,
    Axel

  2. #2
    Ext User
    Join Date
    Dec 2007
    Posts
    1
    Vote Rating
    0
    adamsherman is on a distinguished road

      0  

    Question Examples?

    Examples?


    Do you happen to have some basic code that shows the arrangement of Reader/Proxy/View, particularly how to handle committing changes to data? I'm just starting with Ext & DWR and that would be a huge help.

    A.

  3. #3
    Ext User
    Join Date
    Nov 2007
    Posts
    3
    Vote Rating
    0
    Axel is on a distinguished road

      0  

    Default Example Code

    Example Code


    Hello,

    Here is some example code to create a ComboBox:

    Code:
    var store = new Ext.data.Store({
    	proxy: new Ext.data.DWRProxy(MyDwrJS.myMethod),
    	reader: new Ext.data.MapReader()
    });
    		
    var comboExt = new Ext.form.ComboBox({
    	transform: 'myField',
    	displayField: 'value',
    	valueField: 'key',
    	store: store
    });
    It is uses a MapReader I posted an other thread.

    The java code method takes one param (the text currently in the combo) and returns a map<String elementValue, String elementLabel>. The selected value is then sent together with the form on post.

    Cheers,
    Axel

  4. #4
    Ext User
    Join Date
    Dec 2007
    Posts
    2
    Vote Rating
    0
    vashah is on a distinguished road

      0  

    Question Not working for me

    Not working for me


    Hi,

    I am a newbie with Ext. I have tried using DWRProxy + Map reader combination for my ComboBox. Here's the code:
    Code:
    var mapDs = new Ext.data.Store({
    	proxy: new   Ext.ux.data.DWRProxy(this.serverInterface.getPossibleBusinessGroups),
    	reader: new Ext.ux.data.MapReader(),
    	baseParams: {
    			launchIdentifier: this.launchIdentifier
    			}
    	});
    var comboExt = new Ext.form.ComboBox({		
    			fieldLabel: 'Business Group',
    			displayField: 'value',
    			valueField: 'key',
    			store: mapDs
    		});
    DWR works as intented and returns me a map of possible business groups but the combo box hangs in the "Loading..." state.

    Help appreciated. Thanks,
    Vivek
    Last edited by mystix; 1 Jan 2008 at 8:31 PM. Reason: use [code][/code] tags

  5. #5
    Ext User
    Join Date
    Dec 2007
    Posts
    3
    Vote Rating
    0
    davewolfs is on a distinguished road

      0  

    Default


    Could someone please explain in more detail what this code is doing.

    I am finding code such as Ext.data.DWRProxy.superclass.constructor.call(this) kinda hard to follow.

    I assume that this is how Ext is extended? Perhaps some of you could chime in on exactly what this proxy is doing.

    Thanks,

    Dave

  6. #6
    Ext User
    Join Date
    Nov 2007
    Posts
    3
    Vote Rating
    0
    qaz is on a distinguished road

      0  

    Default Can some one, create one example, with one form work with dwr 2.0.2, with code?

    Can some one, create one example, with one form work with dwr 2.0.2, with code?


    Can some one, create one example, with one form work with dwr 2.0.2, with code?

    one example with a table, sould be nice too.

  7. #7
    Sencha User Juvs's Avatar
    Join Date
    Oct 2007
    Posts
    33
    Vote Rating
    0
    Juvs is on a distinguished road

      0  

    Default Fix to DWRProxy

    Fix to DWRProxy


    Something I notice when using the extension, when you pass an object as parameter the actual code interact into the attributes of the object and creates an array with the attributes not with the object it self, so I did the next modification:

    Code:
    Ext.data.DWRProxy = function (f) {
    	Ext.data.DWRProxy.superclass.constructor.call(this);
    	this.func = f;
    };
    
    Ext.extend(Ext.data.DWRProxy, Ext.data.DataProxy, {
    	load : function(params, reader, loadCallback, scope, arg) {
    		var dataProxy = this;
    		dataProxy.fireEvent("beforeload", dataProxy, params);
    		var args = [];
    		if (typeof(params) == 'Array') {
    			for (var param in params) {
    				args[args.length] = params[param];
    			}
    		} else {
    			args[args.length] = params;
    		}	
    		args[args.length] = {
    			callback: function(response) {
    				dataProxy.fireEvent("load", dataProxy, response, loadCallback);
    				var records = reader.read(response);
    		        loadCallback.call(scope, records, arg, true);
    			},
      			exceptionHandler: function(message) {
    		    	dataProxy.fireEvent("loadexception", dataProxy, response, loadCallback, e);
    		        loadCallback.call(scope, null, arg, false);
    		    }
    		};
    		
    		this.func.apply(this, args);
    	}
    });
    When this situation comes out, well, lets say you have a Java Object on the server that receives an object as parameter:

    Code:
    public class CustomerService extends Service {
    
    	//more methods...
    	//...
    
    	public IResponse getAllCustomers(GridPagedRequest pagedRequest) {
    		//some code here....
    		return response;		
    	}
    }
    The parameter object:

    Code:
    public class GridPagedRequest implements Serializable {
    	private int start;
    	private int limit;
    	
    	public int getLimit() {
    		return limit;
    	}
    	public void setLimit(int limit) {
    		this.limit = limit;
    	}
    	public int getStart() {
    		return start;
    	}
    	public void setStart(int start) {
    		this.start = start;
    	}
    }
    Then in the client (javascript) I defined a DataStore as follows:

    Code:
       // create the Data Store
       this.ds = new Ext.data.Store({
            proxy: new Ext.data.DWRProxy(CustomerService.getAllCustomers), //Here is the DWR Object call
    	reader: new Ext.data.MapReader()
       });
    and load the datastore:

    Code:
    this.ds.load({
    	params: {start: 0, limit: 15}
    });
    Before the modification I always get an error on the server, because the DWRProxy creates an array with two values, start and limit, and the server object expects to get an object with two attributes, not two parameters.

    In case you need to pass this two parameters, the only change you have to do is:

    Code:
    public class CustomerService extends Service {
    
    	//more methods...
    	//...
    
    	public IResponse getAllCustomers(int start, int limit) { //Now, is two parameters
    		//some code here....
    		return response;		
    	}
    }
    and

    Code:
    this.ds.load({
    	params: [0,15]
    });

    I hope this help...

  8. #8
    Ext User
    Join Date
    Nov 2007
    Location
    Harrisburg, PA
    Posts
    9
    Vote Rating
    0
    benjam72 is on a distinguished road

      0  

    Default


    Thanks Juvs, that helps to illuminate how to pass parameters to the Java class and ensuring the correct data type. However, one of the things I still don't understand is where the callback function is defined, when it's passed to DWRProxy, and when it's invoked. Can you help me out?

  9. #9
    Sencha User TheItalianJob's Avatar
    Join Date
    Jan 2008
    Location
    Rome (Italy)
    Posts
    79
    Vote Rating
    0
    TheItalianJob is on a distinguished road

      0  

    Wink


    Hello Axel,

    i'm a newbie in extjs, can you write for our the complete code of this class?

    What is the structure of the object IResponse?

    Code:
     
    public class CustomerService extends Service {
     
    //more methods...
    //...
     
    public IResponse getAllCustomers(GridPagedRequest pagedRequest) {
    //some code here....
    return response; 
    }
    }

    Thanks a lot!

  10. #10
    Ext User hatchetman82's Avatar
    Join Date
    Jan 2008
    Posts
    13
    Vote Rating
    0
    hatchetman82 is on a distinguished road

      0  

    Default shouldnt beforeLoad be vetoable ?

    shouldnt beforeLoad be vetoable ?


    When you're firing the "beforeLoad" event, shouldnt you make the event "vetoable" ?
    (as in, a negative return value from firing the event should abort the process)

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar