Results 1 to 10 of 11

Thread: replace protocol in geoext.form.formpanel??

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    42
    Vote Rating
    0
      0  

    Default replace protocol in geoext.form.formpanel??

    Hi all,

    I've been scratching my head over this and I'm wondering if this is possible. I want to replace the protocol of the GeoExt.form.FormPanel in the following way:

    1. to render the formpanel, I defined a variable "proto" as null outside the formpanel (var proto = null).
    2. then "proto" goes inside the formpanel (protocol: proto).
    3. in the handler function of the button a new variable "proto" is defined. I want to replace this new variable inside the formpanel.

    Since extjs, geoext, openlayers are javascript libraries, I've tried things such as "eval" to make the variable "proto" inside the handler accessible in the formpanel but no luck so far. Here it is a simplified example to show this:

    Code:
    var proto = null;
    
    var formPanel = new GeoExt.form.FormPanel({
        protocol: proto,                # <--- replace with [1]
        items: [{
            xtype: "combo",
            id: "idcombo",
            etc...
        }, {
            xtype: "textfield",
            id: "idtext",
            etc...
        }],
        button:[{
            text: "search",
            handler: function() {
                formPanel.search();
                var combo = Ext.getCmp('idcombo').getValue();      # <--- this works and gets the value chosen in "xtype: combo"
                var proto: new OpenLayers.Protocol.HTTP({          # <--- [1] (ie. new variable "proto")
                    url: "http://www.pub.pub/" + combo + "/somestuff/",    # <--- this works
                    format: etc...
                })
            }
        }]
    })
    how could I do this? I'll appreciate your support, thanks in advance.

    Best regards,

    Gery

  2. #2
    Sencha User
    Join Date
    Jan 2011
    Posts
    549
    Vote Rating
    54
      0  

    Default

    If I'm understanding the problem correctly, surely all you would need to do is:
    Code:
    var p = new OpenLayers.Protocol.HTTP({ //CONFIG HERE});
    formPanel.protocol = p;

  3. #3
    Sencha User
    Join Date
    Jun 2012
    Posts
    42
    Vote Rating
    0
      0  

    Default

    Thank you willigogs for the idea, I tried it but I'm getting this error:

    Code:
    TypeError: o.protocol is null
    and it points to the SearchAction.js (line 122).

    I'm sure this is because
    Code:
    var proto = null;
    defined outside the formPanel. I read that SearchAction.js but don't get what is the problem to replace the protocol.

  4. #4
    Sencha User
    Join Date
    Jan 2011
    Posts
    549
    Vote Rating
    54
      0  

    Default

    I have never used GeoExt, so I'm completely guessing here - but could the fact that you are calling formPanel.search() before populating the protocol be a problem?

  5. #5
    Sencha User
    Join Date
    Jun 2012
    Posts
    42
    Vote Rating
    0
      0  

    Default

    yeah in fact that could be the problem, how could I solve that? in the handler putting formPanel.search() after var proto doesn't solve the problem btw
    Last edited by Gery; 15 Jan 2013 at 10:09 AM. Reason: http://www.sencha.com/forum/newreply.php?p=929518&noquote=1

  6. #6
    Sencha User
    Join Date
    Jan 2011
    Posts
    549
    Vote Rating
    54
      0  

    Default

    I would recommend some basic debugging to see what is / is not getting set.

    Something like:
    Code:
    button:[{
    	text: "search",
    	handler: function() {
    	    
    	    console.log(formPanel)
    	    console.log(formPanel.protocol)
    	    
    	    var combo = Ext.getCmp('idcombo').getValue();
    	    var proto = new OpenLayers.Protocol.HTTP({
    	        url: "http://www.pub.pub/" + combo + "/somestuff/"
    	    });
    	    
    	    formPanel.protocol = proto;
    	    console.log(formPanel.protocol)
    	    	
    	    formPanel.search();
    	    
    	}
    }]
    If everything is being set as expected, but the formPanel.search() function is still failing, then double check that this is successful if hardcoded into the protocol to begin with.

    The only other option I would investigate before searching for someone with specific GeoExt assistance, would be to see if destroying and re-instantiating the form (with the correct protocol assigned) would be a possibility.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •