Hey Greg,

Very interesting. What's the status of pivot 2.0? Is it usable right now?

On Tue, Nov 9, 2010 at 7:56 AM, Greg Brown <[email protected]> wrote:

> Bindable only gets called on the root element of a WTKX or BXML document.
> This is because the document's variable namespace applies to the document as
> a whole, not to individual sub-elements. However, this also works for
> includes. So, if you write this:
>
> <TabPane>
>  <tabs>
>    <wtkx:include src="my_panel.wtkx"/>
>  </tabs>
> </TabPane>
>
> and my_panel.wtkx defines <me:MyPanel> as the root element, bind() will
> automatically be called on it, as well as initialize().
>
> Note also that you don't need to load your panel's content in the MyPanel
> constructor - you can simply use WTKX for this:
>
> my_panel.wtkx:
>
> <me:MyPanel>
>  <content>
>    <!-- my content goes here -->
>  </content>
> </me:MyPanel>
>
> Finally, note that in Pivot 2.0, tags such as <tabs> and <content> are
> optional. TabPane and Border now define "default properties", which can be
> omitted in markup:
>
> <TabPane>
>  <wtkx:include src="my_panel.wtkx"/>
> </TabPane>
>
> <me:MyPanel>
>  <!-- my content goes here -->
> </me:MyPanel>
>
> See the BXML Primer for more info:
>
>  http://ixnay.biz/pivot-tutorials/bxml-primer.html
>
> This document discusses BXML and the Pivot 2.0 version of Bindable, but
> most of the same concepts apply to Pivot 1.5.
>
> G
>
> On Nov 8, 2010, at 9:40 PM, ocean ocean wrote:
>
> > Hey all,
> >
> > I am having trouble figuring out how to use the
> org.apache.pivot.wtkx.Bindable interface.
> >
> > Let's say I create a class that extends a container that then reads in a
> WTKX file, eg:
> >
> > MyPanel.java:
> > public class MyPanel extends Border implements Bindable {
> >
> >     public MyPanel() throws Exception {
> >         WTKXSerializer wtkxSerializer = new WTKXSerializer();
> >         Component content = (Component) wtkxSerializer.readObject(this,
> "my-panel.wtkx");
> >         setContent(content);
> >     }
> > }
> >
> > Then I can reference this file from the main window very easily using
> WTKX:
> >
> > <TabPane>
> >  <tabs>
> >  <me:MyPanel />
> > </tabs>
> > </TabPane>
> >
> > In this situation, Bindable.bind() doesn't get called. My panel class is
> constructed but then I have to manually call bind on it. Is there a better
> way to get both modularization (being able to use separate wtkx files and
> separate panel classes) and also use the Bindable interface?
>
>

Reply via email to