[ALOY-880] Improve error reporting on duplicate alloy controller id
|Fix Version/s||2014 Sprint 03|
|Labels||alloy, controller, error|
DescriptionHi =] I had the following structure (note the duplicated id: 'scheduler'): index.xml
scheduler.xml<Alloy> <TabGroup> <Tab title="Scheduler"> <Require src="scheduler" id="scheduler" /> </Tab> <Tab title="Job List"> <Require src="jobList" id="jobList" /> </Tab> </TabGroup> </Alloy>
The error I received back came from alloy/controllers/BaseController.js line 36 : "cannot read property '__iamalloy' of undefined" The problem was that the duplicate id prevented one of the scheduler controllers to have an undefined value as it's 'parent' property. A check should occur somewhere sooner to warn that a duplicate id has been defined.<Alloy> <Window title="Scheduler" navBarHidden="false" layout="vertical"> <Widget src="uk.co.ibcos.scheduler" dataProvider="jobData" id="scheduler" /> </Window> </Alloy>
- Tim Poulsen 2014-02-10
[~lsdriscoll] There is actually a warning message output. It's probably just that there's a lot of build messages that go by so that it's easy to miss it.
I used a label instead of a widget in my test app. Hence, I wouldn't get the same code error you saw. Instead, for me the label simply doesn't appear. Either way, the root cause is the same -- the child element is using the parent Window's id (which is assigned an id based on the file name since one isn't explicitly specified). I'm closing this as invalid. Reopen this ticket if you think I'm wrong in that assessment.
[INFO] [joblist.xml] view processing... [INFO] view: "joblist.xml" [WARN] <Label> at line 3 is using this view's default ID "joblist". Only a top-level element in a view should use the default ID
- Eric Merriman 2018-03-07 Closing as invalid. If this is incorrect, please reopen.