Stefan,

Thanks alot, that was the answer I was looking for!
Foolproof it is.

Cheers,
Patrice

2011/6/8 Stefan Volbers <[email protected]>

> Hi Patrice,
>
> you do not need to explicitly declare your application a Singleton.
>
>  From within your classes, you can always reach the application class with
> qx.core.Init.getApplication()
> This does also work whereever the context ('this') is bound to any other
> object, so is 100% fool proof ;-)
>
> HTH
>
> Greetings
> Stefan
>
>
> On 08.06.2011 15:26, Patrice Oostermeyer wrote:
> > Ok I have the ugly part working.
> > But I don't quite get the better approach.
> > I'm trying to call reloadMap from Application.js, which is of
> > type qx.application.Standalone.
> > I marked it "singleton", which seems to be no problem.
> > The call to reloadMap works, BUT in it is a reference to 'this', and
> > that is where it fails.
> > Any suggestions?
> >
> > qx.Class.define("test.Application",
> > { extend : qx.application.Standalone,
> >    type: "singleton",
> >
> >    members :
> >    {
> >       some:"bla",
> >      main : function() {...}
> >      reloadMap : function(msg)
> >      { this.some = "thensome";
> >        // crash when called outside this app.
> >        alert("ReloadMap says: " + msg + this.some);
> >      }
> >    }
> > }
> >
> > Regards,
> > Patrice
> >
> > 2011/6/1 Marc Puts <[email protected]
> > <mailto:[email protected]>>
> >
> >     In the main() function of your application, you could set a global
> >     variable that calls the reloadMap function.
> >     Playground example:
> >     http://tinyurl.com/3eth8of
> >
> >     While the above works, it's pretty ugly.
> >
> >     Another (and imo, better) approach would be to have the reloadMap()
> >     function in a singleton class:
> >
> >     qx.Class.define("test.SomeClass",
> >     {
> >        type: "singleton",
> >        extend : qx.core.Object",
> >
> >        members :
> >        {
> >          reloadMap : function(msg)
> >          {
> >            alert("ReloadMap says: " + msg);
> >          }
> >        }
> >     }
> >
> >     Then, from outside the application, you can write:
> >         test.SomeClass.getInstance().reloadMap("Hello!");
> >
> >
> >
> >     Regards,
> >     Marc
> >
> >
> >     On 06/01/2011 04:29 PM, ibanezje wrote:
> >      > Probably asked more than once,
> >      >
> >      > but how do I call a function in my main Application from outside
> the
> >      > application?
> >      > something like:
> >      >
> >      > fails.
> >      > reloadMap() is a function in the 'members' section of
> Application.js
> >      >
> >
>
>
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to