You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by piotrz <pi...@gmail.com> on 2017/05/01 12:35:25 UTC

[FlexJS, MDL] Null Pointer Exception in HorizontalFlexLayout

Hi Peter,

During creation of DropDownList component in MDL I have experienced Null
Pointer Exception in HorizontalFlexLayout. [1]

Issue:
My DropDownList contains 3 elements: Div with selected text, Material icon
(i) and Menu.

Case 1: If I create DropDownList in MXML - MDL library handle properly
upgrading. 

Menu is a simple ul, but once upgrade is done MDL library surround it by
additional div [2] "mdl-menu__container".

HorizontalFlexLayout is going through the children of View in function
"layout". Array contains 3 elements from my DropDownList - the last one is
menu - in moment of layout perform it contains "ul" not
"mdl-menu__container".

<http://apache-flex-development.2333347.n4.nabble.com/file/n61437/horizontalflex_layout.png> 

This "ul" has been created by FlexJS and has element.flexjs_wrapper. and
function getElementAt returns child one by one.

Case 2 - ISSUE:

I would like to create DropDownList dynamically:

var dropDown:DropDownList = new DropDownList();
addElement(dropDown);

In order to do this Menu inside DropDownList need to be "upgraded" manually
- I need to tell MDL library that I've created Menu component - I have bead
for that purpose which doing his job: UpgradeElement.

Upgrade is completed successfully and MDL is surrounding "ul" by
"mdl-menu__container".

Now HorizontalFlexLayout is doing "layout" and trying to go through the
children. In array for some reason there is no "ul" MDL Menu, but this
"mdl-menu__container" which wasn't created by FlexJS. In that case it
doesn't have element.flexjs_wrapper, so getElementAt returns null. And we
are getting NPE.

It look like everything what HorizontalFlexLayout is doing in Case 1
happened before upgrading - in case 2 I'm doing upgrade during whole life
cycle performance.

I hope this long explanation help you understand issue and provide some
feedback. I'm attaching simple project where you can reproduce this issue
[3]

[1] https://paste.apache.org/9oRP
[2] https://paste.apache.org/iN4K
[3] https://1drv.ms/u/s!ApVpLyjpHDC2zTehS-kv_1g0cgSY

Piotr

 




-----
Apache Flex PMC
piotrzarzycki21@gmail.com
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-MDL-Null-Pointer-Exception-in-HorizontalFlexLayout-tp61437.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.

Re: [FlexJS, MDL] Null Pointer Exception in HorizontalFlexLayout

Posted by Peter Ent <pe...@adobe.com>.
OK. I will look at the other layouts and probably do the same for them
where it makes sense.

On 5/1/17, 10:06 AM, "piotrz" <pi...@gmail.com> wrote:

>Thank you Peter. That helped. I was thinking about such solution, but
>wasn't
>sure whether it won't break anything. If I'm thinking more about that it
>makes sense do not bother non UIBase component here.
>
>Piotr
>
>
>
>-----
>Apache Flex PMC
>piotrzarzycki21@gmail.com
>--
>View this message in context:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fle
>x-development.2333347.n4.nabble.com%2FFlexJS-MDL-Null-Pointer-Exception-in
>-HorizontalFlexLayout-tp61437p61441.html&data=02%7C01%7C%7C61b665f8d3134b4
>d5cf708d4909cf543%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C63629245119
>9825874&sdata=7%2Bpqd%2FKFt%2FRaA%2Bvml%2BcTIspcY2r9iuxYRUcdKegANRg%3D&res
>erved=0
>Sent from the Apache Flex Development mailing list archive at Nabble.com.


Re: [FlexJS, MDL] Null Pointer Exception in HorizontalFlexLayout

Posted by piotrz <pi...@gmail.com>.
Thank you Peter. That helped. I was thinking about such solution, but wasn't
sure whether it won't break anything. If I'm thinking more about that it
makes sense do not bother non UIBase component here.

Piotr



-----
Apache Flex PMC
piotrzarzycki21@gmail.com
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-MDL-Null-Pointer-Exception-in-HorizontalFlexLayout-tp61437p61441.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.

Re: [FlexJS, MDL] Null Pointer Exception in HorizontalFlexLayout

Posted by Peter Ent <pe...@adobe.com>.
Hi Piotr,

I mostly understand. It seems like the child is not UIBase so it is null,
at least in one of the cases. The layout code should be changed to check
for null and skip that child.  Can you see if that helps?

