Titanium JIRA Archive
Appcelerator Community (AC)

[AC-160] Cannot use Alloy controller that does not have an associated view

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionNot Our Bug
Resolution Date2015-11-26T05:41:33.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAlloy
Labelsalloy, controller, view
ReporterBrenton House
AssigneeMostafizur Rahman
Created2015-06-11T15:53:47.000+0000
Updated2017-02-07T23:28:24.000+0000

Description

If I have a controller: mycontroller.js that does not have an associated view file: mycontroller.xml, then when I go to use that controller like this:
<Alloy>
  <Require src="mycontroller"/> 
</Alloy>
I get this Alloy build error: [ERROR] view "mycontroller" does not exist. [ERROR] The following paths were inspected: [ERROR] c:\appc\myapp\app\views\mobileweb\mycontroller [ERROR] c:\appc\myapp\app\views\mycontroller [ERROR] Alloy compiler failed

Comments

  1. Jebun Naher 2015-11-23

    Hello, We tested this issue and this doesn't seem to be a bug. Views may be included in other views using the Require element. Specify the type attribute as 'view' and the src attribute should be the view file minus the '.xml' extension, and assign a unique value to the id attribute to reference the UI objects in the controller code. If you omit the type attribute, Alloy assumes it is implicitly set to 'view’. Please refer to [this](http://docs.appcelerator.com/platform/latest/#!/guide/Alloy_XML_Markup-section-35621528_AlloyXMLMarkup-RequireElement) and [this](http://docs.appcelerator.com/platform/latest/#!/guide/Alloy_Controllers). *Testing Environment:* Appcelerator Studio, build: 4.4.0.201511182122 Appcelerator Command-Line Interface, version 5.1.0 Mac Osx: 10.9.5 Ti sdk : 5.1.0 Node.js Version = 0.12.7 Jdk: 1.7.0_65 Emulator: Samsung Galaxy S4(4.4.4) *Steps to test:* 1. Create a classic project 2. Run with the sample test case below *Test Case* index.xml
       <Alloy>
           <Window id="index">
               <Require type="view" src="mycontroller"/>
           </Window>
       </Alloy>
       
    index.js
       $.index.open();
       
    mycontroller.xml
       <Alloy>
       	<View id="win1">
       		<Button onClick="test">Go Next</Button>
       	</View>
       </Alloy>
       
    mycontroller.js
       var test = function(e) {
          alert("hi there");
       };
       
    Thanks.

JSON Source