pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ninjathehunter <kzhang...@gmail.com>
Subject Re: Cannot config a button press listener outside the initialize method of Bindable
Date Sun, 03 Aug 2014 16:36:41 GMT
Hi Roger

Thanks for your reply. 

As you suggested, my first instinctive solution for the problem that
"getNamedComponent()" method only searches direct descendants was to do a
recursive search. However, I think this might not be a good practice after a
second thought. I think the whole purpose of introducing bxml (or xaml in
Windows WPF or similar) is to group UI definition in one place. This avoids
the old fashion of "window.add(button)" style UI construction. By using a
recursive search means the Java code varies if the UI structure changes.

I used a lot of 

<bxml:include src="MyPanel.bxml"/>

style construction in my UI configuration to avoid a big chunky bxml. I
created a class (which implements Bindable) for each bxml. Therefore I end
up with one MainFrame class, which is the whole UI, and a lot of classes
like MyPanel, which forms part of the MainFrame. 

When I call 

mainFrame = (MainFrame)bxmlSerializer.readObject(MainFrame.class,
"/gui/MainFrame.bxml");

It creates an instance of the MainFrame class, as well as all the other
classes that forms part of the MainFrame, like MyPanel.

However, once it is created, I found it is hard for me to refer to it. This
is because it is created by the framework and the only way I can refer to
them is to recursively search from the root components.

Many thanks.



--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Cannot-config-a-button-press-listener-outside-the-initialize-method-of-Bindable-tp4022979p4022983.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Mime
View raw message