You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by ben <be...@intel.com> on 2013/04/02 20:48:58 UTC

How to access components (from included bxml files) in java code?

Hi,
I have a root bxml file in which I include sub bxml files like so:

Root.bxml
=================
<TablePane styles="{padding:8, horizontalSpacing:6}">
        <columns>
            <TablePane.Column width="1*"/>
            <TablePane.Column/>
        </columns>

        <TablePane.Row height="1*">
            <Border styles="{padding:12}">
                <BoxPane>
                    <TabPane bxml:id="tabPane">
                        <corner>
                            <BoxPane bxml:id="cornerBoxPane"
styles="{horizontalAlignment:'right'}">
                                <Label text="Search"/>
                                <TextInput textSize="15"/>
                            </BoxPane>
                        </corner>

                        <BoxPane styles="{horizontalAlignment:'left',
verticalAlignment:'top'}">
                            <TabPane.tabData>
                                <content:ButtonData icon="@img/dut.jpg"
                                    text="Device"/>
                            </TabPane.tabData>
                            
                            <bxml:include src="device_settings.bxml"/>
                        </BoxPane>

                        <BoxPane styles="{horizontalAlignment:'left',
verticalAlignment:'top'}">
                            <TabPane.tabData>
                                <content:ButtonData icon="@img/tester.jpg"
                                    text="Tester"/>
                            </TabPane.tabData>
                            
                            <bxml:include src="tester_settings.bxml"/>
                        </BoxPane>
                    </TabPane>
                </BoxPane>
            </Border>
        </TablePane.Row>
    </TablePane>
===============================

In the device_settings.bxml and tester_settings.bxml, I have some expanders
and I include other files that have tables,
In that code I attach some bxml:id’s to components so that I can hopefully
access them later on in the java code.

Device_settings.bxml
========================
<Border styles="{padding:6}"
    xmlns:bxml="http://pivot.apache.org/bxml"
    xmlns="org.apache.pivot.wtk">
    <ScrollPane horizontalScrollBarPolicy="fill">
        <BoxPane orientation="vertical" styles="{fill:true, padding:{left:2,
right:2}}">
            <Expander bxml:id="signal_settings_expander" title="Signal
Settings" expanded="false">
                <bxml:include src="signal_settings.bxml"/>
            </Expander>
            <Expander bxml:id="power_settings_expander" title="Power
Settings" expanded="false">
                <bxml:include src="power_settings.bxml"/>
            </Expander> 
            <Expander bxml:id="user_variables_expander" title="User
Variables" expanded="false">
                <bxml:include src="user_variables.bxml"/>
            </Expander> 
        </BoxPane>
    </ScrollPane>
</Border>

When I build and run my code I’m only able to access the id’s in the
root.bxml file.
All the other id’s that I’ve tagged in the bxml files are not showing up in
the namespace. 

If I print my code:
Map<String, Object> namespace = bxmlSerializer.getNamespace();
        Iterator<String> iter = namespace.iterator();
        while(iter.hasNext()) {
            String key = iter.next();
            System.out.println(key + " => " + namespace.get(key));
        }

Output is :
tabPane => org.apache.pivot.wtk.TabPane
cornerBoxPane => org.apache.pivot.wtk.BoxPane
confirmCloseTabPrompt => org.apache.pivot.wtk.Prompt

How do I get the included bxml id’s as well to show up?
I like being able to include other files rather than having a big old master
bxml file 

Thanks,
ben




--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/How-to-access-components-from-included-bxml-files-in-java-code-tp4022548.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

RE: How to access components (from included bxml files) in java code?

Posted by ben <be...@intel.com>.
Thanks Roger! It worked like a charm. I figured it was something silly like
that..
I had even come across it on the bxml primer page under scripting a while
back, but now understand it :)



--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/How-to-access-components-from-included-bxml-files-in-java-code-tp4022548p4022550.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

RE: How to access components (from included bxml files) in java code?

Posted by "Roger L. Whitcomb" <Ro...@actian.com>.
Hi Ben,
	Welcome to Pivot!  That's actually very easy.  In all your <bxml:include statements, add the inline="true" setting and then all your included "bxml:id" components will be available in the root namespace.

HTH,
~Roger Whitcomb