‹peter

On 5/1/17, 8:35 AM, "piotrz" <pi...@gmail.com> wrote:

>Hi Peter,
>
>During creation of DropDownList component in MDL I have experienced Null
>Pointer Exception in HorizontalFlexLayout. [1]
>
>Issue:
>My DropDownList contains 3 elements: Div with selected text, Material icon
>(i) and Menu.
>
>Case 1: If I create DropDownList in MXML - MDL library handle properly
>upgrading. 
>
>Menu is a simple ul, but once upgrade is done MDL library surround it by
>additional div [2] "mdl-menu__container".
>
>HorizontalFlexLayout is going through the children of View in function
>"layout". Array contains 3 elements from my DropDownList - the last one is
>menu - in moment of layout perform it contains "ul" not
>"mdl-menu__container".
>
><https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fl
>ex-development.2333347.n4.nabble.com%2Ffile%2Fn61437%2Fhorizontalflex_layo
>ut.png&data=02%7C01%7C%7C92f8ef48e030413571a708d490902c50%7Cfa7b1b5a7b3443
>8794aed2c178decee1%7C0%7C0%7C636292396295241298&sdata=TTsjYE1G7SohYeujGKKB
>DvIAC7JYha3fPcUbkF4TbaY%3D&reserved=0>
>
>This "ul" has been created by FlexJS and has element.flexjs_wrapper. and
>function getElementAt returns child one by one.
>
>Case 2 - ISSUE:
>
>I would like to create DropDownList dynamically:
>
>var dropDown:DropDownList = new DropDownList();
>addElement(dropDown);
>
>In order to do this Menu inside DropDownList need to be "upgraded"
>manually
>- I need to tell MDL library that I've created Menu component - I have
>bead
>for that purpose which doing his job: UpgradeElement.
>
>Upgrade is completed successfully and MDL is surrounding "ul" by
>"mdl-menu__container".
>
>Now HorizontalFlexLayout is doing "layout" and trying to go through the
>children. In array for some reason there is no "ul" MDL Menu, but this
>"mdl-menu__container" which wasn't created by FlexJS. In that case it
>doesn't have element.flexjs_wrapper, so getElementAt returns null. And we
>are getting NPE.
>
>It look like everything what HorizontalFlexLayout is doing in Case 1
>happened before upgrading - in case 2 I'm doing upgrade during whole life
>cycle performance.
>
>I hope this long explanation help you understand issue and provide some
>feedback. I'm attaching simple project where you can reproduce this issue
>[3]
>
>[1] 
>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpaste.apa
>che.org%2F9oRP&data=02%7C01%7C%7C92f8ef48e030413571a708d490902c50%7Cfa7b1b
>5a7b34438794aed2c178decee1%7C0%7C0%7C636292396295241298&sdata=O3iz6XdYaDIO
>6408JrznUhIN%2BU3oiBC2U4eqj4rMTsE%3D&reserved=0
>[2] 
>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpaste.apa
>che.org%2FiN4K&data=02%7C01%7C%7C92f8ef48e030413571a708d490902c50%7Cfa7b1b
>5a7b34438794aed2c178decee1%7C0%7C0%7C636292396295241298&sdata=6ur7OO4g%2Fi
>Sj1IFmWpfJDMwNvQk6PfbuEM2yfackVlE%3D&reserved=0
>[3] 
>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2F1drv.ms%2
>Fu%2Fs!ApVpLyjpHDC2zTehS-kv_1g0cgSY&data=02%7C01%7C%7C92f8ef48e030413571a7
>08d490902c50%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6362923962952412
>98&sdata=wnCIo8EFiKQLZFZVLRMcj%2Fnqg1G1Kwb%2BMJPhN6x1ltE%3D&reserved=0
>
>Piotr
>
> 
>
>
>
>
>-----
>Apache Flex PMC
>piotrzarzycki21@gmail.com
>--
>View this message in context:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fle
>x-development.2333347.n4.nabble.com%2FFlexJS-MDL-Null-Pointer-Exception-in
>-HorizontalFlexLayout-tp61437.html&data=02%7C01%7C%7C92f8ef48e030413571a70
>8d490902c50%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C63629239629524129
>8&sdata=FMk2TnkFIbtdFUEg0ifVD3X%2FmDZq%2BmMoQe2o4RyIi1Y%3D&reserved=0
>Sent from the Apache Flex Development mailing list archive at Nabble.com.