You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Piotr Zarzycki <pi...@gmail.com> on 2017/05/02 21:39:58 UTC
Re: git commit: [flex-asjs] [refs/heads/develop] - Added example of
building a Table from a data source to the TableExample example.
Hi Peter,
I was going through the DataTable class code and I see that you are adding
mapper bead in addedToParent.
override public function addedToParent():void
{
super.addedToParent();
addBead(new DataTableMapperForArrayListData());
dispatchEvent( new Event("initComplete") );
}
If I add event listener to DataTable class I will get "initComplete"
two times.
You will not have issue with added bead, but developer who will get
this class and use it could have.
Piotr
2017-05-02 22:34 GMT+02:00 <pe...@apache.org>:
> Repository: flex-asjs
> Updated Branches:
> refs/heads/develop 82ff1840e -> 336fac64c
>
>
> Added example of building a Table from a data source to the TableExample
> example.
>
>
> Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/336fac64
> Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/336fac64
> Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/336fac64
>
> Branch: refs/heads/develop
> Commit: 336fac64c0eed8b063213a72899f658e9d490cea
> Parents: 82ff184
> Author: Peter Ent <pe...@apache.org>
> Authored: Tue May 2 16:33:57 2017 -0400
> Committer: Peter Ent <pe...@apache.org>
> Committed: Tue May 2 16:33:57 2017 -0400
>
> ----------------------------------------------------------------------
> .../src/main/flex/MyInitialView.mxml | 31 ++++-
> .../src/main/flex/TableExample.mxml | 3 +
> .../src/main/flex/dataTable/DataColumn.as | 33 ++++++
> .../src/main/flex/dataTable/DataTable.as | 69 ++++++++++++
> .../mapper/DataTableMapperForArrayListData.as | 112 +++++++++++++++++++
> .../main/flex/dataTable/model/DataTableModel.as | 40 +++++++
> .../src/main/flex/models/ProductsModel.as | 47 ++++++++
> 7 files changed, 334 insertions(+), 1 deletion(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> 336fac64/examples/flexjs/TableExample/src/main/flex/MyInitialView.mxml
> ----------------------------------------------------------------------
> diff --git a/examples/flexjs/TableExample/src/main/flex/MyInitialView.mxml
> b/examples/flexjs/TableExample/src/main/flex/MyInitialView.mxml
> index c2f81dd..11d2e29 100644
> --- a/examples/flexjs/TableExample/src/main/flex/MyInitialView.mxml
> +++ b/examples/flexjs/TableExample/src/main/flex/MyInitialView.mxml
> @@ -18,7 +18,9 @@ limitations under the License.
>
> -->
> <js:View xmlns:fx="http://ns.adobe.com/mxml/2009"
> - xmlns:js="library://ns.apache.
> org/flexjs/basic">
> + xmlns:js="library://ns.apache.
> org/flexjs/basic"
> + xmlns:dataTable="dataTable.*"
> + xmlns:model="dataTable.model.*">
>
> <fx:Style>
> @namespace js "library://ns.apache.org/flexjs/basic";
> @@ -44,6 +46,10 @@ limitations under the License.
> padding: 6px;
> }
>
> + .DataTable {
> + iBeadModel: ClassReference("dataTable.
> model.DataTableModel");
> + }
> +
> </fx:Style>
>
> <js:beads>
> @@ -117,5 +123,28 @@ limitations under the License.
> </js:TableCell>
> </js:TableRow>
> </js:Table>
> +
> + <!-- Generates a Table structure from a data source -->
> +
> + <dataTable:DataTable x="600" y="0" width="400" height="400">
> + <dataTable:beads>
> + <js:ConstantBinding
> + sourceID="applicationModel"
> + sourcePropertyName="products"
> + destinationPropertyName="dataProvider" />
> + </dataTable:beads>
> + <dataTable:DataColumn
> + dataField="name"
> + label="State"
> + itemRenderer="org.apache.flex.html.supportClasses.StringItemRenderer"
> />
> + <dataTable:DataColumn
> + dataField="capital"
> + label="Capital"
> + itemRenderer="org.apache.flex.html.supportClasses.StringItemRenderer"
> />
> + <dataTable:DataColumn
> + dataField="country"
> + label="Country"
> + itemRenderer="org.apache.flex.html.supportClasses.StringItemRenderer"
> />
> + </dataTable:DataTable>
>
> </js:View>
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> 336fac64/examples/flexjs/TableExample/src/main/flex/TableExample.mxml
> ----------------------------------------------------------------------
> diff --git a/examples/flexjs/TableExample/src/main/flex/TableExample.mxml
> b/examples/flexjs/TableExample/src/main/flex/TableExample.mxml
> index 2d5c972..41989f8 100644
> --- a/examples/flexjs/TableExample/src/main/flex/TableExample.mxml
> +++ b/examples/flexjs/TableExample/src/main/flex/TableExample.mxml
> @@ -27,6 +27,9 @@
> <js:valuesImpl>
> <js:SimpleCSSValuesImpl />
> </js:valuesImpl>
> + <js:model>
> + <models:ProductsModel />
> + </js:model>
> <js:initialView>
> <local:MyInitialView />
> </js:initialView>
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> 336fac64/examples/flexjs/TableExample/src/main/flex/
> dataTable/DataColumn.as
> ----------------------------------------------------------------------
> diff --git a/examples/flexjs/TableExample/src/main/flex/dataTable/DataColumn.as
> b/examples/flexjs/TableExample/src/main/flex/dataTable/DataColumn.as
> new file mode 100644
> index 0000000..b8e5f2e
> --- /dev/null
> +++ b/examples/flexjs/TableExample/src/main/flex/dataTable/DataColumn.as
> @@ -0,0 +1,33 @@
> +///////////////////////////////////////////////////////////
> /////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
> +///////////////////////////////////////////////////////////
> /////////////////////
> +package dataTable
> +{
> + import org.apache.flex.html.supportClasses.DataGridColumn;
> +
> + /**
> + * DataColumn is exactly like DataGridColumn
> + */
> + public class DataColumn extends DataGridColumn
> + {
> + public function DataColumn()
> + {
> + super();
> + }
> + }
> +}
> \ No newline at end of file
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> 336fac64/examples/flexjs/TableExample/src/main/flex/dataTable/DataTable.as
> ----------------------------------------------------------------------
> diff --git a/examples/flexjs/TableExample/src/main/flex/dataTable/DataTable.as
> b/examples/flexjs/TableExample/src/main/flex/dataTable/DataTable.as
> new file mode 100644
> index 0000000..1b388b6
> --- /dev/null
> +++ b/examples/flexjs/TableExample/src/main/flex/dataTable/DataTable.as
> @@ -0,0 +1,69 @@
> +///////////////////////////////////////////////////////////
> /////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
> +///////////////////////////////////////////////////////////
> /////////////////////
> +package dataTable
> +{
> + import dataTable.mapper.DataTableMapperForArrayListData;
> + import dataTable.model.DataTableModel;
> +
> + import org.apache.flex.events.Event;
> + import org.apache.flex.html.Table;
> +
> + [DefaultProperty("columns")]
> +
> + /**
> + * The DataTable uses Table along with a data mapper and item
> renderers to generate
> + * a Table from a data source.
> + */
> + public class DataTable extends Table
> + {
> + public function DataTable()
> + {
> + super();
> +
> + className = "DataTable";
> + }
> +
> + public function get columns():Array
> + {
> + return DataTableModel(model).columns;
> + }
> + public function set columns(value:Array):void
> + {
> + DataTableModel(model).columns = value;
> + }
> +
> + public function get dataProvider():Object
> + {
> + return DataTableModel(model).dataProvider;
> + }
> + public function set dataProvider(value:Object):void
> + {
> + DataTableModel(model).dataProvider = value;
> + }
> +
> + override public function addedToParent():void
> + {
> + super.addedToParent();
> +
> + addBead(new DataTableMapperForArrayListData());
> +
> + dispatchEvent( new Event("initComplete") );
> + }
> + }
> +}
> \ No newline at end of file
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> 336fac64/examples/flexjs/TableExample/src/main/flex/dataTable/mapper/
> DataTableMapperForArrayListData.as
> ----------------------------------------------------------------------
> diff --git a/examples/flexjs/TableExample/src/main/flex/dataTable/mapper/
> DataTableMapperForArrayListData.as b/examples/flexjs/
> TableExample/src/main/flex/dataTable/mapper/DataTableMapperForArrayListDat
> a.as
> new file mode 100644
> index 0000000..c80234c
> --- /dev/null
> +++ b/examples/flexjs/TableExample/src/main/flex/dataTable/mapper/
> DataTableMapperForArrayListData.as
> @@ -0,0 +1,112 @@
> +///////////////////////////////////////////////////////////
> /////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
> +///////////////////////////////////////////////////////////
> /////////////////////
> +package dataTable.mapper
> +{
> + import dataTable.DataColumn;
> + import dataTable.model.DataTableModel;
> +
> + import org.apache.flex.collections.ArrayList;
> + import org.apache.flex.core.IBead;
> + import org.apache.flex.core.IBeadModel;
> + import org.apache.flex.core.IStrand;
> + import org.apache.flex.events.Event;
> + import org.apache.flex.events.IEventDispatcher;
> + import org.apache.flex.html.Label;
> + import org.apache.flex.html.Table;
> + import org.apache.flex.html.TableCell;
> + import org.apache.flex.html.TableHeader;
> + import org.apache.flex.html.TableRow;
> + import org.apache.flex.html.supportClasses.DataItemRenderer;
> +
> + public class DataTableMapperForArrayListData implements IBead
> + {
> + public function DataTableMapperForArrayListData()
> + {
> + }
> +
> + private var _strand:IStrand;
> +
> + public function set strand(value:IStrand):void
> + {
> + _strand = value;
> +
> + IEventDispatcher(_strand).addEventListener("initComplete",
> handleInitComplete);
> + }
> +
> + private function handleInitComplete(event:Event):void
> + {
> + var model:DataTableModel = _strand.getBeadByType(IBeadModel)
> as DataTableModel;
> + if (model == null) return;
> +
> + var dp:ArrayList = model.dataProvider as ArrayList;
> + if (dp == null || dp.length == 0) return;
> +
> + var table:Table = _strand as Table;
> +
> + var createHeaderRow:Boolean = false;
> + for(var c:int=0; c < model.columns.length; c++)
> + {
> + var test:DataColumn = model.columns[c] as
> DataColumn;
> + if (test.label != null) {
> + createHeaderRow = true;
> + break;
> + }
> + }
> +
> + if (createHeaderRow) {
> + var headerRow:TableRow = new TableRow();
> +
> + for(c=0; c < model.columns.length; c++)
> + {
> + test = model.columns[c] as
> DataColumn;
> + var tableHeader:TableHeader = new
> TableHeader();
> + var label:Label = new Label();
> + tableHeader.addElement(label);
> + label.text = test.label == null ?
> "" : test.label;
> + headerRow.addElement(tableHeader);
> + }
> +
> + table.addElement(headerRow);
> + }
> +
> + for(var i:int=0; i < dp.length; i++)
> + {
> + var tableRow:TableRow = new TableRow();
> +
> + for(var j:int=0; j < model.columns.length;
> j++)
> + {
> + var column:DataColumn =
> model.columns[j] as DataColumn;
> + var tableCell:TableCell = new
> TableCell();
> +
> + var ir:DataItemRenderer =
> column.itemRenderer.newInstance() as DataItemRenderer;
> + tableCell.addElement(ir);
> + tableRow.addElement(tableCell);
> +
> + ir.labelField = column.dataField;
> + ir.index = i;
> + ir.data = dp.getItemAt(i);
> + }
> +
> + table.addElement(tableRow);
> + }
> +
> + table.dispatchEvent(new Event("layoutNeeded"));
> + }
> + }
> +}
> \ No newline at end of file
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> 336fac64/examples/flexjs/TableExample/src/main/flex/dataTable/model/
> DataTableModel.as
> ----------------------------------------------------------------------
> diff --git a/examples/flexjs/TableExample/src/main/flex/dataTable/model/DataTableModel.as
> b/examples/flexjs/TableExample/src/main/flex/dataTable/model/
> DataTableModel.as
> new file mode 100644
> index 0000000..084b512
> --- /dev/null
> +++ b/examples/flexjs/TableExample/src/main/flex/dataTable/model/
> DataTableModel.as
> @@ -0,0 +1,40 @@
> +///////////////////////////////////////////////////////////
> /////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
> +///////////////////////////////////////////////////////////
> /////////////////////
> +package dataTable.model
> +{
> + import org.apache.flex.html.beads.models.ArrayListSelectionModel;
> +
> + public class DataTableModel extends ArrayListSelectionModel
> + {
> + public function DataTableModel()
> + {
> + super();
> + }
> +
> + private var _columns:Array;
> + public function get columns():Array
> + {
> + return _columns;
> + }
> + public function set columns(value:Array):void
> + {
> + _columns = value;
> + }
> + }
> +}
> \ No newline at end of file
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> 336fac64/examples/flexjs/TableExample/src/main/flex/
> models/ProductsModel.as
> ----------------------------------------------------------------------
> diff --git a/examples/flexjs/TableExample/src/main/flex/models/ProductsModel.as
> b/examples/flexjs/TableExample/src/main/flex/models/ProductsModel.as
> new file mode 100644
> index 0000000..06a9b9b
> --- /dev/null
> +++ b/examples/flexjs/TableExample/src/main/flex/models/ProductsModel.as
> @@ -0,0 +1,47 @@
> +///////////////////////////////////////////////////////////
> /////////////////////
> +//
> +// Licensed to the Apache Software Foundation (ASF) under one or more
> +// contributor license agreements. See the NOTICE file distributed with
> +// this work for additional information regarding copyright ownership.
> +// The ASF licenses this file to You under the Apache License, Version
> 2.0
> +// (the "License"); you may not use this file except in compliance with
> +// the License. You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
> +///////////////////////////////////////////////////////////
> /////////////////////
> +package models
> +{
> + import org.apache.flex.collections.ArrayList;
> +
> + public class ProductsModel
> + {
> + public function ProductsModel()
> + {
> + }
> +
> + private var _products:ArrayList = new ArrayList([
> + {name: "British Columbia", capital: "Vancouver",
> country: "Canada"},
> + {name: "Coahuila", capital: "Saltilli", country:
> "Mexico"},
> + {name: "Georgia", capital: "Atlanta", country:
> "USA"},
> + {name: "Kyoto", capital: "Kyoto", country:
> "Japan"},
> + {name: "Massachusetts", capital: "Boston",
> country: "USA"},
> + {name: "New South Wales", capital: "Sydney",
> country: "Australia"},
> + {name: "Quebec", capital: "Montreal", country:
> "Canada"},
> + {name: "Shimane", capital: "Matsue", country:
> "Japan"},
> + {name: "Victoria", capital: "Melbourne", country:
> "Australia"},
> + {name: "Yucatan", capital: "Merida", country:
> "Mexico"}
> + ]);
> +
> + public function get products():ArrayList
> + {
> + return _products;
> + }
> + }
> +}
> \ No newline at end of file
>
>
Re: git commit: [flex-asjs] [refs/heads/develop] - Added example of
building a Table from a data source to the TableExample example.
Posted by piotrz <pi...@gmail.com>.
The second way is to stay as is and addBead before addedToParent. :)
Piotr
-----
Apache Flex PMC
piotrzarzycki21@gmail.com
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/Re-git-commit-flex-asjs-refs-heads-develop-Added-example-of-building-a-Table-from-a-data-source-to-t-tp61479p61486.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.
Re: git commit: [flex-asjs] [refs/heads/develop] - Added example of
building a Table from a data source to the TableExample example.
Posted by Peter Ent <pe...@adobe.com>.
Hi,
Yes - you are right about getting "initComplete" twice. I wrote the code
and forgot about it! The DataTable should probably dispatch
"dataTableComplete" so that the data mapper can detect that as the
all-finished event.
Thanks,
‹peter
On 5/2/17, 5:39 PM, "Piotr Zarzycki" <pi...@gmail.com> wrote:
>Hi Peter,
>
>I was going through the DataTable class code and I see that you are adding
>mapper bead in addedToParent.
>
>override public function addedToParent():void
>{
> super.addedToParent();
>
> addBead(new DataTableMapperForArrayListData());
>
> dispatchEvent( new Event("initComplete") );
>}
>
> If I add event listener to DataTable class I will get "initComplete"
>two times.
>
>You will not have issue with added bead, but developer who will get
>this class and use it could have.
>
>Piotr
>
>
>2017-05-02 22:34 GMT+02:00 <pe...@apache.org>:
>
>> Repository: flex-asjs
>> Updated Branches:
>> refs/heads/develop 82ff1840e -> 336fac64c
>>
>>
>> Added example of building a Table from a data source to the TableExample
>> example.
>>
>>
>> Project:
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-u
>>s.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Frepo&data=02%7C01%7C%7C973eb1da4
>>7de43ee8ff308d491a3d089%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6362
>>93580155655469&sdata=lugSmNuyjCCVZ%2BPoSqlfac2LM4%2BwoALMml9%2FWJ12nMM%3D
>>&reserved=0
>> Commit:
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-u
>>s.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Fcommit%2F336fac64&data=02%7C01%7
>>C%7C973eb1da47de43ee8ff308d491a3d089%7Cfa7b1b5a7b34438794aed2c178decee1%7
>>C0%7C0%7C636293580155655469&sdata=N4yb6S%2Ftiq2Bmy3dYMzB6DWOcnUbhCmHlIfqp
>>48%2FE%2Bk%3D&reserved=0
>> Tree:
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-u
>>s.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Ftree%2F336fac64&data=02%7C01%7C%
>>7C973eb1da47de43ee8ff308d491a3d089%7Cfa7b1b5a7b34438794aed2c178decee1%7C0
>>%7C0%7C636293580155655469&sdata=Od4twsqmJ%2BiQLJjGV7W5Lv%2F48N16La6zNvIBp
>>Rzxrf8%3D&reserved=0
>> Diff:
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-u
>>s.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Fdiff%2F336fac64&data=02%7C01%7C%
>>7C973eb1da47de43ee8ff308d491a3d089%7Cfa7b1b5a7b34438794aed2c178decee1%7C0
>>%7C0%7C636293580155655469&sdata=cemmUkVwsZERSGDQVIUoxnIcJAtm8AetP4cTbcyOj
>>FE%3D&reserved=0
>>
>> Branch: refs/heads/develop
>> Commit: 336fac64c0eed8b063213a72899f658e9d490cea
>> Parents: 82ff184
>> Author: Peter Ent <pe...@apache.org>
>> Authored: Tue May 2 16:33:57 2017 -0400
>> Committer: Peter Ent <pe...@apache.org>
>> Committed: Tue May 2 16:33:57 2017 -0400
>>
>> ----------------------------------------------------------------------
>> .../src/main/flex/MyInitialView.mxml | 31 ++++-
>> .../src/main/flex/TableExample.mxml | 3 +
>> .../src/main/flex/dataTable/DataColumn.as | 33 ++++++
>> .../src/main/flex/dataTable/DataTable.as | 69 ++++++++++++
>> .../mapper/DataTableMapperForArrayListData.as | 112
>>+++++++++++++++++++
>> .../main/flex/dataTable/model/DataTableModel.as | 40 +++++++
>> .../src/main/flex/models/ProductsModel.as | 47 ++++++++
>> 7 files changed, 334 insertions(+), 1 deletion(-)
>> ----------------------------------------------------------------------
>>
>>
>>
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-u
>>s.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Fblob%2F&data=02%7C01%7C%7C973eb1
>>da47de43ee8ff308d491a3d089%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6
>>36293580155665477&sdata=lKg4ES5s2EUHsYKZqLX2ADXkVYodqZxqmtbLE6443yM%3D&re
>>served=0
>> 336fac64/examples/flexjs/TableExample/src/main/flex/MyInitialView.mxml
>> ----------------------------------------------------------------------
>> diff --git
>>a/examples/flexjs/TableExample/src/main/flex/MyInitialView.mxml
>> b/examples/flexjs/TableExample/src/main/flex/MyInitialView.mxml
>> index c2f81dd..11d2e29 100644
>> --- a/examples/flexjs/TableExample/src/main/flex/MyInitialView.mxml
>> +++ b/examples/flexjs/TableExample/src/main/flex/MyInitialView.mxml
>> @@ -18,7 +18,9 @@ limitations under the License.
>>
>> -->
>> <js:View
>>xmlns:fx="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2
>>Fns.adobe.com%2Fmxml%2F2009&data=02%7C01%7C%7C973eb1da47de43ee8ff308d491a
>>3d089%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636293580155665477&sda
>>ta=KQ1v3zxgipqPUoRjx%2BIs6UimtO1%2FcQVpFcHQ5eN0Fuw%3D&reserved=0"
>> - xmlns:js="library://ns.apache.
>> org/flexjs/basic">
>> + xmlns:js="library://ns.apache.
>> org/flexjs/basic"
>> + xmlns:dataTable="dataTable.*"
>> + xmlns:model="dataTable.model.*">
>>
>> <fx:Style>
>> @namespace js "library://ns.apache.org/flexjs/basic";
>> @@ -44,6 +46,10 @@ limitations under the License.
>> padding: 6px;
>> }
>>
>> + .DataTable {
>> + iBeadModel: ClassReference("dataTable.
>> model.DataTableModel");
>> + }
>> +
>> </fx:Style>
>>
>> <js:beads>
>> @@ -117,5 +123,28 @@ limitations under the License.
>> </js:TableCell>
>> </js:TableRow>
>> </js:Table>
>> +
>> + <!-- Generates a Table structure from a data source -->
>> +
>> + <dataTable:DataTable x="600" y="0" width="400" height="400">
>> + <dataTable:beads>
>> + <js:ConstantBinding
>> + sourceID="applicationModel"
>> + sourcePropertyName="products"
>> + destinationPropertyName="dataProvider"
>>/>
>> + </dataTable:beads>
>> + <dataTable:DataColumn
>> + dataField="name"
>> + label="State"
>> +
>>itemRenderer="org.apache.flex.html.supportClasses.StringItemRenderer"
>> />
>> + <dataTable:DataColumn
>> + dataField="capital"
>> + label="Capital"
>> +
>>itemRenderer="org.apache.flex.html.supportClasses.StringItemRenderer"
>> />
>> + <dataTable:DataColumn
>> + dataField="country"
>> + label="Country"
>> +
>>itemRenderer="org.apache.flex.html.supportClasses.StringItemRenderer"
>> />
>> + </dataTable:DataTable>
>>
>> </js:View>
>>
>>
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-u
>>s.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Fblob%2F&data=02%7C01%7C%7C973eb1
>>da47de43ee8ff308d491a3d089%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6
>>36293580155665477&sdata=lKg4ES5s2EUHsYKZqLX2ADXkVYodqZxqmtbLE6443yM%3D&re
>>served=0
>> 336fac64/examples/flexjs/TableExample/src/main/flex/TableExample.mxml
>> ----------------------------------------------------------------------
>> diff --git
>>a/examples/flexjs/TableExample/src/main/flex/TableExample.mxml
>> b/examples/flexjs/TableExample/src/main/flex/TableExample.mxml
>> index 2d5c972..41989f8 100644
>> --- a/examples/flexjs/TableExample/src/main/flex/TableExample.mxml
>> +++ b/examples/flexjs/TableExample/src/main/flex/TableExample.mxml
>> @@ -27,6 +27,9 @@
>> <js:valuesImpl>
>> <js:SimpleCSSValuesImpl />
>> </js:valuesImpl>
>> + <js:model>
>> + <models:ProductsModel />
>> + </js:model>
>> <js:initialView>
>> <local:MyInitialView />
>> </js:initialView>
>>
>>
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-u
>>s.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Fblob%2F&data=02%7C01%7C%7C973eb1
>>da47de43ee8ff308d491a3d089%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6
>>36293580155665477&sdata=lKg4ES5s2EUHsYKZqLX2ADXkVYodqZxqmtbLE6443yM%3D&re
>>served=0
>> 336fac64/examples/flexjs/TableExample/src/main/flex/
>> dataTable/DataColumn.as
>> ----------------------------------------------------------------------
>> diff --git
>>a/examples/flexjs/TableExample/src/main/flex/dataTable/DataColumn.as
>> b/examples/flexjs/TableExample/src/main/flex/dataTable/DataColumn.as
>> new file mode 100644
>> index 0000000..b8e5f2e
>> --- /dev/null
>> +++ b/examples/flexjs/TableExample/src/main/flex/dataTable/DataColumn.as
>> @@ -0,0 +1,33 @@
>> +///////////////////////////////////////////////////////////
>> /////////////////////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed
>>with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance
>>with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +//
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.apach
>>e.org%2Flicenses%2FLICENSE-2.0&data=02%7C01%7C%7C973eb1da47de43ee8ff308d4
>>91a3d089%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636293580155665477&
>>sdata=IekeMPQyd7Eg%2FLaERDHd7oKWYArTngVw701ertvhsL4%3D&reserved=0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +///////////////////////////////////////////////////////////
>> /////////////////////
>> +package dataTable
>> +{
>> + import org.apache.flex.html.supportClasses.DataGridColumn;
>> +
>> + /**
>> + * DataColumn is exactly like DataGridColumn
>> + */
>> + public class DataColumn extends DataGridColumn
>> + {
>> + public function DataColumn()
>> + {
>> + super();
>> + }
>> + }
>> +}
>> \ No newline at end of file
>>
>>
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-u
>>s.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Fblob%2F&data=02%7C01%7C%7C973eb1
>>da47de43ee8ff308d491a3d089%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6
>>36293580155665477&sdata=lKg4ES5s2EUHsYKZqLX2ADXkVYodqZxqmtbLE6443yM%3D&re
>>served=0
>>
>>336fac64/examples/flexjs/TableExample/src/main/flex/dataTable/DataTable.a
>>s
>> ----------------------------------------------------------------------
>> diff --git
>>a/examples/flexjs/TableExample/src/main/flex/dataTable/DataTable.as
>> b/examples/flexjs/TableExample/src/main/flex/dataTable/DataTable.as
>> new file mode 100644
>> index 0000000..1b388b6
>> --- /dev/null
>> +++ b/examples/flexjs/TableExample/src/main/flex/dataTable/DataTable.as
>> @@ -0,0 +1,69 @@
>> +///////////////////////////////////////////////////////////
>> /////////////////////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed
>>with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance
>>with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +//
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.apach
>>e.org%2Flicenses%2FLICENSE-2.0&data=02%7C01%7C%7C973eb1da47de43ee8ff308d4
>>91a3d089%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636293580155665477&
>>sdata=IekeMPQyd7Eg%2FLaERDHd7oKWYArTngVw701ertvhsL4%3D&reserved=0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +///////////////////////////////////////////////////////////
>> /////////////////////
>> +package dataTable
>> +{
>> + import dataTable.mapper.DataTableMapperForArrayListData;
>> + import dataTable.model.DataTableModel;
>> +
>> + import org.apache.flex.events.Event;
>> + import org.apache.flex.html.Table;
>> +
>> + [DefaultProperty("columns")]
>> +
>> + /**
>> + * The DataTable uses Table along with a data mapper and item
>> renderers to generate
>> + * a Table from a data source.
>> + */
>> + public class DataTable extends Table
>> + {
>> + public function DataTable()
>> + {
>> + super();
>> +
>> + className = "DataTable";
>> + }
>> +
>> + public function get columns():Array
>> + {
>> + return DataTableModel(model).columns;
>> + }
>> + public function set columns(value:Array):void
>> + {
>> + DataTableModel(model).columns = value;
>> + }
>> +
>> + public function get dataProvider():Object
>> + {
>> + return DataTableModel(model).dataProvider;
>> + }
>> + public function set dataProvider(value:Object):void
>> + {
>> + DataTableModel(model).dataProvider = value;
>> + }
>> +
>> + override public function addedToParent():void
>> + {
>> + super.addedToParent();
>> +
>> + addBead(new DataTableMapperForArrayListData());
>> +
>> + dispatchEvent( new Event("initComplete") );
>> + }
>> + }
>> +}
>> \ No newline at end of file
>>
>>
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-u
>>s.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Fblob%2F&data=02%7C01%7C%7C973eb1
>>da47de43ee8ff308d491a3d089%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6
>>36293580155665477&sdata=lKg4ES5s2EUHsYKZqLX2ADXkVYodqZxqmtbLE6443yM%3D&re
>>served=0
>> 336fac64/examples/flexjs/TableExample/src/main/flex/dataTable/mapper/
>> DataTableMapperForArrayListData.as
>> ----------------------------------------------------------------------
>> diff --git
>>a/examples/flexjs/TableExample/src/main/flex/dataTable/mapper/
>> DataTableMapperForArrayListData.as b/examples/flexjs/
>>
>>TableExample/src/main/flex/dataTable/mapper/DataTableMapperForArrayListDa
>>t
>> a.as
>> new file mode 100644
>> index 0000000..c80234c
>> --- /dev/null
>> +++ b/examples/flexjs/TableExample/src/main/flex/dataTable/mapper/
>> DataTableMapperForArrayListData.as
>> @@ -0,0 +1,112 @@
>> +///////////////////////////////////////////////////////////
>> /////////////////////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed
>>with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance
>>with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +//
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.apach
>>e.org%2Flicenses%2FLICENSE-2.0&data=02%7C01%7C%7C973eb1da47de43ee8ff308d4
>>91a3d089%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636293580155665477&
>>sdata=IekeMPQyd7Eg%2FLaERDHd7oKWYArTngVw701ertvhsL4%3D&reserved=0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +///////////////////////////////////////////////////////////
>> /////////////////////
>> +package dataTable.mapper
>> +{
>> + import dataTable.DataColumn;
>> + import dataTable.model.DataTableModel;
>> +
>> + import org.apache.flex.collections.ArrayList;
>> + import org.apache.flex.core.IBead;
>> + import org.apache.flex.core.IBeadModel;
>> + import org.apache.flex.core.IStrand;
>> + import org.apache.flex.events.Event;
>> + import org.apache.flex.events.IEventDispatcher;
>> + import org.apache.flex.html.Label;
>> + import org.apache.flex.html.Table;
>> + import org.apache.flex.html.TableCell;
>> + import org.apache.flex.html.TableHeader;
>> + import org.apache.flex.html.TableRow;
>> + import org.apache.flex.html.supportClasses.DataItemRenderer;
>> +
>> + public class DataTableMapperForArrayListData implements IBead
>> + {
>> + public function DataTableMapperForArrayListData()
>> + {
>> + }
>> +
>> + private var _strand:IStrand;
>> +
>> + public function set strand(value:IStrand):void
>> + {
>> + _strand = value;
>> +
>> +
>>IEventDispatcher(_strand).addEventListener("initComplete",
>> handleInitComplete);
>> + }
>> +
>> + private function handleInitComplete(event:Event):void
>> + {
>> + var model:DataTableModel =
>>_strand.getBeadByType(IBeadModel)
>> as DataTableModel;
>> + if (model == null) return;
>> +
>> + var dp:ArrayList = model.dataProvider as
>>ArrayList;
>> + if (dp == null || dp.length == 0) return;
>> +
>> + var table:Table = _strand as Table;
>> +
>> + var createHeaderRow:Boolean = false;
>> + for(var c:int=0; c < model.columns.length; c++)
>> + {
>> + var test:DataColumn = model.columns[c]
>>as
>> DataColumn;
>> + if (test.label != null) {
>> + createHeaderRow = true;
>> + break;
>> + }
>> + }
>> +
>> + if (createHeaderRow) {
>> + var headerRow:TableRow = new TableRow();
>> +
>> + for(c=0; c < model.columns.length; c++)
>> + {
>> + test = model.columns[c] as
>> DataColumn;
>> + var tableHeader:TableHeader =
>>new
>> TableHeader();
>> + var label:Label = new Label();
>> + tableHeader.addElement(label);
>> + label.text = test.label == null
>>?
>> "" : test.label;
>> +
>>headerRow.addElement(tableHeader);
>> + }
>> +
>> + table.addElement(headerRow);
>> + }
>> +
>> + for(var i:int=0; i < dp.length; i++)
>> + {
>> + var tableRow:TableRow = new TableRow();
>> +
>> + for(var j:int=0; j <
>>model.columns.length;
>> j++)
>> + {
>> + var column:DataColumn =
>> model.columns[j] as DataColumn;
>> + var tableCell:TableCell = new
>> TableCell();
>> +
>> + var ir:DataItemRenderer =
>> column.itemRenderer.newInstance() as DataItemRenderer;
>> + tableCell.addElement(ir);
>> + tableRow.addElement(tableCell);
>> +
>> + ir.labelField =
>>column.dataField;
>> + ir.index = i;
>> + ir.data = dp.getItemAt(i);
>> + }
>> +
>> + table.addElement(tableRow);
>> + }
>> +
>> + table.dispatchEvent(new Event("layoutNeeded"));
>> + }
>> + }
>> +}
>> \ No newline at end of file
>>
>>
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-u
>>s.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Fblob%2F&data=02%7C01%7C%7C973eb1
>>da47de43ee8ff308d491a3d089%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6
>>36293580155665477&sdata=lKg4ES5s2EUHsYKZqLX2ADXkVYodqZxqmtbLE6443yM%3D&re
>>served=0
>> 336fac64/examples/flexjs/TableExample/src/main/flex/dataTable/model/
>> DataTableModel.as
>> ----------------------------------------------------------------------
>> diff --git
>>a/examples/flexjs/TableExample/src/main/flex/dataTable/model/DataTableMod
>>el.as
>> b/examples/flexjs/TableExample/src/main/flex/dataTable/model/
>> DataTableModel.as
>> new file mode 100644
>> index 0000000..084b512
>> --- /dev/null
>> +++ b/examples/flexjs/TableExample/src/main/flex/dataTable/model/
>> DataTableModel.as
>> @@ -0,0 +1,40 @@
>> +///////////////////////////////////////////////////////////
>> /////////////////////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed
>>with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance
>>with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +//
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.apach
>>e.org%2Flicenses%2FLICENSE-2.0&data=02%7C01%7C%7C973eb1da47de43ee8ff308d4
>>91a3d089%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636293580155665477&
>>sdata=IekeMPQyd7Eg%2FLaERDHd7oKWYArTngVw701ertvhsL4%3D&reserved=0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +///////////////////////////////////////////////////////////
>> /////////////////////
>> +package dataTable.model
>> +{
>> + import
>>org.apache.flex.html.beads.models.ArrayListSelectionModel;
>> +
>> + public class DataTableModel extends ArrayListSelectionModel
>> + {
>> + public function DataTableModel()
>> + {
>> + super();
>> + }
>> +
>> + private var _columns:Array;
>> + public function get columns():Array
>> + {
>> + return _columns;
>> + }
>> + public function set columns(value:Array):void
>> + {
>> + _columns = value;
>> + }
>> + }
>> +}
>> \ No newline at end of file
>>
>>
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-u
>>s.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Fblob%2F&data=02%7C01%7C%7C973eb1
>>da47de43ee8ff308d491a3d089%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6
>>36293580155665477&sdata=lKg4ES5s2EUHsYKZqLX2ADXkVYodqZxqmtbLE6443yM%3D&re
>>served=0
>> 336fac64/examples/flexjs/TableExample/src/main/flex/
>> models/ProductsModel.as
>> ----------------------------------------------------------------------
>> diff --git
>>a/examples/flexjs/TableExample/src/main/flex/models/ProductsModel.as
>> b/examples/flexjs/TableExample/src/main/flex/models/ProductsModel.as
>> new file mode 100644
>> index 0000000..06a9b9b
>> --- /dev/null
>> +++ b/examples/flexjs/TableExample/src/main/flex/models/ProductsModel.as
>> @@ -0,0 +1,47 @@
>> +///////////////////////////////////////////////////////////
>> /////////////////////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed
>>with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance
>>with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +//
>>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.apach
>>e.org%2Flicenses%2FLICENSE-2.0&data=02%7C01%7C%7C973eb1da47de43ee8ff308d4
>>91a3d089%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636293580155665477&
>>sdata=IekeMPQyd7Eg%2FLaERDHd7oKWYArTngVw701ertvhsL4%3D&reserved=0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +///////////////////////////////////////////////////////////
>> /////////////////////
>> +package models
>> +{
>> + import org.apache.flex.collections.ArrayList;
>> +
>> + public class ProductsModel
>> + {
>> + public function ProductsModel()
>> + {
>> + }
>> +
>> + private var _products:ArrayList = new ArrayList([
>> + {name: "British Columbia", capital: "Vancouver",
>> country: "Canada"},
>> + {name: "Coahuila", capital: "Saltilli", country:
>> "Mexico"},
>> + {name: "Georgia", capital: "Atlanta", country:
>> "USA"},
>> + {name: "Kyoto", capital: "Kyoto", country:
>> "Japan"},
>> + {name: "Massachusetts", capital: "Boston",
>> country: "USA"},
>> + {name: "New South Wales", capital: "Sydney",
>> country: "Australia"},
>> + {name: "Quebec", capital: "Montreal", country:
>> "Canada"},
>> + {name: "Shimane", capital: "Matsue", country:
>> "Japan"},
>> + {name: "Victoria", capital: "Melbourne",
>>country:
>> "Australia"},
>> + {name: "Yucatan", capital: "Merida", country:
>> "Mexico"}
>> + ]);
>> +
>> + public function get products():ArrayList
>> + {
>> + return _products;
>> + }
>> + }
>> +}
>> \ No newline at end of file
>>
>>