You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Kyle McKnight <ka...@gmail.com> on 2016/10/25 18:04:01 UTC

Do ItemRenderer's get reused across different components?

I have a List, ParentList, that has a VerticalLayout. Within ParentList is
another List, ChildList with a TileLayout.

During points in my application, ParentList gets updated which then also
means ChildList gets updated. What is weird is that the same ChildList will
show different sizes of the children randomly when I leave and come back to
the the page.

So let's say I set the selected index on ParentList to index 5. ChildList
gets updated with a subset of data, arbitrarily DataA...DataN. Each
renderer in ChildList will be width X. But then I set ParentList to index 6
and then later back to 5. So viewing the same set of data, DataA...DataN,
yet this time the TileLayout will have the children be width Z instead of
the same width X it was before.

Sorry if that's confusing lol. Basically the same TileLayout with the same
data will size taht data differently.

So this leads me to wonder if renderers are reused even if they are
contained withing different components as long as they use the same Class
of renderer? Is this happening because when the data is set on the
ChildList renderer's I'm not resetting everything to some default state?

Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

Re: Do ItemRenderer's get reused across different components?

Posted by kamcknig <ka...@gmail.com>.
Lol. Gnarly.Good word for it :)



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Do-ItemRenderer-s-get-reused-across-different-components-tp13928p13952.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: Do ItemRenderer's get reused across different components?

Posted by Clint M <cm...@gmail.com>.
was able to reproduce... pretty gnarly... assigning a new XMLList with the
same content multiple times yields different tilelayout arrangements.

On Wed, Oct 26, 2016 at 4:33 AM, kamcknig <ka...@gmail.com> wrote:

> Test project attached. If you just click each of the buttons multiple
> times,
> as in "set 1" two or three times, then set 2 two or three times, you'll see
> it keeps resetting the width. The width should auto fit to the shortest
> text
> each time.
>
> test.zip
> <http://apache-flex-users.2333346.n4.nabble.com/file/n13945/test.zip>
>
>
>
> --
> View this message in context: http://apache-flex-users.
> 2333346.n4.nabble.com/Do-ItemRenderer-s-get-reused-
> across-different-components-tp13928p13945.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>

Re: Do ItemRenderer's get reused across different components?

Posted by Alex Harui <ah...@adobe.com>.

On 10/26/16, 12:02 PM, "kamcknig" <ka...@gmail.com> wrote:

>Awesome thanks! I'll consider this answered. If I do play with it more and
>get it figured out I'll post the solution though.
>

One more thing that might also help when using virtual layout is
explicitly setting typicalItemRenderer to an extra instance of an item
renderer and assigning that renderer the data that has the longest text.
Otherwise, I think the layout uses the first data item.

HTH,
-Alex


Re: Do ItemRenderer's get reused across different components?

Posted by kamcknig <ka...@gmail.com>.
Awesome thanks! I'll consider this answered. If I do play with it more and
get it figured out I'll post the solution though.




Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

On Wed, Oct 26, 2016 at 2:54 PM, Alex Harui [via Apache Flex Users] <
ml-node+s2333346n13956h90@n4.nabble.com> wrote:

>
>
> On 10/26/16, 11:59 AM, "Kyle McKnight" <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=13956&i=0>> wrote:
>
> >Apologies I meant longest text.
> >
> >It definitely works with useVirtualLayout set to false, I have already
> >tried that and it works just fine. And technically I don't have enough
> >renderers at once that that would actually be fine. I just was trying to
> >figure this out as more of a learning experience since general practice
> is
> >to use virtual layouts.
>
> If you want to keep playing with it, you can see if a call to
> TileLayout.clearVirtualLayoutCache also brings you more stability.  You
> might need to make a custom version of TileLayout that calls
> clearVirtualLayoutCache() at the beginning of measure()
>
> HTH,
> -Alex
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://apache-flex-users.2333346.n4.nabble.com/Do-
> ItemRenderer-s-get-reused-across-different-components-tp13928p13956.html
> To unsubscribe from Do ItemRenderer's get reused across different
> components?, click here
> <http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=13928&code=a2FtY2tuaWdAZ21haWwuY29tfDEzOTI4fC0xNTg3MjQ1NTM4>
> .
> NAML
> <http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Do-ItemRenderer-s-get-reused-across-different-components-tp13928p13957.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: Do ItemRenderer's get reused across different components?

