You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by fredlenson <fr...@gmail.com> on 2012/02/20 03:32:31 UTC

Get data for TableView from Java

I've studied the TableView examples on the Tutorials section of the Pivot
site:

http://pivot.apache.org/tutorials/table-views.html Table Views 
http://pivot.apache.org/tutorials/table-views.json.html JSON-based
TableViews 
http://pivot.apache.org/tutorials/table-views.custom.html Custom TableView 

What I want to do is have the data displayed in the TableView comes from my
Java class.
In other words, I just want to use the .bxml file to layout my GUI
components, but have the rows and columns be dynamically generated.

Is there any example on how to do this? I couldn't find any examples where
the data displayed in components defined in the .bxml file come from the
Java class.
In the JSON example there's this code:

<tableData>
<bxml:include src="standings.json"/>
</tableData>

What I'd like to do is something like this (using imaginary syntax!):

<tableData>
<data = com.mypivottest.getTableViewData()>
</tableData>

Or, do I have to set the TableView data in the Java class?
Any help appreciated, thanks!


--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Get-data-for-TableView-from-Java-tp3759653p3759653.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

RE: Get data for TableView from Java

Posted by fredlenson <fr...@gmail.com>.
Thanks for the response, Camilo!

Your message helped me start reading about bindings etc. and now I
understand better.

These tutorials are also useful too:

http://pivot.apache.org/tutorials/push-buttons.html Push Buttons 
http://pivot.apache.org/tutorials/stock-tracker.ui.html UI Markup Using BXML 

Thanks again!

--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Get-data-for-TableView-from-Java-tp3759653p3762146.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Get data for TableView from Java

Posted by Luiz Gustavo <lu...@gmail.com>.
Great Camilo!! =)



2012/2/20 Camilo Casadiego <Ca...@adv.co>

