Search code examples
datagridapache-royale

How to use js:DataGrid on Apache Royale ? Issue with Language.synthType


I have an issue using this code, I don't know what Language.synthType is...

Used SDK is 0.9.6

<j:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:local="*"
                   xmlns:models="models.*"
                   xmlns:js="library://ns.apache.org/royale/basic"  
                   xmlns:j="library://ns.apache.org/royale/jewel" 
                   xmlns:binding="org.apache.royale.binding.*"
                   applicationComplete="ev_applicationComplete()">
    <fx:Script>
        <![CDATA[
            import org.apache.royale.collections.ArrayList;



            private function ev_applicationComplete():void {
                dg.dataProvider = new ArrayList( [
                        {label:'Apple',code:'1'},
                        {label:'Nuts',code:'2'}
                    ]);
            }

        ]]>
    </fx:Script>

    <js:valuesImpl>
        <js:SimpleCSSValuesImpl />
    </js:valuesImpl>

    <js:initialView >
        <j:View>
            <j:beads>
                <js:ContainerDataBinding/>
            </j:beads>

            <js:DataGrid id="dg" width="600" height="300">
                <js:columns>
                    <js:DataGridColumn label="Label" dataField="label" columnWidth="300" />
                    <js:DataGridColumn label="Code" dataField="code"  columnWidth="300"/>
                </js:columns>
            </js:DataGrid>
        </j:View>
    </js:initialView>
</j:Application>

When running code this issue is throw

EventDispatcher.js:74 Uncaught TypeError: org.apache.royale.utils.Language.synthType is not a function
    at org.apache.royale.html.beads.DataGridView.handleInitComplete (DataGridView.js:88)
    at org.apache.royale.html.DataGrid.goog.events.EventTarget.fireListeners (eventtarget.js:284)
    at Function.goog.events.EventTarget.dispatchEventInternal_ (eventtarget.js:382)
    at org.apache.royale.html.DataGrid.goog.events.EventTarget.dispatchEvent (eventtarget.js:196)
    at org.apache.royale.html.DataGrid.org.apache.royale.events.EventDispatcher.dispatchEvent (EventDispatcher.js:71)
    at org.apache.royale.html.DataGrid.org.apache.royale.core.HTMLElementWrapper.dispatchEvent (HTMLElementWrapper.js:245)
    at org.apache.royale.html.DataGrid.addedToParent (DataGrid.js:58)
    at org.apache.royale.jewel.View.org.apache.royale.core.UIBase.addElement (UIBase.js:414)
    at org.apache.royale.jewel.View.org.apache.royale.core.GroupBase.addElement (GroupBase.js:165)
    at Function.org.apache.royale.utils.MXMLDataInterpreter.org_apache_royale_utils_MXMLDataInterpreter_initializeStrandBasedObject (MXMLDataInterpreter.js:236)

Solution

  • That Language.synthType function supports some specific cases when using int, uint, and Class in a very minimal way for typechecking and basic instantiations when held as Class variables ( e.g. var intClass:Class = int; <- you can now use intClass as expected to create an int).

    In this specific case it is being used for some ' as Class' type checks, which we can actually optimize out in future builds (because it will be sufficient to do non-null checks in the related site in the DataGridView code - this is all just additional explanation in case you are interested, don't worry about that detail).

    So I can understand where the problem is, but I don't understand why your copy of org.apache.royale.utils.Language is missing that function. Is there any chance that you are using an older version of the Language library mixed with the latest 0.9.6 SDK? Or maybe you are using a library that was compiled with an older version of the SDK. I suggest you double check with a 'clean' build if you did not do that already. If you check in a debug build output, can you confirm that the following is true in your javascript console:

    typeof org.apache.royale.utils.Language.synthType == 'function'
    

    If you don't see that, then there must be some conflict between your library versions I think, perhaps an older version of the Language library being used somewhere... If you can provide more details maybe I can help.