Posted by Alex Harui <ah...@adobe.com>.

On 10/26/16, 11:59 AM, "Kyle McKnight" <ka...@gmail.com> wrote:

>Apologies I meant longest text.
>
>It definitely works with useVirtualLayout set to false, I have already
>tried that and it works just fine. And technically I don't have enough
>renderers at once that that would actually be fine. I just was trying to
>figure this out as more of a learning experience since general practice is
>to use virtual layouts.

If you want to keep playing with it, you can see if a call to
TileLayout.clearVirtualLayoutCache also brings you more stability.  You
might need to make a custom version of TileLayout that calls
clearVirtualLayoutCache() at the beginning of measure()

HTH,
-Alex


Re: Do ItemRenderer's get reused across different components?

Posted by Kyle McKnight <ka...@gmail.com>.
Apologies I meant longest text.

It definitely works with useVirtualLayout set to false, I have already
tried that and it works just fine. And technically I don't have enough
renderers at once that that would actually be fine. I just was trying to
figure this out as more of a learning experience since general practice is
to use virtual layouts.


Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

On Wed, Oct 26, 2016 at 2:56 PM, Alex Harui <ah...@adobe.com> wrote:

>
>
> On 10/26/16, 4:33 AM, "kamcknig" <ka...@gmail.com> wrote:
>
> >Test project attached. If you just click each of the buttons multiple
> >times,
> >as in "set 1" two or three times, then set 2 two or three times, you'll
> >see
> >it keeps resetting the width. The width should auto fit to the shortest
> >text
> >each time.
>
> Shortest text?  What happens to longer text?  I don't think I saw any code
> trying to measure and find the shortest.
>
> How many rate renderers do you think you will need?  In your test case,
> the TileLayout has useVirtualLayout=true.  TileLayout does some caching
> when useVirtualLayout=true and I think that's screwing up the app because
> the TileLayout is remembering information from the last layout pass and
> using that in the calculation of the next layout pass.
>
> I set useVirtualLayout="false" on the List containing the TileList and
> things seemed to be more stable.
>
> -Alex
>
>

Re: Do ItemRenderer's get reused across different components?

Posted by Alex Harui <ah...@adobe.com>.

On 10/26/16, 4:33 AM, "kamcknig" <ka...@gmail.com> wrote:

>Test project attached. If you just click each of the buttons multiple
>times,
>as in "set 1" two or three times, then set 2 two or three times, you'll
>see
>it keeps resetting the width. The width should auto fit to the shortest
>text
>each time.

Shortest text?  What happens to longer text?  I don't think I saw any code
trying to measure and find the shortest.

How many rate renderers do you think you will need?  In your test case,
the TileLayout has useVirtualLayout=true.  TileLayout does some caching
when useVirtualLayout=true and I think that's screwing up the app because
the TileLayout is remembering information from the last layout pass and
using that in the calculation of the next layout pass.

I set useVirtualLayout="false" on the List containing the TileList and
things seemed to be more stable.

-Alex


Re: Do ItemRenderer's get reused across different components?

Posted by kamcknig <ka...@gmail.com>.
Test project attached. If you just click each of the buttons multiple times,
as in "set 1" two or three times, then set 2 two or three times, you'll see
it keeps resetting the width. The width should auto fit to the shortest text
each time.

test.zip
<http://apache-flex-users.2333346.n4.nabble.com/file/n13945/test.zip>  



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Do-ItemRenderer-s-get-reused-across-different-components-tp13928p13945.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: Do ItemRenderer's get reused across different components?

Posted by kamcknig <ka...@gmail.com>.
Ill attempt to break that part out into its own project sometime today

