Titanium JIRA Archive
Alloy (ALOY)

[ALOY-544] Ability to define a custom namespace to enable Alloy to generate custom widgets

GitHub Issuen/a
TypeNew Feature
Resolution Date2014-07-21T15:03:39.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsRuntime, XML
ReporterDaniel Sefton


Alloy should allow the user to specify a custom namespace for each widget in XML which modifies the generated code to use the widgets within the specified namespace. As an example, generates Ti.UI.createwindow(). The user should be able to specify , which Alloy would in turn use to generate mcd.createwindow(). This is useful if the user has their own custom framework with custom widget attributes.


  1. Tony Lukasavage 2013-03-07

    For reference, this technically works now so long as the custom API matches 1 to 1 with the Titanium API, as mentioned in the ticket's description. The issue is that there are a number of validation points in Alloy right now that assert certain things about the parent/child relationships in the XML. For example, The index.xml expects Ti.UI.Window, not some other namespace. There are a bunch of these checks throughout the various XML elements in Alloy/Titanium, so hunting those down and loosening the restrictions is what really needs to be done.
  2. Daniel Sefton 2013-03-07

    I see, ok. So it works for standard built-in widgets. I'd update the description, but I can't edit this report. The customer is now saying: "Only concern is how to deal with the exceptional scenarios. Let me take a small example. Let's say I need to have a widget called 'LoginWidget' , I can't map this with customNamespace.createloginwidget()" Is that a separate issue? Let me know if you'd like the customer to elaborate...
  3. Tony Lukasavage 2013-03-07

    Daniel in that case they should just create a widget
  4. Miles Matthias 2013-04-02

    Tony, what about this situation with nested elements? Like:
    We're looking to build a custom form object where we can define the form elements in xml and its styles in the tss files, but do things like form.loadRecord(), form.getRecord(), form.loadValues(), form.getValues(), form.disable(), and form.enable(). (We'll probably open source this at some point.) I've thought about using a custom namespace, but is a widget sufficient? I haven't seen any examples of nesting objects in a call.
  5. Fokke Zandbergen 2014-07-19

    This ticket can be closed as this works in Alloy 1.3.1+: *views/index.xml*
       <Form module="mycustomnamespace">
         <TextField label="First name:" />
         <TextField label="Last name:" />
       exports.createForm = function() {
         return Ti.UI.createView();
    You just need to make sure that createForm returns a TiProxy element that has add() because the children will be added by calling this.
  6. Jason Kneen 2014-07-19

    Agreed, this should be closed. The module attribute can be used to override any tag and return a custom element. See an example here https://github.com/jasonkneen/com.jasonkneen.tabdemo on how this is done with a TabGroup. For iOS, you get standard TabGroup, Tab, Window components - on Android you get a custom re-created TabGroup based on views. The XML is *identical* except for the module="tabGroup" addition.
  7. Tim Poulsen 2014-07-21

    Resolving, since this functionality already exists as described by the comments.
  8. Eric Merriman 2018-03-07

    Closing as invalid. If this is incorrect, please reopen.

JSON Source