Titanium JIRA Archive
Alloy (ALOY)

[ALOY-611] Add <Require> support to ListView

GitHub Issuen/a
TypeSub-task
PriorityHigh
StatusResolved
ResolutionFixed
Resolution Date2013-07-31T20:40:36.000+0000
Affected Version/sn/a
Fix Version/sAlloy 1.2.0, 2013 Sprint 16, 2013 Sprint 08
ComponentsXML
Labelsnotable
ReporterTony Lukasavage
AssigneeUnknown
Created2013-04-08T14:43:39.000+0000
Updated2018-03-07T22:25:39.000+0000

Description

tags need to handle the isViewTemplate condition so that they can return ListView compatible code. Right now only explicit UI components are handled in the markup.
<Alloy>
    <ListView>
        <Templates>
            <ItemTemplate name="template1" height="100">
                <ImageView bindId="image" left="15" top="6" bottom="6"/>
                <Label bindId="label" left="100" right="10"/>
            </ItemTemplate>
            <ItemTemplate name="template2" height="100">
                <!-- this won't work until this is resolved -->
                <Require src="someRequire"/>
            </ItemTemplate>
        </Templates>
    </ListView>
</Alloy>

Comments

  1. Tony Lukasavage 2013-04-11

    test app: https://github.com/appcelerator/alloy/tree/master/test/apps/ui/listview it includes required itemtemplates and listitems
  2. Fokke Zandbergen 2013-07-31

    The test app does *not* include the very example of this ticket. It [does include](https://github.com/appcelerator/alloy/blob/master/test/apps/ui/listview/views/templates.xml) a test where the <Require /> is on the same level as the other <ItemTemplate />, but does not test for a <Require /> used *IN* an <ItemTemplate />, like in the description of this ticket. When using a <Require /> inside an <ItemTemplate /> on the master version from Git, you'll get the following error during compile, which obviously should at least be caught to display a clear syntax error:
       
       /usr/local/lib/node_modules/alloy/Alloy/commands/compile/parsers/Alloy.Abstract.ItemTemplate.js:60
                                               return childTemplates + '.push(' + state.item.symbol + ');';
                                                                                            ^
       TypeError: Cannot read property 'symbol' of undefined
           at Object.CU.generateNodeExtended.post (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/parsers/Alloy.Abstract.ItemTemplate.js:60:51)
           at Object.exports.parse (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/parsers/base.js:14:17)
           at Object.exports.parse (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/parsers/Alloy.Require.js:12:27)
           at Object.exports.generateNode (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/compilerUtils.js:271:48)
           at Object.exports.generateNodeExtended (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/compilerUtils.js:223:17)
           at /usr/local/lib/node_modules/alloy/Alloy/commands/compile/parsers/Alloy.Abstract.ItemTemplate.js:55:15
           at Array.forEach (native)
           at Function._.each._.forEach (/usr/local/lib/node_modules/alloy/Alloy/lib/alloy/underscore.js:79:11)
           at parse (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/parsers/Alloy.Abstract.ItemTemplate.js:54:5)
           at Object.exports.parse (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/parsers/base.js:11:17)
           at Object.exports.parse (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/parsers/Alloy.Abstract.ItemTemplate.js:10:27)
           at Object.exports.generateNode (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/compilerUtils.js:271:48)
           at Object.exports.generateNodeExtended (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/compilerUtils.js:223:17)
           at /usr/local/lib/node_modules/alloy/Alloy/commands/compile/parsers/Ti.UI.ListView.js:57:17
           at Array.forEach (native)
           at Function._.each._.forEach (/usr/local/lib/node_modules/alloy/Alloy/lib/alloy/underscore.js:79:11)
           at /usr/local/lib/node_modules/alloy/Alloy/commands/compile/parsers/Ti.UI.ListView.js:48:6
           at Array.forEach (native)
           at Function._.each._.forEach (/usr/local/lib/node_modules/alloy/Alloy/lib/alloy/underscore.js:79:11)
           at parse (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/parsers/Ti.UI.ListView.js:31:4)
           at Object.exports.parse (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/parsers/base.js:11:17)
           at Object.exports.parse (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/parsers/Ti.UI.ListView.js:17:27)
           at Object.exports.generateNode (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/compilerUtils.js:271:48)
           at /usr/local/lib/node_modules/alloy/Alloy/commands/compile/compilerUtils.js:332:29
           at Array.forEach (native)
           at Function._.each._.forEach (/usr/local/lib/node_modules/alloy/Alloy/lib/alloy/underscore.js:79:11)
           at Object.exports.generateNode (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/compilerUtils.js:327:5)
           at /usr/local/lib/node_modules/alloy/Alloy/commands/compile/index.js:496:28
           at Array.forEach (native)
           at Function._.each._.forEach (/usr/local/lib/node_modules/alloy/Alloy/lib/alloy/underscore.js:79:11)
           at parseAlloyComponent (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/index.js:493:5)
           at /usr/local/lib/node_modules/alloy/Alloy/commands/compile/index.js:241:6
           at Array.forEach (native)
           at Function._.each._.forEach (/usr/local/lib/node_modules/alloy/Alloy/lib/alloy/underscore.js:79:11)
           at /usr/local/lib/node_modules/alloy/Alloy/commands/compile/index.js:233:6
           at Array.forEach (native)
           at Function._.each._.forEach (/usr/local/lib/node_modules/alloy/Alloy/lib/alloy/underscore.js:79:11)
           at module.exports (/usr/local/lib/node_modules/alloy/Alloy/commands/compile/index.js:229:4)
           at Object.<anonymous> (/usr/local/lib/node_modules/alloy/Alloy/alloy.js:91:46)
           at Module._compile (module.js:456:26)
           at Object.Module._extensions..js (module.js:474:10)
           at Module.load (module.js:356:32)
           at Function.Module._load (module.js:312:12)
           at Module.require (module.js:364:17)
           at require (module.js:380:17)
           at Object.<anonymous> (/usr/local/lib/node_modules/alloy/bin/alloy:3:1)
           at Module._compile (module.js:456:26)
           at Object.Module._extensions..js (module.js:474:10)
           at Module.load (module.js:356:32)
           at Function.Module._load (module.js:312:12)
           at Function.Module.runMain (module.js:497:10)
           at startup (node.js:119:16)
           at node.js:901:3
       
    Thanks to Matthew Lanham fro [bringing this under my attention](https://github.com/FokkeZB/nl.fokkezb.cachedImageView/issues/5).
  3. Tony Lukasavage 2013-07-31

    Thanks for the heads up guys. I'll address this specific situation.
  4. Tony Lukasavage 2013-07-31

    PR: https://github.com/appcelerator/alloy/pull/198 After additional research, controllers within ItemTemplates don't make a great deal of sense given the entirely new structure used by the ListView API. There's no way to tie the UI components that compose the ItemTemplate back to the originating controller code. Due to this fact, the elements inside the will need to be basic Titanium API elements, not controllers or widgets for the time being. If you use a or in an now, you'll get an error like this at compile time:
       [ERROR] Error with <Require> at line 11
       [ERROR] <ItemTemplate> cannot contain <Require> or <Widget> elements.
       [ERROR] ListView currently only supports Titanium API elements:
       [ERROR]   examples: <Label>, <Button>, <ImageView>, etc...
       [ERROR] Please reference the ListView guide at docs.appcelerator.com for more details.
       [ERROR] Alloy compiler failed
       
    I'm going to resolve this issue, but will revisit it to be addressed with more than a compile error message at a future date. There would need to be significant work done on code generation just to facilitate this particular usage of ItemTemplate, and I don't believe the large effort necessary to do that is warranted right now.
  5. Fokke Zandbergen 2013-08-01

    Agree 100%
  6. André Böhlke 2014-06-02

    I still have the same problem in version 1.3.1. The resolution should not be "fixed" but "won't fix"
  7. Manuel Lehner 2014-08-26

    Can this ticket be re-opened until there's a workaround? As André mentioned this was not fixed. Using Widgets and Require in Templates would be awesome.
  8. Fokke Zandbergen 2014-08-26

    The original issue *IS* fixed. I think [~manuellehner] you better create a new issue asking for using <Require /> and <Widget /> in item templates.
  9. Manuel Lehner 2014-08-26

JSON Source