Yes, you can do this in several ways. You can define the list in BXML directly,
either in a define block or in script:
<bxml:define xmlns:collections="org.apache.pivot.collections">
<collections:ArrayList bxml:id="tableDataInList"/>
</bxml:define>
<bxml:script>
importPackage(org.apache.pivot.collections);
var tableDataInList = ArrayList();
</bxml:script>
or you can do it in Java:
ArrayList tableDataInList = new ArrayList();
bxmlSerializer.getNamespace().put("tableDataInList", tableDataInList);
bxmlSerializer.readObject(...)
Greg
On Oct 20, 2010, at 9:31 AM, Gerrick Bivins wrote:
> Hi Greg,
> Where my confusion comes in is in the syntax, I think,
> What I was expecting to be able to specify the dataprovider something like
> this:
> in BXML:
> <Border>
> <content>
> <ScrollPane horizontalScrollBarPolicy="fill_to_capacity">
> <view>
> <TableView bxml:id="tableView"
> tableData="$tableDataInList">
> <bxml:define>
>
> </bxml:define>
> <columns>
> <TableView.Column name="label" width="3*"
> headerData="Name"/>
> <TableView.Column name="value" width="1*"
> headerData="Value"/>
> <TableView.Column name="units" width="1*"
> headerData="Units"/>
> </columns>
> </TableView>
> </view>
> <columnHeader>
> <TableViewHeader tableView="$tableView"/>
> </columnHeader>
> </ScrollPane>
> </content>
> </Border>
>
> And with a definition of tableDatainList defined and populated somewhere,
> bxml,java,javascript etc, as a bindable variable.
>
> Is it possible to define a List somewhere and then bind it as a variable
> that is accessible in bxml?
> Again thanks for the patience here.
> Gerrick
>
>
> On Tue, Oct 19, 2010 at 12:16 PM, Greg Brown <[email protected]> wrote:
> Unfortunately, the term "binding" is very heavily overloaded. :-) What you
> are describing sounds like "data-bound" or "data-driven" controls. Pivot does
> support this - in fact, the design of this feature was somewhat inspired by
> Flex. The ListView, TableView, and TreeView components (among others) are all
> backed by instances of org.apache.pivot.collections.List. Implementations of
> this interface (such as ArrayList) fire events, which allow them to be used
> as a data model. You can see some examples in the tutorial:
>
> http://pivot.apache.org/tutorials/
>
> It currently only covers Pivot 1.5 but most of the concepts are the same in
> 2.0.
>
> Pivot also supports several other forms of binding:
>
> - BXML binding, which maps objects declared in markup to Java member variables
> - Data binding, which uses a load()/store() mechanism to populate user
> interface elements
> - Namespace binding, which allows you to declaratively create a relationship
> between a source property and a target property (also inspired to some extent
> by Flex)
>
> Hope this helps.
>
> Greg
>
>
> On Oct 19, 2010, at 10:17 AM, Gerrick Bivins wrote:
>
>> Hello all,
>> I'm coming from a dev background of swing then a flex project and now we are
>> back on a java project.
>> After my experiences with flex/actionscript I've been looking for a more
>> modern alternative to swing so
>> that lead me to pivot.
>> Right now I'm struggling with understanding data binding in pivot (I'm using
>> trunk of 2.0).
>> In flex/actionscript, just about any thing (components, data) were
>> "bindable". What that allowed was the ability to
>> populate a bindable structure (arraylist for instance) and then refer to
>> that arraylist as the "dataprovider" for any of
>> the components. Changes to the arraylist are automatically reflected in any
>> components that were bound to it.
>> That's the general idea but it's a pretty vague description/example. Here is
>> an example from the docs that shows an arraylist as a dataprovider to a
>> table (datagrid):
>> Data binding in a flex datagrid
>>
>> This paradigm was one of the great things about flex/actionscript and I was
>> hoping pivot had some similar mechanisms in place but
>> I can't find a concrete example of it. Is there an analogous "databinding"
>> concept in pivot?
>>
>> Thanks for any guidance here.
>> Gerrick
>>
>
>