Titanium JIRA Archive
Alloy (ALOY)

[ALOY-701] Alloy Listview templates don't support nesting

GitHub Issuen/a
Resolution Date2013-06-12T14:08:52.000+0000
Affected Version/sn/a
Fix Version/sn/a
ReporterCarter Lathrop
AssigneeTony Lukasavage


Paste into index.xml Run a alloy compile. This is fail with relevant error strings.
	<Window class="container">
		<ListView id="list" defaultItemTemplate="lvItem">
      		<ItemTemplate name="lvItem" id="lvItem">
         		<ImageView bindId="image" class="image" id="image" />
         		<View id="DetailContainer">
           			<Label bindId="name" id="name" />
           			<Label bindId="type" id="type" />
This sort of layout for a template won't compile. The nested labels in a view are in order to use a layout of vertical on DetailContainer. If there is a better way to deal with this then please tell me, but otherwise I think I have to guess heights for the labels.


  1. Carter Lathrop 2013-06-03

    Hello Neville, Would you mind providing a full test case, one that we can reproduce the issue so as to easily see what is going on? You can either package it up or just paste the necessary code. Once I can reproduce I would be glad to pass along to the Alloy team. For future reference: https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report Thanks for your cooperation, Carter
  2. Neville Dastur 2013-06-03

    Hi Carter I have updated the description. Thanks
  3. Carter Lathrop 2013-06-04

    Hi Neville, Pasting this into an index.xml gives me the follow error:
       [ERROR] :  [ERROR] Compile failed. index.xml must have a top-level container element.
       [ERROR] :  [ERROR] Valid elements: [Ti.UI.Window,Ti.UI.iPad.SplitWindow,Ti.UI.TabGroup,Alloy.Collection,Alloy.Model]
       [ERROR] :  Alloy compiler failed
    Is this the error you are speaking of? Would you mind elaborating if I am doing something wrong here, I have followed your instructions to the best of my knowledge. Best, Carter
  4. Neville Dastur 2013-06-04

    Hi Carter, Sorry, no I had copied from a non index.xml file. For index.xml it will have to be a window rather than just a view. So no this is not the error.
  5. Carter Lathrop 2013-06-04

    Still no luck, would you mind providing the entire project, or at least the necessary files to run this, eg index.js, or any other controllers. Thanks, Carter
  6. Neville Dastur 2013-06-04

    Okay, so I have put the code in https://github.com/ClinicalSoftwareSolutions/DemoBug/tree/alloy_nested_listview branch Run alloy compile --config platform=ios and the compile will fail with:
       [INFO] ----- MVC GENERATION -----
       [INFO] [index.xml] view processing...
       [INFO]   style:      "index.tss"
       [INFO]   view:       "index.xml"
       [INFO]   controller: "index.js"
       WARN: ERROR: Unexpected token name «__alloyId6», expected punc «:» [Resources/alloy/controllers/index.js:27,241]
       [TRACE] var Alloy = require('alloy'),
       	Backbone = Alloy.Backbone,
       	_ = Alloy._;
       function Controller() {
       	require('alloy/controllers/' + "BaseController").apply(this, Array.prototype.slice.call(arguments));
       	var __parentSymbol = arguments[0] ? arguments[0]['__parentSymbol'] : null;
       	var $model = arguments[0] ? arguments[0]['$model'] : null;
       	var __itemTemplate = arguments[0] ? arguments[0]['__itemTemplate'] : null;
       	var $ = this;
       	var exports = {};
       	var __defers = {};
       	// Generated code that must be executed before all UI and/or
       	// controller code. One example is all model and collection
       	// declarations from markup.
       	// Generated UI code
       	$.__views.index = Ti.UI.createWindow(
       $.__views.index && $.addTopLevelView($.__views.index);var __alloyId1={};var __alloyId3=[];var __alloyId4={type:'Ti.UI.ImageView',bindId:'image',properties:{bindId:"image",},};__alloyId3.push(__alloyId4);var __alloyId5={type:'Ti.UI.View',var __alloyId6=[];var __alloyId7={type:'Ti.UI.Label',bindId:'name',properties:{width:Ti.UI.SIZE,height:Ti.UI.SIZE,color:"#000",bindId:"name",},};__alloyId6.push(__alloyId7);var __alloyId8={type:'Ti.UI.Label',bindId:'type',properties:{width:Ti.UI.SIZE,height:Ti.UI.SIZE,color:"#000",bindId:"type",},};__alloyId6.push(__alloyId8);properties:{},childTemplates:__alloyId6,};__alloyId3.push(__alloyId5);var __alloyId2 = {properties:{name:"lvItem",},childTemplates:__alloyId3,};__alloyId1["lvItem"]=__alloyId2;$.__views.list = Ti.UI.createListView(
       	// make all IDed elements in $.__views available right on the $ in a
       	// controller's internal code. Externally the IDed elements will
       	// be accessed with getView().
       	_.extend($, $.__views);
       	// Controller code directly from the developer's controller file
       function doClick(e) {
       	// Generated code that must be executed after all UI and
       	// controller code. One example deferred event handlers whose
       	// functions are not defined until after the controller code
       	// is executed.
       	// Extend the $ instance with all functions and properties
       	// defined on the exports object.
       	_.extend($, exports);
       module.exports = Controller;
       		throw e;
           at new JS_Parse_Error (/opt/local/lib/node_modules/alloy/node_modules/uglify-js/lib/parse.js:185:18)
           at js_error (/opt/local/lib/node_modules/alloy/node_modules/uglify-js/lib/parse.js:199:11)
           at croak (/opt/local/lib/node_modules/alloy/node_modules/uglify-js/lib/parse.js:630:9)
           at token_error (/opt/local/lib/node_modules/alloy/node_modules/uglify-js/lib/parse.js:638:9)
           at expect_token (/opt/local/lib/node_modules/alloy/node_modules/uglify-js/lib/parse.js:651:9)
           at expect (/opt/local/lib/node_modules/alloy/node_modules/uglify-js/lib/parse.js:654:36)
           at /opt/local/lib/node_modules/alloy/node_modules/uglify-js/lib/parse.js:1181:13
           at /opt/local/lib/node_modules/alloy/node_modules/uglify-js/lib/parse.js:677:24
           at expr_atom (/opt/local/lib/node_modules/alloy/node_modules/uglify-js/lib/parse.js:1111:35)
           at maybe_unary (/opt/local/lib/node_modules/alloy/node_modules/uglify-js/lib/parse.js:1281:19)
  7. Neville Dastur 2013-06-11

    Hi Carter. Do you now see the error using the project in GitHub?
  8. Carter Lathrop 2013-06-11

    Hello Neville, Yes, sorry about the wait, I had forgotten to update my node.js and was getting funny errors. Now we are on the same page but after messing around with your code, I do not think the nested labels are the issue here. If you remove one of them, the code still breaks, with the same error. Is the same thing happening for you? Regards, Carter
  9. Carter Lathrop 2013-06-11

    Neville, I think I understand what you are getting at, the double nesting within an itemTemplate is causing the error, not the fact that there are two labels within the view within the ItemTemplate. I will pass along to the Alloy team to see if they have any insight on this. Regards, Carter
  10. Neville Dastur 2013-06-11

    Carter, yes that is right. I use the label inside of a view so that they can be vertically layouted. Also, I notice that you are changing the reporter on all these issues away from my name. Is there a reason. It's just that is makes it awkward for me to filter and search for issues I have reported and are interested in the progress of. No one else seems to do that.
  11. Carter Lathrop 2013-06-11

    By default, when moving a ticket to Alloy, the reporter switches to the person who moved it. And as for changing the reporter to myself on other tickets, I have spoken to my colleagues who have informed me that that way of reporting bugs is now not needed, I hadn't realized this. It used to be automatic (just how it is for alloy tickets now), that whoever moved the ticket to Ti-Mobile or Ti-Studio would become the reporter, and to keep everything consistent, this standard was continued for quite some time via manual changes for other bug types. I'll ensure from now on that you remain as the reporter and I will put a bug report through to remove the automatic assignment in Alloy tickets. Thanks for bringing that to my attention, Carter
  12. Tony Lukasavage 2013-06-12

    Duplicate of ALOY-678

JSON Source