On Oct 26, 2016 1:39 AM, "Alex Harui [via Apache Flex Users]" <
ml-node+s2333346n13942h56@n4.nabble.com> wrote:

>
>
> On 10/25/16, 6:41 PM, "Kyle McKnight" <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=13942&i=0>> wrote:
>
> >I only set the explicitWidth.
> >
> >Where would I store the columnWidth once it's attained? Since the parents
> >of the child are also reused, if I stored them in the parent renderer
> then
> >those values might not be right for the next time they are reused. Lol.
> >What a mess! :)
>
> IMO, storing the values is a caching problem.  You will have to know when
> to invalidate the values in the cache.
>
> Let's go back to the renderer.  Can you post the renderer code?  Maybe it
> will be easy to see why the measurements get sticky.
>
> -Alex
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://apache-flex-users.2333346.n4.nabble.com/Do-
> ItemRenderer-s-get-reused-across-different-components-tp13928p13942.html
> To unsubscribe from Do ItemRenderer's get reused across different
> components?, click here
> <http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=13928&code=a2FtY2tuaWdAZ21haWwuY29tfDEzOTI4fC0xNTg3MjQ1NTM4>
> .
> NAML
> <http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Do-ItemRenderer-s-get-reused-across-different-components-tp13928p13944.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: Do ItemRenderer's get reused across different components?

Posted by Alex Harui <ah...@adobe.com>.

On 10/25/16, 6:41 PM, "Kyle McKnight" <ka...@gmail.com> wrote:

>I only set the explicitWidth.
>
>Where would I store the columnWidth once it's attained? Since the parents
>of the child are also reused, if I stored them in the parent renderer then
>those values might not be right for the next time they are reused. Lol.
>What a mess! :)

IMO, storing the values is a caching problem.  You will have to know when
to invalidate the values in the cache.

Let's go back to the renderer.  Can you post the renderer code?  Maybe it
will be easy to see why the measurements get sticky.

-Alex


Re: Do ItemRenderer's get reused across different components?

Posted by Kyle McKnight <ka...@gmail.com>.
I only set the explicitWidth.

Where would I store the columnWidth once it's attained? Since the parents
of the child are also reused, if I stored them in the parent renderer then
those values might not be right for the next time they are reused. Lol.
What a mess! :)


Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

On Tue, Oct 25, 2016 at 9:31 PM, Alex Harui <ah...@adobe.com> wrote:

>
>
> On 10/25/16, 6:19 PM, "Kyle McKnight" <ka...@gmail.com> wrote:
>
> >Hmm, sorry. Couldn't quite figure it out. At the end of the set data
> >override of my ChildList renderer I added a listener for the update event.
> >Then in the handler, if the explicitWidth hadn't been set yet, I set it.
> >But they still resized.
>
> Hmm.  Did you set explicitHeight as well?  But then the width shouldn't
> have changed.
>
> Another approach would be to set the TileLayout's columnWidth and
> rowHeight properties when you know what to set them to.
>
> -Alex
>
>

Re: Do ItemRenderer's get reused across different components?

Posted by Alex Harui <ah...@adobe.com>.

On 10/25/16, 6:19 PM, "Kyle McKnight" <ka...@gmail.com> wrote:

>Hmm, sorry. Couldn't quite figure it out. At the end of the set data
>override of my ChildList renderer I added a listener for the update event.
>Then in the handler, if the explicitWidth hadn't been set yet, I set it.
>But they still resized.

Hmm.  Did you set explicitHeight as well?  But then the width shouldn't
have changed.

Another approach would be to set the TileLayout's columnWidth and
rowHeight properties when you know what to set them to.

-Alex


Re: Do ItemRenderer's get reused across different components?

Posted by Kyle McKnight <ka...@gmail.com>.
Hmm, sorry. Couldn't quite figure it out. At the end of the set data
override of my ChildList renderer I added a listener for the update event.
Then in the handler, if the explicitWidth hadn't been set yet, I set it.
But they still resized.


Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

On Tue, Oct 25, 2016 at 5:06 PM, Kyle McKnight <ka...@gmail.com> wrote:

