Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1179] Support defining controller inheritance in XML

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsRuntime, XML
LabelsTCSupportTriage, inheritance
Reporter曹俊
AssigneeTim Poulsen
Created2014-07-01T02:45:15.000+0000
Updated2015-01-05T15:43:38.000+0000

Description

I would like to be able to specify that subTopBar inherits from topBar by defining the baseController relationship in the XML of subTopBar rather than in its JavaScript code. --- original description follows --- There is a super controller which name is 'topBar'. There is a sub controller which inherit from 'topBar', its name is 'subTopBar'. 'subTopBar' has no XML in any views, because I wanna reuse the view of 'topBar'. (exports.baseController = 'topBar' ) such as the following .jade file described:
Alloy
  View
    Require#topBar(src='subTopBar', title='极速开户', top='0')
    View(backgroundColor="#f7f7f7", top="44")
When Alloy building, Alloy will try to find the view of the subcontroller when it was required in XML. 1st I wanna reuse the view, but I cant create a XML in views directory. 2nd I can still create it in JS by dynamic without any XML of subcontroller. In a word: I am for fear to it is a bug. I think it would be better for you to check this issue, thx.

Attachments

FileDateSize
TestBaseController.zip2014-07-02T02:27:43.000+00005526754

Comments

  1. Mauro Parra-Miranda 2014-07-02

    Hello @曹俊 please provide a testcase that shows this situation. Thanks!
  2. 曹俊 2014-07-02

    Test case1 pass Alloy-build. Test case2 fail.
  3. 曹俊 2014-07-02

    Hi Mauro Parra-Miranda. I upload 2 test case. Environment: Ti 3.2.1, Ti SDK 3.2.2, alloy 1.3.0. Please run on iphone. "testcase1" pass Alloy-build. "testcase2" fail. [INFO] ----- MVC GENERATION ----- [INFO] [global style] writing to cache... [INFO] [index.xml] view processing... [INFO] style: "index.tss" [INFO] view: "index.xml" [ERROR] view "subController" does not exist. Please notice "index.js" in "testcase1" and notice "index.xml" in "testcase2" Because "testcase1" work well and that there is not difference between "testcase1" and "testcase2" in truth. So I think it is a bug or a feature. Thx for your work.
  4. Motiur Rahman 2014-07-12

    Hi, Testcase1 is well and testcase2 show error but both are logically same. But in testcase2 has little bit mistake, require file didn't exist in view. In testcase2>>view>>index.xml and superController.xml but the reporter code is
       <Alloy>
       	<Window class="container">
           <View id="mainView">
             <Label id="label" onClick="doClick">Hello, World</Label>
             <Require src="subController"></Require>
           </View>
       	</Window>
       </Alloy>
       
       
    Actually code will be.
       <Alloy>
       	<Window class="container">
           <View id="mainView">
             <Label id="label" onClick="doClick">Hello, World</Label>
             <Require src="superController"></Require>
           </View>
       	</Window>
       </Alloy>
       
  5. Mauro Parra-Miranda 2014-08-08

    Hello [~mdsb100]! Let me know if the correction above fixes your issue. Best Regards!
  6. 曹俊 2014-08-08

    Hi [~morahman], In fact, I want use subController. I can create subController in running time (testcase1). It does not pass the alloy-building if I write "subController" into XML (testcase2). This is problem. The target of the two case is same!
  7. 曹俊 2014-08-08

    Hi [~mpmiranda], When I define a subController in .xml like "" , I do not need to create a View which name is "subController.xml" because I inherit the view form superController. So please let me pass the alloy-building.(Alloy try to find "subController.xml", and error.)
  8. Tim Poulsen 2014-09-02

    Inheritance is currently supported when controllers are instantiated in the JavaScript files, but it is not currently supported with XML tags as testcase2 attempts to do. There's reference documentation at http://docs.appcelerator.com/titanium/latest/#!/guide/Alloy_Controllers-section-34636384_AlloyControllers-Inheritance and a sample app at https://github.com/appcelerator/alloy/tree/master/test/apps/advanced/inheritance [~mpmiranda] You can move this to Alloy. However, it is a feature request not a bug.

JSON Source