XML construction from resource throws exception : TypeError: Cannot read property 'setAttribute' of undefined

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

XML construction from resource throws exception : TypeError: Cannot read property 'setAttribute' of undefined

serkan
Hİ,

The source below has the exception. Similar one was resolved for XMLList with https://github.com/apache/royale-asjs/issues/545

The error line :

function (value) { this.filterMenuData[1].setAttribute('label', value);},

note : for the index 0 it works.

Thanks,
Serkan



<?xml version="1.0" encoding="latin5" ?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.apache.org/royale/spark"
               xmlns:mx="library://ns.apache.org/royale/mx"
               height="288" width="179"
               >
    <fx:Metadata>
        [ResourceBundle("messages")]
    </fx:Metadata>

    <fx:Script>
        <![CDATA[
        ]]>
    </fx:Script>

    <fx:Declarations>
        <fx:XML format="e4x" id="filterMenuData">
            <menuitem label="{resourceManager.getString('messages', 'statusFilter')}" id="statusFilter">
                <menuitem label="{resourceManager.getString('messages', 'listAll')}"/>            
                <menuitem label="{resourceManager.getString('messages', 'readyFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'waitingFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'workingFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'successfulFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'failedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'timeoutFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'skippedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'stoppedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'pausedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'disabledFilter')}"/>
            </menuitem>
        </fx:XML>
    </fx:Declarations>
        
</s:Application>


Reply | Threaded
Open this post in threaded view
|

Re: XML construction from resource throws exception : TypeError: Cannot read property 'setAttribute' of undefined

Greg Dove

if it is XML, then it index [1] should not work. Only index [0] is valid for an XML instance;
when you access [0] on an XML instance it returns the same instance.

var xml:XML = <root><child/></root>

trace(xml[1])//undefined
trace(xml[0])//same as xml.toString()

If it is an XMLList then it can have index values greater than zero.


On Tue, Apr 28, 2020 at 4:19 PM serkan <[hidden email]> wrote:
Hİ,

The source below has the exception. Similar one was resolved for XMLList with https://github.com/apache/royale-asjs/issues/545

The error line :

function (value) { this.filterMenuData[1].setAttribute('label', value);},

note : for the index 0 it works.

Thanks,
Serkan



<?xml version="1.0" encoding="latin5" ?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.apache.org/royale/spark"
               xmlns:mx="library://ns.apache.org/royale/mx"
               height="288" width="179"
               >
    <fx:Metadata>
        [ResourceBundle("messages")]
    </fx:Metadata>

    <fx:Script>
        <![CDATA[
        ]]>
    </fx:Script>

    <fx:Declarations>
        <fx:XML format="e4x" id="filterMenuData">
            <menuitem label="{resourceManager.getString('messages', 'statusFilter')}" id="statusFilter">
                <menuitem label="{resourceManager.getString('messages', 'listAll')}"/>            
                <menuitem label="{resourceManager.getString('messages', 'readyFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'waitingFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'workingFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'successfulFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'failedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'timeoutFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'skippedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'stoppedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'pausedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'disabledFilter')}"/>
            </menuitem>
        </fx:XML>
    </fx:Declarations>
        
</s:Application>


Reply | Threaded
Open this post in threaded view
|

Re: XML construction from resource throws exception : TypeError: Cannot read property 'setAttribute' of undefined

serkan
Hi Greg,

It is just same as as in flex.

Do you advise me to convert to XMLList ?


Thanks,
Serkan

28.04.2020 08:56 tarihinde Greg Dove yazdı:

if it is XML, then it index [1] should not work. Only index [0] is valid for an XML instance;
when you access [0] on an XML instance it returns the same instance.

var xml:XML = <root><child/></root>

trace(xml[1])//undefined
trace(xml[0])//same as xml.toString()

If it is an XMLList then it can have index values greater than zero.


On Tue, Apr 28, 2020 at 4:19 PM serkan <[hidden email]> wrote:
Hİ,

The source below has the exception. Similar one was resolved for XMLList with https://github.com/apache/royale-asjs/issues/545

The error line :

function (value) { this.filterMenuData[1].setAttribute('label', value);},

note : for the index 0 it works.

Thanks,
Serkan



<?xml version="1.0" encoding="latin5" ?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.apache.org/royale/spark"
               xmlns:mx="library://ns.apache.org/royale/mx"
               height="288" width="179"
               >
    <fx:Metadata>
        [ResourceBundle("messages")]
    </fx:Metadata>

    <fx:Script>
        <![CDATA[
        ]]>
    </fx:Script>

    <fx:Declarations>
        <fx:XML format="e4x" id="filterMenuData">
            <menuitem label="{resourceManager.getString('messages', 'statusFilter')}" id="statusFilter">
                <menuitem label="{resourceManager.getString('messages', 'listAll')}"/>            
                <menuitem label="{resourceManager.getString('messages', 'readyFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'waitingFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'workingFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'successfulFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'failedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'timeoutFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'skippedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'stoppedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'pausedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'disabledFilter')}"/>
            </menuitem>
        </fx:XML>
    </fx:Declarations>
        
