Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1324] Support Boolean (and Number) values in XML views

GitHub Issuen/a
Resolution Date2016-03-21T08:40:39.000+0000
Affected Version/sn/a
Fix Version/sn/a
ReporterFokke Zandbergen
AssigneeBruce Wayne


This is a new attempt after ALOY-968 was closed with little discussion. The following view snippet:
<Label focusable="false" borderWidth="5" borderColor="#000">Hello, world!</Label>
Will compile to:
    $.__views.__alloyId0 = Ti.UI.createLabel({
        width: Ti.UI.SIZE,
        height: Ti.UI.SIZE,
        color: "#000",
        text: "Hello, world!",
        focusable: "false",
        borderWidth: "5",
        borderColor: "#000",
        id: "__alloyId0"
For some properties/values (mostly Number) this is not a problem, but focusable: "false" will evaluate to true. Of course these could and in most cases _should_ be set in TSS which supports Boolean and Number types. However, in particular boolean flags that impact the markup/layout (show, hide, animate..) it can make sense to set them in the XML view. Simply casting all /^[0-9]+$/ values to Number and all /^(true|false)$/ to Boolean might break apps and will make it impossible to keep them as strings if that is in fact what you want. A workaround for Boolean values would be to set Alloy.Globals.TRUE = true; in alloy.js and then use this as value in the XML. Maybe we can introduce Ti.TRUE and Ti.FALSE as an official "workaround"? I must say I'm not keen on either two.. so open for other ideas.


  1. Fokke Zandbergen 2016-02-12

    Is partly duplicated by ALOY-1355

JSON Source