> Hi there…i guess you want something like this…****
>
> ****
>
> ****
>
> The first and most important thing that you should do is to have a class
> to be base of your bxml file…I’ll just shouw you and example and tell you
> why…****
>
> ** **
>
> For example…in the last window…it is a Dialog, but if you see de bxml file
> it looks like this****
>
> ****
>
> If you can see it not a dialog itself… But  a workspace:NewItemDialog, and
> the msot important…you have this xmlns defined…****
>
> xmlns:workspace=*"co.com.adv.salarixII.ui.controller.workspace.dialog"*
>
> * *
>
> *The this class heading looks like this…*
>
> *package* co.com.adv.salarixII.ui.controller.workspace.dialog;****
>
> ** **
>
> //alot of imports....****
>
> * *
>
> *public* *class* NewItemDialog *extends* Dialog *implements* Bindable {***
> *
>
> ** **
>
> Whe you implement the Bindable interface…inmediatly the ide makes you add
> this method..****
>
> ** **
>
> @Override****
>
>     *public* *void* initialize(Map<String, Object> namespace, URL
> location, Resources resources) {****
>
> ** **
>
> that method is called when your page is rendered…and the..you can start
> playing with the bindings…for example…if the bxml:id of you ListView is
> listViewCosas… the in the class you can add an attribute like this…****
>
> @BXML****
>
>             *private* ListView listViewCosas;****
>
> remember that the attribute name and the bxml id in your bxml file for the
> specific object must be exactly the same (like with jsf..)****
>
> ** **
>
> then in the init method you can do wherever you wahnt with the list…the
> mos simple is to set the values…whcihc is achived like this..****
>
> ** **
>
> List<WhateverObjectYOuHave> list = new ArrayList<WhateverObjectYOuHave>();
> ****
>
> //Here you must add elements to the list…****
>
> typeList.setListData(list);****
>
> and it’s done…when your bxml file is rendered…you whould get your list
> displayed…****
>
> one last thing….don’t forget to add a toString Method in your objects..so
> It’ll show the ifno you whant to be shown of the obeject (your are not
> tided to only use strings…and whe you call the getSelectedItem you get the
> actual instance of the selected object)****
>
> ** **
>
> ** **
>
> ** **
>
> Cordialmente,****
>
>  ****
>
> ****
>
> Camilo Casadiego Espitia****
>
> Arquitecto de SW****
>
> A + 57 1 6393000 ****
>
>   camilo.casadiego@adv.com.co****
>
> c http://www.adv.com.co****
>
> Carrera 11 No. 93 – 53 P7****
>
> Bogotá - Colombia****
>
> ****
>
> ** **
>
> ** **
>
> -----Mensaje original-----
> De: fredlenson [mailto:fredlenson@gmail.com]
> Enviado el: Sunday, February 19, 2012 9:33 PM
> Para: user@pivot.apache.org
> Asunto: Get data for TableView from Java****
>
> ** **
>
> I've studied the TableView examples on the Tutorials section of the Pivot*
> ***
>
> site:****
>
> ** **
>
> http://pivot.apache.org/tutorials/table-views.html Table Views
> http://pivot.apache.org/tutorials/table-views.json.html JSON-based
> TableViews http://pivot.apache.org/tutorials/table-views.custom.htmlCustom TableView
> ****
>
> ** **
>
> What I want to do is have the data displayed in the TableView comes from
> my Java class.****
>
> In other words, I just want to use the .bxml file to layout my GUI
> components, but have the rows and columns be dynamically generated.****
>
> ** **
>
> Is there any example on how to do this? I couldn't find any examples where
> the data displayed in components defined in the .bxml file come from the
> Java class.****
>
> In the JSON example there's this code:****
>
> ** **
>
> <tableData>****
>
> <bxml:include src="standings.json"/>****
>
> </tableData>****
>
> ** **
>
> What I'd like to do is something like this (using imaginary syntax!):****
>
> ** **
>
> <tableData>****
>
> <data = com.mypivottest.getTableViewData()>****
>
> </tableData>****
>
> ** **
>
> Or, do I have to set the TableView data in the Java class?****
>
> Any help appreciated, thanks!****
>
> ** **
>
> ** **
>
> --****
>
> View this message in context:
> http://apache-pivot-users.399431.n3.nabble.com/Get-data-for-TableView-from-Java-tp3759653p3759653.html
> ****
>
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.****
>



-- 
Luiz Gustavo S. de Souza

http://luizgustavoss.wordpress.com

RE: Get data for TableView from Java

Posted by Camilo Casadiego <Ca...@adv.co>.
Hi there…i guess you want something like this…
[cid:image001.png@01CCEF55.A88244F0]
[cid:image002.png@01CCEF55.A88244F0]
The first and most important thing that you should do is to have a class to be base of your bxml file…I’ll just shouw you and example and tell you why…

For example…in the last window…it is a Dialog, but if you see de bxml file it looks like this
[cid:image003.jpg@01CCEF55.A88244F0]
If you can see it not a dialog itself… But  a workspace:NewItemDialog, and the msot important…you have this xmlns defined…
xmlns:workspace="co.com.adv.salarixII.ui.controller.workspace.dialog"

The this class heading looks like this…
package co.com.adv.salarixII.ui.controller.workspace.dialog;

//alot of imports....

public class NewItemDialog extends Dialog implements Bindable {

Whe you implement the Bindable interface…inmediatly the ide makes you add this method..

@Override
    public void initialize(Map<String, Object> namespace, URL location, Resources resources) {

that method is called when your page is rendered…and the..you can start playing with the bindings…for example…if the bxml:id of you ListView is listViewCosas… the in the class you can add an attribute like this…
@BXML
            private ListView listViewCosas;
remember that the attribute name and the bxml id in your bxml file for the specific object must be exactly the same (like with jsf..)

then in the init method you can do wherever you wahnt with the list…the mos simple is to set the values…whcihc is achived like this..

List<WhateverObjectYOuHave> list = new ArrayList<WhateverObjectYOuHave>();
//Here you must add elements to the list…
typeList.setListData(list);
and it’s done…when your bxml file is rendered…you whould get your list displayed…
one last thing….don’t forget to add a toString Method in your objects..so It’ll show the ifno you whant to be shown of the obeject (your are not tided to only use strings…and whe you call the getSelectedItem you get the actual instance of the selected object)







Cordialmente,



Camilo Casadiego Espitia

Arquitecto de SW

A + 57 1 6393000

  camilo.casadiego@adv.com.co

c http://www.adv.com.co

Carrera 11 No. 93 – 53 P7

Bogotá - Colombia





-----Mensaje original-----
De: fredlenson [mailto:fredlenson@gmail.com]
Enviado el: Sunday, February 19, 2012 9:33 PM
Para: user@pivot.apache.org
Asunto: Get data for TableView from Java



I've studied the TableView examples on the Tutorials section of the Pivot

site:



http://pivot.apache.org/tutorials/table-views.html Table Views http://pivot.apache.org/tutorials/table-views.json.html JSON-based TableViews http://pivot.apache.org/tutorials/table-views.custom.html Custom TableView



What I want to do is have the data displayed in the TableView comes from my Java class.

In other words, I just want to use the .bxml file to layout my GUI components, but have the rows and columns be dynamically generated.



Is there any example on how to do this? I couldn't find any examples where the data displayed in components defined in the .bxml file come from the Java class.

In the JSON example there's this code:



<tableData>

<bxml:include src="standings.json"/>

</tableData>



What I'd like to do is something like this (using imaginary syntax!):



<tableData>

<data = com.mypivottest.getTableViewData()>

</tableData>



Or, do I have to set the TableView data in the Java class?

Any help appreciated, thanks!





--

View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Get-data-for-TableView-from-Java-tp3759653p3759653.html

Sent from the Apache Pivot - Users mailing list archive at Nabble.com.