Results 1 to 4 of 4

Thread: How can I overwrite the url of OpenLayers.Protocol.HTTP?

  1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    42

    Default How can I overwrite the url of OpenLayers.Protocol.HTTP?

    How can I overwrite the url of OpenLayers.Protocol.HTTP? I tried

    Code:
    searchformPanel.protocol.url
    and it works (checked with console.log), but at the end the original url is sent (in the code below: url: '/fs/') (see attached picture).

    mY1pq.png

    This is the code:

    Code:
    var searchformPanel = new GeoExt.form.FormPanel({
          border: false,
          width: 250,
          protocol: new OpenLayers.Protocol.HTTP({
            url: '/fs/',
            format: new OpenLayers.Format.GeoJSON()
          }),
          items:[{
            xtype: 'combo',
            id: 'idcombo',
            store: new Ext.data.SimpleStore({
              fields:['fsclass','ollayer'],
              data:[["Boreholes","Boreholes"],["All_layers","All layers"]]
            }),
            displayField: 'ollayer',
            valueField: 'fsclass',
            fieldLabel: 'Layer',
            emptyText: 'select a layer',
            submitValue: false,
            selectOnFocus: true,
            mode: 'local',
            typeAhead: true,
            editable: false,
            forceSelection: true,
            triggerAction: 'all'
          },{
            xtype: 'textfield',
            id: 'idtextfield',
            fieldLabel: 'Find features',
            emptyText: 'enter word',
            name: 'comments__like',
            allowBlank: false
          }],
          listeners:{
            actioncomplete: function(form, action){
              searchShowTip(action.response.features);
            }
          },
          buttons:[{
            text: 'search',
            listeners:{
              click: function(){
    
                var comboLayer = Ext.getCmp('idcombo').getRawValue();
                var keyword = Ext.getCmp('idtextfield').getRawValue();
    
                var newUrl = '/fs/' + comboLayer + '?format=GeoJSON&comments__ilike=' + keyword + '&queryable=comments';
                console.log('1:' + newUrl);
    
                //this gets '/fs/' from the searchformPanel
                console.log('2:' + searchformPanel.protocol.url);
    
                searchformPanel.protocol.url = newUrl;
                console.log('3:' + searchformPanel.protocol.url);
    
                searchformPanel.search();
              }
            }
          }]
      });
    Please any support about this is very welcome, thank you!

  2. #2
    Sencha User
    Join Date
    Jan 2011
    Posts
    549

    Default

    I'm not entirely sure I'm understanding the issue?

    Could you clarify exactly what you're expecting, opposed to what is actually happening?

  3. #3
    Sencha User
    Join Date
    Jun 2012
    Posts
    42

    Default

    thanks willigogs for the answer, this is happening in the code:

    Code:
    searchformPanel.protocol.url = newUrl;
    should set a new url in the url of the protocol of the formPanel (ie. searchformPanel.protocol.url), which is this:

    (1)
    Code:
    /fs/Boreholes?format=GeoJSON&comments__ilike=basin&queryable=comments
    however, after pressing the search button, the original url (ie. url in the protocol + values chosen in the formPanel) is sent, ie:

    (2)
    Code:
    /fs/?comments__ilike=basin&queryable=comments
    the difference between (1) and (2) is that the latter is missing Boreholes and format=GeoJSON&. I expect that (1) will be sent instead of (2).

    I hope this will be clearer.

    Gery

  4. #4
    Sencha User
    Join Date
    Jun 2012
    Posts
    42

    Default

    The solution was to simply take the protocol outside the formPanel and use "protocol.options.url = newUrl;", thanks willigogs for support

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
  •