0
votes

Below is the source of a very simplified XPage. It has a radio button group with two choices and an onchange event that sets viewScope.vsCompanies depending on the value selected. Then there is a field called Title that I have made Required. If I click on the radio button it changes from Contract to Lease and back but the onchange event never fires. Instead I get a warning that the Title is required. I only want the validation to fire when the document is being submitted so the onchange works. Do I have to make every one of the validations conditional on the submit being pressed, which seems like a lot of additional work. I could set a viewScope when the submit button is pressed and make it only required if that viewScope is true.

Sorry missed adding the code ps clientsideValidation is disabled

<xp:this.data>
        <xp:dominoDocument var="CLDoc"
            databaseName="Client Apps\LGI\XPages\LGIContracts-Leases.nsf"
            formName="frmCL">
        </xp:dominoDocument>
    </xp:this.data>
<xp:this.properties>
        <xp:parameter name="xsp.client.validation" value="false" />
    </xp:this.properties>
    <xp:br></xp:br>
    <xp:messages id="messages1"></xp:messages>
    <xp:radioGroup id="radioGroup1" value="#{CLDoc.Type}">
        <xp:selectItem itemLabel="Contract"></xp:selectItem>
        <xp:selectItem itemLabel="Lease"></xp:selectItem>
        <xp:eventHandler event="onchange" submit="true"
            refreshMode="partial" refreshId="comboBox1">
            <xp:this.action><![CDATA[#{javascript:if (CLDoc.getValue("Type") == "Contract"){
    viewScope.vsCompanies = ["A","B","C"];
    return;
    break;
}else{
    viewScope.vsCompanies = ["X","Y","Z"];
    return;
    break;
}}]]></xp:this.action>
        </xp:eventHandler>
    </xp:radioGroup>
    Company
    <xp:br></xp:br>
    <xp:comboBox id="comboBox1" value="#{CLDoc.Company}">
        <xp:selectItems>
            <xp:this.value><![CDATA[#{javascript:viewScope.vsCompanies}]]></xp:this.value>
        </xp:selectItems>
    </xp:comboBox>
    <xp:br></xp:br>

    Title
    <xp:br></xp:br>
    <xp:inputText id="inputText1" style="width:392.0px" value="#{CLDoc.Title}"
        required="true">
        <xp:this.validators>
            <xp:validateRequired message="Title is required"></xp:validateRequired>
        </xp:this.validators>
    </xp:inputText>
1
There is no source below your post.Matti Virkkunen

1 Answers

3
votes

I believe if you go to the Events you are able to disable validators for that event.

[edit]

I found a duplicate question here. xpages validation on field having onChange script

Looks like the event handler has the following parameter disableValidators="true"