> Great! Thanks so much
>
> On Oct 25, 2016 5:05 PM, "Alex Harui" <ah...@adobe.com> wrote:
>
>>
>>
>> On 10/25/16, 1:42 PM, "kamcknig" <ka...@gmail.com> wrote:
>>
>> >I'll try that out, is there an event I can listen for when a layout has
>> >completed all of it's measurements and positionings?
>>
>> It depends.  You may need to wait until data has arrived.  So sometimes I
>> wait for some data event then wait for updateComplete from LayoutManager.
>>
>> HTH,
>> -Alex
>>
>>

Re: Do ItemRenderer's get reused across different components?

Posted by Kyle McKnight <ka...@gmail.com>.
Great! Thanks so much

On Oct 25, 2016 5:05 PM, "Alex Harui" <ah...@adobe.com> wrote:

>
>
> On 10/25/16, 1:42 PM, "kamcknig" <ka...@gmail.com> wrote:
>
> >I'll try that out, is there an event I can listen for when a layout has
> >completed all of it's measurements and positionings?
>
> It depends.  You may need to wait until data has arrived.  So sometimes I
> wait for some data event then wait for updateComplete from LayoutManager.
>
> HTH,
> -Alex
>
>

Re: Do ItemRenderer's get reused across different components?

Posted by Alex Harui <ah...@adobe.com>.

On 10/25/16, 1:42 PM, "kamcknig" <ka...@gmail.com> wrote:

>I'll try that out, is there an event I can listen for when a layout has
>completed all of it's measurements and positionings?

It depends.  You may need to wait until data has arrived.  So sometimes I
wait for some data event then wait for updateComplete from LayoutManager.

HTH,
-Alex


Re: Do ItemRenderer's get reused across different components?

Posted by kamcknig <ka...@gmail.com>.
I'll try that out, is there an event I can listen for when a layout has
completed all of it's measurements and positionings?

Thanks!


Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

On Tue, Oct 25, 2016 at 4:40 PM, Alex Harui [via Apache Flex Users] <
ml-node+s2333346n13933h77@n4.nabble.com> wrote:

>
>
> On 10/25/16, 11:43 AM, "kamcknig" <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=13933&i=0>> wrote:
>
> >I am not because I would like them to be dynamically sized. The only
> width
> >I believe I have set is on the renderer itself I set the minWidth to 150.
>
> Yeah, that sounds like a scenario we hit often.  I often really only want
> a renderer to be dynamically sized at startup or when the app is resized,
> but not on every update.  The solution is to make sure your renderers do
> not change their measured size based on content.  That can be hard if
> sub-components have scrollbars or are otherwise flexible.  Another trick
> I've used is to wait until the layout has run once (and hopefully chosen
> good sizes) then go and run code to set the renderer's size explicitly.
> Even something as simple as
>
>    renderer.explicitWidth = renderer.width;
>
> can be sufficient.
>
> HTH,
> -Alex
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://apache-flex-users.2333346.n4.nabble.com/Do-
> ItemRenderer-s-get-reused-across-different-components-tp13928p13933.html
> To unsubscribe from Do ItemRenderer's get reused across different
> components?, click here
> <http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=13928&code=a2FtY2tuaWdAZ21haWwuY29tfDEzOTI4fC0xNTg3MjQ1NTM4>
> .
> NAML
> <http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Do-ItemRenderer-s-get-reused-across-different-components-tp13928p13934.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: Do ItemRenderer's get reused across different components?

Posted by Alex Harui <ah...@adobe.com>.

On 10/25/16, 11:43 AM, "kamcknig" <ka...@gmail.com> wrote:

>I am not because I would like them to be dynamically sized. The only width
>I believe I have set is on the renderer itself I set the minWidth to 150.

Yeah, that sounds like a scenario we hit often.  I often really only want
a renderer to be dynamically sized at startup or when the app is resized,
but not on every update.  The solution is to make sure your renderers do
not change their measured size based on content.  That can be hard if
sub-components have scrollbars or are otherwise flexible.  Another trick
I've used is to wait until the layout has run once (and hopefully chosen
good sizes) then go and run code to set the renderer's size explicitly.
Even something as simple as

   renderer.explicitWidth = renderer.width;