</s:Application>



Reply | Threaded
Open this post in threaded view
|

Re: XML construction from resource throws exception : TypeError: Cannot read property 'setAttribute' of undefined

Greg Dove

Hi Serkan,
If it's the same as Flex, then please log an issue with that same example code (if you can swap all the resourceManager requests to plain strings, it will be easier for us to use it when investigating/fixing the issue)
I am not sure yet why that would be valid in Flex, unless it is treated specially via mxml as an XMLList. An XML instance definitely only makes sense with [0] (and that is only to make it more compatible with XMLList in e4x expressions I think, not for any other reason).

Please log the issue under royale-asjs, but it sounds like it might end up needing a fix in royale-compiler.


On Tue, Apr 28, 2020 at 8:34 PM serkan <[hidden email]> wrote:
Hi Greg,

It is just same as as in flex.

Do you advise me to convert to XMLList ?


Thanks,
Serkan

28.04.2020 08:56 tarihinde Greg Dove yazdı:

if it is XML, then it index [1] should not work. Only index [0] is valid for an XML instance;
when you access [0] on an XML instance it returns the same instance.

var xml:XML = <root><child/></root>

trace(xml[1])//undefined
trace(xml[0])//same as xml.toString()

If it is an XMLList then it can have index values greater than zero.


On Tue, Apr 28, 2020 at 4:19 PM serkan <[hidden email]> wrote:
Hİ,

The source below has the exception. Similar one was resolved for XMLList with https://github.com/apache/royale-asjs/issues/545

The error line :

function (value) { this.filterMenuData[1].setAttribute('label', value);},

note : for the index 0 it works.

Thanks,
Serkan



<?xml version="1.0" encoding="latin5" ?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.apache.org/royale/spark"
               xmlns:mx="library://ns.apache.org/royale/mx"
               height="288" width="179"
               >
    <fx:Metadata>
        [ResourceBundle("messages")]
    </fx:Metadata>

    <fx:Script>
        <![CDATA[
        ]]>
    </fx:Script>

    <fx:Declarations>
        <fx:XML format="e4x" id="filterMenuData">
            <menuitem label="{resourceManager.getString('messages', 'statusFilter')}" id="statusFilter">
                <menuitem label="{resourceManager.getString('messages', 'listAll')}"/>            
                <menuitem label="{resourceManager.getString('messages', 'readyFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'waitingFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'workingFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'successfulFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'failedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'timeoutFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'skippedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'stoppedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'pausedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'disabledFilter')}"/>
            </menuitem>
        </fx:XML>
    </fx:Declarations>
        
</s:Application>



Reply | Threaded
Open this post in threaded view
|

Re: XML construction from resource throws exception : TypeError: Cannot read property 'setAttribute' of undefined

serkan
In reply to this post by serkan
Hi Greg,

I tested the XMLList version it looks like can work after the issues with menu resolved.

I can access the index :

this.filterMenuData[1] and so.

If it is planned to support the same approach as flex I may create and issue. If not than I can use XMLLlist

Thanks,
Serkan


28.04.2020 11:33 tarihinde serkan yazdı:
Hi Greg,

It is just same as as in flex.

Do you advise me to convert to XMLList ?


Thanks,
Serkan

28.04.2020 08:56 tarihinde Greg Dove yazdı:

if it is XML, then it index [1] should not work. Only index [0] is valid for an XML instance;
when you access [0] on an XML instance it returns the same instance.

var xml:XML = <root><child/></root>

trace(xml[1])//undefined
trace(xml[0])//same as xml.toString()

If it is an XMLList then it can have index values greater than zero.


On Tue, Apr 28, 2020 at 4:19 PM serkan <[hidden email]> wrote:
Hİ,

The source below has the exception. Similar one was resolved for XMLList with https://github.com/apache/royale-asjs/issues/545

The error line :

function (value) { this.filterMenuData[1].setAttribute('label', value);},

note : for the index 0 it works.

Thanks,
Serkan



<?xml version="1.0" encoding="latin5" ?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.apache.org/royale/spark"
               xmlns:mx="library://ns.apache.org/royale/mx"
               height="288" width="179"
               >
    <fx:Metadata>
        [ResourceBundle("messages")]
    </fx:Metadata>

    <fx:Script>
        <![CDATA[
        ]]>
    </fx:Script>

    <fx:Declarations>
        <fx:XML format="e4x" id="filterMenuData">
            <menuitem label="{resourceManager.getString('messages', 'statusFilter')}" id="statusFilter">
                <menuitem label="{resourceManager.getString('messages', 'listAll')}"/>            
                <menuitem label="{resourceManager.getString('messages', 'readyFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'waitingFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'workingFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'successfulFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'failedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'timeoutFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'skippedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'stoppedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'pausedFilter')}"/>
                <menuitem label="{resourceManager.getString('messages', 'disabledFilter')}"/>
            </menuitem>
        </fx:XML>
    </fx:Declarations>
        
</s:Application>