flex-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Curtis Aube (JIRA)" <j...@apache.org>
Subject [jira] [Created] (FLEX-34022) Null object reference when setting columns on Spark DataGrid
Date Fri, 03 Jan 2014 18:35:54 GMT
Curtis Aube created FLEX-34022:
----------------------------------

             Summary: Null object reference when setting columns on Spark DataGrid
                 Key: FLEX-34022
                 URL: https://issues.apache.org/jira/browse/FLEX-34022
             Project: Apache Flex
          Issue Type: Bug
          Components: Spark: DataGrid
    Affects Versions: Apache Flex 4.11.0, Apache Flex 4.9.0
         Environment: Mac OS X
            Reporter: Curtis Aube


If you set a bindable columns property for the DataGrid before it is initialized and set an
itemRenderer for one of the columns, you get a null object reference when the DataGrid is
initialized.

Here is an example:
<?xml version="1.0" encoding="utf-8"?>
<s:Application creationComplete="creationComplete()" minHeight="600" minWidth="955" preinitialize="setColumns()"
xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"
			   xmlns:s="library://ns.adobe.com/flex/spark">
	<fx:Script>
		<![CDATA[
			import mx.collections.ArrayCollection;
			import mx.collections.ArrayList;
			import spark.components.gridClasses.GridColumn;
			import spark.skins.spark.DefaultItemRenderer;

			[Bindable]
			private var columns:ArrayList;
			[Bindable]
			private var dp:ArrayCollection;

			private function creationComplete():void
			{
				var myHistoryItems:Array = new Array;
				myHistoryItems.push({filename: "Testing"});
				dp = new ArrayCollection(myHistoryItems);
			}

			private function setColumns():void
			{
				var column:GridColumn
				var myColumns:ArrayList = new ArrayList;

				column = new GridColumn("filename");
				column.headerText = "Filename";
				column.itemRenderer = new ClassFactory(DefaultItemRenderer);
				myColumns.addItem(column);

				columns = myColumns;
			}
		]]>
	</fx:Script>
	<s:DataGrid height="100%" width="100%" columns="{columns}" dataProvider="{dp}"/>
</s:Application>

Here is the stack trace:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at spark.components::Group/addElement()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/spark/src/spark/components/Group.as:1395]
	at spark.components.gridClasses::GridLayout/createTypicalItemRenderer()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/spark/src/spark/components/gridClasses/GridLayout.as:756]
	at spark.components.gridClasses::GridLayout/updateTypicalCellSizes()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/spark/src/spark/components/gridClasses/GridLayout.as:891]
	at spark.components.gridClasses::GridLayout/measure()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/spark/src/spark/components/gridClasses/GridLayout.as:452]
	at spark.components.supportClasses::GroupBase/measure()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/spark/src/spark/components/supportClasses/GroupBase.as:1156]
	at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::measureSizes()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/framework/src/mx/core/UIComponent.as:8514]
	at mx.core::UIComponent/validateSize()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/framework/src/mx/core/UIComponent.as:8438]
	at spark.components::Group/validateSize()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/spark/src/spark/components/Group.as:1065]
	at mx.managers::LayoutManager/validateSize()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/framework/src/mx/managers/LayoutManager.as:673]
	at mx.managers::LayoutManager/doPhasedInstantiation()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/framework/src/mx/managers/LayoutManager.as:800]
	at mx.managers::LayoutManager/doPhasedInstantiationCallback()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/framework/src/mx/managers/LayoutManager.as:1188]




--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message