Feb 24, 2011

Setting constraints on a Dojo control

Constraints in Dojo are objects passed to functions responsible for validating, parsing, and formatting the data in the box, and various properties may be provided to override system or locale-specific defaults.

I was having difficulty finding an example used in XPages. Code below is a constraint used on a dijit.form.NumberTextBox. I'm just setting the number pattern to accept a number with a comma. You can setup multiple constraints...just separate with semi-colons.

<xp:inputText value="#{document.Number}" id="number1" dojoType="dijit.form.NumberTextBox">
    <xp:this.dojoAttributes>
        <xp:dojoAttribute name="constraints" value="{pattern: '#,##0'}"></xp:dojoAttribute>
    </xp:this.dojoAttributes>
</xp:inputText>

No comments:

Post a Comment