About component model

1 view
Skip to first unread message

Lorenzo Vegetti

unread,
Jun 11, 2009, 11:05:03 AM6/11/09
to QxTransformer
Hello, I'm trying to create my first app.
In particular I'm trying to use the component model using Qooxdoo
0.8.2 and QxTransformer trunk.

In my Application.xml I'd like to use a component to hold all the UI:
<ds_windows:MainWindow />

I have a base class MainWindowBase that extends
qx.ui.container.Composite (cfr: code behind example):
qx.Class.define("ds.windows.MainWindowBase", { extend :
qx.ui.container.Composite, [...]

In MainWindow.xml my component extends ds.windows.MainWindowBase, it's
still quite simple:
<qx:vbox id="ds_windows_MainWindow" qxt:edge="0">
<qx:menuBar>[...]
<qx:tabView>[...]
</qx:vbox>

In the code generated in MainWindow.js, a few lines after the line
where the id I specified is connected with 'this':
var ds_windows_MainWindow = this;

I see the line:
qxtComponent1.add(qxMenuBar1 );

Finally the problem: qxtComponent1 is not defined anywhere, as far as
I can tell, ds_windows_MainWindow or this should be used.

Am I doing something wrong?

Thanks,
Lorenzo

Lorenzo Vegetti

unread,
Jun 11, 2009, 11:24:54 AM6/11/09
to QxTransformer
Guess I found the error: it was obviously my fault.
The only child of qxt:component should have been:
<qx:composite id="ds_windows_MainWindow">

and not its content as in my previous post:
<qx:vbox id="ds_windows_MainWindow" qxt:edge="0">

Thanks anyway,
Lorenzo

Christian Boulanger

unread,
Jun 11, 2009, 11:32:32 AM6/11/09
to qxtran...@googlegroups.com
Hello Lorenzo,

thanks for your inquiry and yes, the scope of the ids is limited to
the the document/script in which it is defined... You can define a
different scope with the qxt:scope attribute - Siarhei can provide
more information here since the useage has changed in this new
version.

Don't hesitate to ask any other question that you might have.

Best,

Christian

2009/6/11 Lorenzo Vegetti <l.ve...@libero.it>:

Siarhei Barysiuk

unread,
Jun 11, 2009, 11:37:26 AM6/11/09
to qxtran...@googlegroups.com
Hi Lorenzo,

You're absolutely right. The problem is in your component definition.

qx:component has only one child which actually defines basic behavior
of your component.
So, if you are creating a simple panel which extends composite layout
class you should use qx:composite under your qx:component.
Like:

<qx:component ...>
<qx:composite ...>
[...]

It gives qxtransformer information how to process your custom
component when it finds such component in xml.
Because it knows how to process qx:composite but knows nothing about
ds_windows:MainWindow in simple words.

Search for "behavior-element" in our wiki for more information.

Cheers,
Siarhei

Siarhei Barysiuk

unread,
Jun 11, 2009, 11:42:18 AM6/11/09
to qxtran...@googlegroups.com
Actually, in this particular case it's not related with scope and
variable name.
But I wonder why you are using such looong variables names? :)
qxtransformer
generates variable names automatically and if you're not planning to
use this
reference in your code you can just skip it.

I suppose it will work for you.

Siarhei

Lorenzo Vegetti

unread,
Jun 12, 2009, 3:30:32 AM6/12/09
to QxTransformer


On Jun 11, 5:42 pm, Siarhei Barysiuk <s.barys...@gmail.com> wrote:
> Actually, in this particular case it's not related with scope and  
> variable name.
> But I wonder why you are using such looong variables names? :)  

I just wanted to be clear, now I've removed them all, since, as you
pointed out, there's no need to add an id to every widget...

Lorenzo Vegetti

unread,
Jun 12, 2009, 3:32:47 AM6/12/09
to QxTransformer
On Jun 11, 5:32 pm, Christian Boulanger
<c.boulan...@qxtransformer.org> wrote:
> Hello Lorenzo,
>
> thanks for your inquiry and yes, the scope of the ids is limited to
> the the document/script in which it is defined... You can define a
> different scope with the qxt:scope attribute - Siarhei can provide
> more information here since the useage has changed in this new
> version.

The scope, thought I read about it in the docs but I couldn't find it
anymore!!!
Thanks, I was looking for it
Lorenzo

Siarhei Barysiuk

unread,
Jun 12, 2009, 4:15:07 AM6/12/09
to qxtran...@googlegroups.com
Brief description of qxt:scope attribute:

It allows controlling scope of generated variable. By default it's a
local variable.
qxt:scope has how only one possible value value: this. (Maybe will add
global in the future.)

Without qxt:scope:
------
var widget1 = .....
-----

With qxt:scope="this"
------
var widget1 = .....
this.widget1 = widget;
------
So, you're able in this case get your widget as this.widget1 in your
callback for example.

Cheers,
Siarhei
Reply all
Reply to author
Forward
0 new messages