Titanium JIRA Archive
Alloy (ALOY)

[ALOY-787] A <Widget> in a widget view should default to the current src

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2014-07-01T15:01:20.000+0000
Affected Version/sAlloy 1.2.0
Fix Version/sAlloy 1.5.0
Componentsn/a
Labelsalloy, qe-manualtest, view, widget
ReporterFokke Zandbergen
AssigneeFeon Sua Xin Miao
Created2013-08-12T06:47:19.000+0000
Updated2015-12-04T08:47:23.000+0000

Description

Considering this view of a widget:
<Alloy>
  <Window>
    <Widget name="secondView" />
  </Window>
</Alloy>
I would like the src attribute to automatically default to the widget it is used in. It's clean, better for my keyboard and one less statement to check if I decide to change my widget's name.

Comments

  1. Tim Poulsen 2014-03-31

    [~fokke] Is this ticket still valid? I'm not sure I understand what you're asking for and why you need it. Can you provide a better description? Maybe even a mocked up project showing how you'd like it to work?
  2. Fokke Zandbergen 2014-04-01

    [~skypanther], yes it's still valid. Imagine a widget with these 2 views: *widgets/my.widget/views/widget.xml*
       <Alloy>
         <Window>
           <Widget src="my.widget" name="other" />
         </Window>
       </Alloy>
       
    *widgets/my.widget/views/other.xml*
       <Alloy>
         <Label>Hello</Label>
       </Alloy>
       
    I'd like to be able to leave out the src attribute in the first view. Why? Because I hate to repeat the id of the widget since a) I'm lazy b) It allows me to easily rename the widget.
  3. Tim Poulsen 2014-04-04

    [~fokke] Widget tags are processed essentially as Require tags. In the case of widgets, the src attribute specifies the folder name from which to get the file specified with the name attribute. There are no properties available at runtime that give me this info automatically. The developer must supply it.
  4. Tim Poulsen 2014-04-04

    Closing as Won't Fix because we don't have a Can't Fix option.
  5. Fokke Zandbergen 2014-04-05

    Thanks for trying anyway :)
  6. Tony Lukasavage 2014-04-30

    Re-opening as this could be implemented by injecting the widget name at compile time, then using it at runtime as a default if no explicit widget src is specified.
  7. Feon Sua Xin Miao 2014-06-30

    PR: https://github.com/appcelerator/alloy/pull/465 Test app: https://github.com/feons/alloy/tree/ALOY-787/test/apps/testing/ALOY-787 Functional Test: 1. Run the test app on iOS, it should compile with no error Noted that in *widgets/my.widget/views/widget.xml*, src attribute for Widget tag is omitted.
  8. Fokke Zandbergen 2014-06-30

    Thx [~fmiao]!
  9. Fokke Zandbergen 2014-07-01

    Tested on iOS Simulator with provided test app and works fine.
  10. Tim Poulsen 2014-07-01

    PR tested and merged
  11. Federico Casali 2014-08-18

    Verified working as expected on iPhone 5 iOS 7.1.2 - Android Nexus Galaxy 4.3 - MobileWeb TiSDK 3.4.0.v20140815142514 Appcelerator Studio 3.3.1.201408140648 CLI 3.4.0-dev Alloy 1.5.0-dev
  12. Andrey Tkachenko 2015-12-03

    It not work in Alloy 1.7.24
        [ERROR] :  Error with <Widget> at line 5
        [ERROR] :  Child element must be one of the following: [Alloy.Abstract.ItemTemplate]
        [ERROR] :  Alloy compiler failed
        
    Inside mywidget/views/widget.xml
        <ListView>
                    <Templates>
                        <Widget name="templates/showlistOne" />               
                    </Templates>
                    <ListSection>
                    	<ListItem template="showlistOne"></ListItem>
                    </ListSection>
        </ListView>
        
    widgets/mywidget/views/templates/showlistOne.xml
        <Alloy>
        	<ItemTemplate name="showlistOne">
        		<Label text="123" />
        	</ItemTemplate>		
        </Alloy>
        
  13. Andrey Tkachenko 2015-12-03

    Android
  14. Fokke Zandbergen 2015-12-03

    [~falko] Could you simplify the test case by not using templates, but instead simple views? The first view is missing the Alloy root element as well. Does the following fail as well for you? *mywidget/views/widget.xml*
        <Alloy>
          <View>
            <Widget name="foo" />
          </View>
        </Alloy>
        
    *mywidget/views/foo.xml*
        <Alloy>
          <Label>Hello</Label>
        </Alloy>
        
  15. Andrey Tkachenko 2015-12-03

    I can't edit my comments for this issue to add alloy tag. My example is quite simple.
  16. Feon Sua Xin Miao 2015-12-04

    [~falko], Widget is currently not supported in Templates, a related ticket is here ALOY-1220.
  17. Andrey Tkachenko 2015-12-04

    That ticket has not relation to this. Please read carefully. In my case Widget works as Require and not inside ItemTemplate.
  18. Fokke Zandbergen 2015-12-04

    [~falko] I'm afraid what you see *is* variation of ALOY-1220 and ALOY-787: *This does NOT work:*
        <Alloy>
        	<ListView>
                    <Templates>
                        <Widget name="bar" />               
                    </Templates>
                    <ListSection>
                    	<ListItem template="showlistOne"></ListItem>
                    </ListSection>
        	</ListView>
        </Alloy>
        
    As does <Require type="widget" name="bar" /> which both fail with:
        [ERROR] Error with <Widget> at line 4
        [ERROR] Child element must be one of the following: [Alloy.Abstract.ItemTemplate]
        
    *This DOES work:*
        <Alloy>
        	<ListView>
                    <Templates>
                        <Widget src="foo" name="bar" />               
                    </Templates>
                    <ListSection>
                    	<ListItem template="showlistOne"></ListItem>
                    </ListSection>
        	</ListView>
        </Alloy>
        
    As does <Require type="widget" src="foo" name="bar" />. [~fmiao] I guess the implementation of ALOY-787 is missing a case for when it's used in templates?
  19. Andrey Tkachenko 2015-12-04

    Fokke Zandbergen your simple example also not work.
        <Alloy>
        	<Window>		
        		<Widget src="test" />
        	</Window>
        </Alloy>
        
        <Alloy>
        	<Widget src="foo" />
        </Alloy>
        
        <Alloy>
        	<Label>ok</Label>
        </Alloy>
        
    {noformat} [ERROR] : widget "foo" view "widget" does not exist. [ERROR] : The following paths were inspected: [ERROR] : /Users/falko/Documents/Appcelerator_Studio_Workspace/test123123/app/widgets/foo/views/android/widget [ERROR] : /Users/falko/Documents/Appcelerator_Studio_Workspace/test123123/app/widgets/foo/views/widget [ERROR] : /Users/falko/.appcelerator/install/5.2.0-55/package/node_modules/appc-cli-titanium/node_modules/alloy/widgets/foo/views/android/widget [ERROR] : /Users/falko/.appcelerator/install/5.2.0-55/package/node_modules/appc-cli-titanium/node_modules/alloy/widgets/foo/views/widget [ERROR] : Alloy compiler failed {noformat}
  20. Fokke Zandbergen 2015-12-04

    In the *widget.xml* you should have name="foo" and not src="foo"
  21. Andrey Tkachenko 2015-12-04

    @Fokke Zandbergen yes you right. But it does not work inside Templates.
  22. Fokke Zandbergen 2015-12-04

JSON Source