/    Sign up×
Community /Pin to ProfileBookmark

How to replace protocol in geoext.form.formpanel

Hello all,

I’ve been scratching my head over this and I’m wondering if this is possible, sorry if this is so simple but I’m new about javascript and their libraries. 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…
    })
    }
    }]
    })[/CODE]

    how could I do this? is the handler the right place to do this? should I do it in this way or there is a better, simpler way? I’ll appreciate your support, thanks in advance.

    Best regards,

    Gery

    to post a comment
    JavaScript

    0Be the first to comment 😎

    ×

    Success!

    Help @Gery spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.18,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...