On Wed, Nov 25, 2009 at 18:14, Jean-Noël Rivasseau <[email protected]>wrote:

>
> here is my problem. I need to extend TabView.js in a very simple way,
> actually just to allow tabs to go either at the left (current behavior) or
> at the right of the tab bar. So what I did was extending TabView and adding
> the following function:
>
>
>         addSpecial: function(page, right)
>         {
>

...


> This code is almost identical to the add function in the original class.
> Now this worked quite well in development, but in production I realized that
> private variable access is strictly enforced via a scrambling of the
> variable names, so the build version of the application was totally failing.
> I know I can turn off this scrambling but I would prefer not to, just for
> this case. Besides, just copying that code and modifying it is not good (bad
> practice). I should be overriding a much smaller section of the code.
>
> So my question is simple, how can I extend the class and still do what I
> need? Currently my workaround was to change all the private variables to
> protected ones in the base class. That works, but in long term that's not OK
> as i dont want to maintain patches against upstream version. I would rather
> cooperate now with upstream to know what can be done on this case. I am
> ready to provide patches etc, but I would like to find a way that's
> acceptable to the Qooxdoo base team (upstream) and my own needs. That could
> involve refactoring the code to make overriding specific methods more
> easier, if you are OK with that.
>

This is interesting. I _think_ you should be able to do it with a mixin, but
I have a feeling that the generator is going to mess with variable
obscuration too early for it to take effect. Hopefully I'm wrong. Give the
following untested code a try. Create a mixin and add your addSpecial method
to TabView rather than extending TabView with your own class.

qx.Mixin.define("custom.MTabView",
{
  methods :
  {
    addSpecial : function(page, right)
    {
      ...
    }
  }
});

Then in your application, include this mixin before your first use of
TabView:

qx.Class.include(qx.ui.tabview.TabView, custom.MTabView);

Now every time you instantiate a qx.ui.tabview.TabView object, it will have
the addSpecial() method too.

Good luck! :-)

Derrell
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to