0
votes

I am learning xpages and trying different things, working through tutorials etc. I have a simple xpage to submit data to a form. It worked until I decided to use a regex in the validate constraint property. The validator works, but the submit button no longer updates the form when the data is in the correct format. The code is below. The problematic code is set off by ***. We are running Domino 8.5.2. No error messages in log.
Thanks, ---Lisa&

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:this.data>
        <xp:dominoDocument var="NameList" formName="NameList"></xp:dominoDocument>
    </xp:this.data>
    <xp:table>
        <xp:tr>
            <xp:td>
                <xp:label value="Firstname:" for="firstname1" id="Firstname_label"></xp:label>
            </xp:td><xp:td>
                <xp:inputText value="#{NameList.Firstname}" id="firstname1"></xp:inputText>
            </xp:td>
        </xp:tr>

        <xp:tr>
            <xp:td>
                <xp:label value="Lastname:" id="Lastname_label" for="lastname1"></xp:label>
            </xp:td><xp:td>
                <xp:inputText value="#{NameList.Lastname}" id="lastname1"></xp:inputText>
            </xp:td>
        </xp:tr>

        <xp:tr>
            <xp:td>
                <xp:label value="Email:" id="Email_Label"></xp:label></xp:td>
            <xp:td>
                <xp:inputText id="email1" value="#{NameList.Email}">
                    ***<xp:this.validators>
                        <xp:validateConstraint
                            message="Email address should be in the format:  name@someplace.somedomain"
                            regex="\S+@\S+\.\S">
                        </xp:validateConstraint>
                    </xp:this.validators>***
                </xp:inputText>
            </xp:td>
        </xp:tr>
    </xp:table>

    <xp:button id="button3" value="Save">
        <xp:eventHandler 
            event="onclick" 
            submit="true" 
            refreshMode="complete" 
            immediate="false" 
            save="true">
            </xp:eventHandler>
        </xp:button>
    <xp:button id="button2" value="Cancel">
        <xp:eventHandler event="onclick" 
        submit="true" 
        refreshMode="complete" 
        immediate="true" 
        save="false">
        </xp:eventHandler>
    </xp:button>
        <xp:this.navigationRules>
            <xp:navigationRule outcome="xsp-success" viewId="/NameResults.xsp">
            </xp:navigationRule>
        </xp:this.navigationRules>
    <xp:br></xp:br>
    </xp:view>
1
Are you sure absolutely sure that your regex is correct?Steve Zavocki
Add a xp:messages control in order to see any validation errorsPer Henrik Lausten
The regex in your example only matches: name@someplace.sAndie2302
The regex will throw an error message if an email address is added that does not match blah@blah.blah. There are no error messages generated when a email address in the form blah@blah.blah is entered. But a record is not created.user4920643
The point of the regex was not to check the validity of email address out there - my research on the topic convinced me of the futility of that exercise. I just wanted to use the validateConstraint property.user4920643

1 Answers

0
votes

Well - the xpages did not like my regular expression. It is a little frustrating because I tested it at rubular.com. So Ruby would like it as would perl, I think. I guess java (or maybe javascript) does not. Here is the expression that worked: ^[A-Za-z0-9._%-]@[A-Za-z0-9].[A-Za-z]{2,4}

---Lisa&