Hi Andreas,

Andreas Hocevar wrote:
On Fri, May 16, 2008 at 3:35 PM, Gilles Bassière
<[EMAIL PROTECTED]> wrote:
Also, I'm not sure about the "action" approach. I need to trigger some extra
code when the button is selected. According to the wiki page " Listeners and
the Javascript API", I should use the action property for this : "[...]
<action> property which specifies an object method to be called when a
button is selected." But this is not really an event-driven approach, is it
? I wonder how I could make use of events to accomplish this. Any hints ?

You are right, you should work with events here. In the case of
WfsGetFeatureInfo, the features will be queried and loaded into the
model you specified in the transactionResponseModel property (e.g.
"trm").

To do your action event-based, you should say

function myAction(objRef) {
  window.alert("test");
}
config.objects["trm"].addListener("loadModel", myAction, config.objects["trm"]);

The third parameter of addListener is the context that will be passed
to the objRef parameter of the event handler. In your case, it might
be useful to pass the model itself, which will give you access to the
xml of the GetFeature response (objRef.doc).
Thanks for help. I haven't tried your solution yet but I think it does not suit my needs. If my understanding of events and MVC is good, the myAction() function would be executed when the WFS GetFeature response has been fetched, right ?

The logic of the WfsGetFeature button has two phases, first you select the tool then you select an area on the map. I actually need to perform some GUI actions when the button is clicked, before any request is sent. To sum up, I'm looking for a kind of onClick event attached to the button (though I'm not sure it's really mvc-friendly since no model is involved...)

By the way, I'd like to ask another question. Your code example help me to understand events in an mvc architecture but i'm still get confused about "objref".What is the point on making a difference between "objRef" and "this" ? Or, what is the concept behind "objref" ? Sorry if this is a silly question but I'm not familiar with advanced architectures.
Regards,
Andreas.
Regards,
Gilles

--
Gilles Bassiere
MAKINA CORPUS
30 rue des Jeuneurs
FR-75002 PARIS
+33 (0) 1 44 82 00 80
http://www.makina-corpus.com

begin:vcard
fn;quoted-printable:Gilles Bassi=C3=A8re
n;quoted-printable:Bassi=C3=A8re;Gilles
org:Makina Corpus;GIS
adr;quoted-printable:;;30 rue des Je=C3=BBneurs;Paris;;FR-75011;France
email;internet:[EMAIL PROTECTED]
title:Web GIS developper
tel;work:+33 (0) 1 44 82 00 80
x-mozilla-html:FALSE
url:http://www.makina-corpus.com
version:2.1
end:vcard

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Mapbuilder-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mapbuilder-users

Reply via email to