can be sufficient.

HTH,
-Alex


Re: Do ItemRenderer's get reused across different components?

Posted by kamcknig <ka...@gmail.com>.
I am not because I would like them to be dynamically sized. The only width
I believe I have set is on the renderer itself I set the minWidth to 150.


Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

On Tue, Oct 25, 2016 at 2:22 PM, Alex Harui [via Apache Flex Users] <
ml-node+s2333346n13929h53@n4.nabble.com> wrote:

> Are you setting columnWidth?  If not it could get recalculated and if a
> renderer reports a different size now that it is full of content, you
> might get different results.
>
> -Alex
>
> On 10/25/16, 11:04 AM, "Kyle McKnight" <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=13929&i=0>> wrote:
>
> >I have a List, ParentList, that has a VerticalLayout. Within ParentList
> is
> >another List, ChildList with a TileLayout.
> >
> >During points in my application, ParentList gets updated which then also
> >means ChildList gets updated. What is weird is that the same ChildList
> >will
> >show different sizes of the children randomly when I leave and come back
> >to
> >the the page.
> >
> >So let's say I set the selected index on ParentList to index 5. ChildList
> >gets updated with a subset of data, arbitrarily DataA...DataN. Each
> >renderer in ChildList will be width X. But then I set ParentList to index
> >6
> >and then later back to 5. So viewing the same set of data, DataA...DataN,
> >yet this time the TileLayout will have the children be width Z instead of
> >the same width X it was before.
> >
> >Sorry if that's confusing lol. Basically the same TileLayout with the
> same
> >data will size taht data differently.
> >
> >So this leads me to wonder if renderers are reused even if they are
> >contained withing different components as long as they use the same Class
> >of renderer? Is this happening because when the data is set on the
> >ChildList renderer's I'm not resetting everything to some default state?
> >
> >Kyle McKnight
> >Senior UI Engineer - Accesso
> >602.515.1444 (M)
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://apache-flex-users.2333346.n4.nabble.com/Do-
> ItemRenderer-s-get-reused-across-different-components-tp13928p13929.html
> To unsubscribe from Do ItemRenderer's get reused across different
> components?, click here
> <http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=13928&code=a2FtY2tuaWdAZ21haWwuY29tfDEzOTI4fC0xNTg3MjQ1NTM4>
> .
> NAML
> <http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Do-ItemRenderer-s-get-reused-across-different-components-tp13928p13931.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: Do ItemRenderer's get reused across different components?

Posted by Alex Harui <ah...@adobe.com>.
Are you setting columnWidth?  If not it could get recalculated and if a
renderer reports a different size now that it is full of content, you
might get different results.

-Alex

On 10/25/16, 11:04 AM, "Kyle McKnight" <ka...@gmail.com> wrote:

>I have a List, ParentList, that has a VerticalLayout. Within ParentList is
>another List, ChildList with a TileLayout.
>
>During points in my application, ParentList gets updated which then also
>means ChildList gets updated. What is weird is that the same ChildList
>will
>show different sizes of the children randomly when I leave and come back
>to
>the the page.
>
>So let's say I set the selected index on ParentList to index 5. ChildList
>gets updated with a subset of data, arbitrarily DataA...DataN. Each
>renderer in ChildList will be width X. But then I set ParentList to index
>6
>and then later back to 5. So viewing the same set of data, DataA...DataN,
>yet this time the TileLayout will have the children be width Z instead of
>the same width X it was before.
>
>Sorry if that's confusing lol. Basically the same TileLayout with the same
>data will size taht data differently.
>
>So this leads me to wonder if renderers are reused even if they are
>contained withing different components as long as they use the same Class
>of renderer? Is this happening because when the data is set on the
>ChildList renderer's I'm not resetting everything to some default state?
>
>Kyle McKnight
>Senior UI Engineer - Accesso
>602.515.1444 (M)