[TIMOB-23215] Windows: Data binding: Using attribute in ListItem that is not in data crashes view
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2016-04-26T14:53:33.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Windows |
Labels | windows |
Reporter | Rene Pot |
Assignee | Kota Iguchi |
Created | 2016-04-14T16:07:46.000+0000 |
Updated | 2017-03-21T23:14:00.000+0000 |
Description
I have a ListView with Data Binding set up. I have a transform function attached to the binding of a ListSection. But if my transform function doesn't return data the ListItem expects, it crashes the view/window or throws an error which is unusable (unknown error).
So for example
<ListItem myLabel:text="{labelText}" />
But transform doesn't give the variable labelText, or (not 100% confirmed yet) it returns null/empty result. In this case it goes wrong.
Happens with Alloy coupled with 5.2.0 and 5.2.1 and 5.3.0
Maybe related to TIMOB23216 but [~topener] could you give us a sample code so we can reproduce the issue on our side?
Hi, the example in the description is already basically what the problem is. Data provided in transform but not used in ListItem is fine, but data to-be-used in the ListItem that is not provided from the transform crashes the view
[~topener] Could you confirm what kind of value
labelText
variable have? I think you are guessing it was empty or null?The data property was missing. Neither null or empty.
Hmm I can not reproduce this. I think you mean
doTransform
returns object but it doesn't have required property, is that right? For example let say we havedoTransform
like below:and then try to bind the missing property ListItem
title
:It just shows empty List (as expected) and it does not throw "unknown exception". Did I miss something in this case?
I had troubles with this, but for me it never returned an empty array or object. I guess it should return something like this
and keep the listview the same
[~topener] Yeah, I tried something like that too but app doesn't crash for me... Now I'm guessing that
doTransform
contains wrong property that causes ListView crash. Could you dump the actual value? Or at least can you provide a property names?Figured it out... turned out to be either
null
orundefined
. I was trying toget()
a property on a model that didn't exist. Although getting a non-existing property from a model didn't crash anything, trying to insert it in the view did. So that is the actual bug reportGlad to hear you figure it out...Could you provide a simple sample code that reproduce the issue [~topener] ? From what you described, I would imagine like this:
Hi, this has nothing to do with models and saving them. It has to do with DataBinding in a ListView.
And that property is used in the xml
I still can't reproduce this but I'm trying in various way. Just in case, which version of alloy are you using? Alloy prior to
1.8.1
had a issue around model binding (TIMOB-20577) so make sure you use Alloy1.8.1
or1.9.x
. (alloy --version
)Can confirm, behaves better with 1.8.# and crashes with 1.7.#
Awesome, so you mean crash is fixed in 1.8.x? I think I found a potential workaround for a View crash with alloy on my side...adding
setTimeout
on updating model (save
) makes View stable for me. I know this is dirty workaround but just in case, hope this works for you too.Yeah correct, apologies for that!
Awesome! Resolving this ticket as duplicate of TIMOB-20577.
Closing ticket as duplicate with reference to the above comments and links.