0
votes

I want to disable client side validation for a Dojo Time Text Box control while making this a required field for server side validation. I have set both the "disableClientSideValidation" and "validatorExt" properties to true. However, when I open the XPage, I immediately see the error "This value is required" beside the Dojo Time Text Box. Here is my code:

<xe:djTimeTextBox id="EventStartTime" value="#document1.EventStartTime}"     required="true"               
disableClientSideValidation="true" 
promptMessage="Bitte fügen Sie diesem Feld einen Wert hinzu!"
validatorExt="true">
<xe:this.validators>
<xp:validateRequired>
<xp:this.message><![CDATA[Bitte füllen Sie das Feld "Event Start Zeit" aus!]]>                 
</xp:this.message>
</xp:validateRequired>
</xe:this.validators>
</xe:djTimeTextBox>
1

1 Answers

3
votes

If you use the xe:djTimeTextBox with the Attribute required="true" it will create a html Output like this:

<input name="view:_id1:EventStartTime" id="view:_id1:EventStartTime" required="true" promptmessage="Bitte fügen Sie diesem Feld einen Wert hinzu!" dojotype="dijit.form.TimeTextBox">

You can view this code when using the noscript plugin for Firefox and set it to disable all scripts. This is the Output befor dojo is transforming your Input in a dojo Text Box.

The Problem is that if you use this extlib prebuild field the required attribute will get written to the input as soon you set this field to required=true no mather if you disable client side validation or not. The workaround for this could be to use a standard input and add the dojo attributes then you can set required on Server Side only like this:

<xp:this.resources>
    <xp:dojoModule name="dijit.form.TimeTextBox"></xp:dojoModule>
</xp:this.resources>

<xp:inputText id="mtgTime1" style="width:160px;" role="button"
    title="used to pick a meeting time" required="true"
    dojoType="dijit.form.TimeTextBox" disableClientSideValidation="true">
    <xp:this.dojoAttributes>
        <xp:dojoAttribute name="required" value="false"></xp:dojoAttribute>
    </xp:this.dojoAttributes>
    <xp:this.validators>
        <xp:validateRequired>
            <xp:this.message><![CDATA[Bitte füllen Sie das Feld "Event Start Zeit" aus!]]></xp:this.message>
        </xp:validateRequired>
    </xp:this.validators>
</xp:inputText>
<xp:messages id="messages1"></xp:messages>
<xp:button id="test" value="tst">
    <xp:eventHandler event="onclick" submit="true"
        refreshMode="complete">
    </xp:eventHandler></xp:button>