Orbeon验证所有字段的错误

时间:2015-11-07 14:49:08

标签: orbeon

我想告知用户有些字段未完成。 我尝试使用here中的代码,但此解决方案对我不起作用。任何人都可以帮助我做错的事吗?它是Orbeon这是我的代码,版本4.4:

<xh:html xmlns:xh="http://www.w3.org/1999/xhtml"
     xmlns:widget="http://orbeon.org/oxf/xml/widget"
     xmlns:f="http://orbeon.org/oxf/xml/formatting"
     xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
     xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
     xmlns:saxon="http://saxon.sf.net/"
     xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
     xmlns:xf="http://www.w3.org/2002/xforms"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:sql="http://orbeon.org/oxf/xml/sql"
     xmlns:ev="http://www.w3.org/2001/xml-events"
     xmlns:xi="http://www.w3.org/2001/XInclude"
     xmlns:exf="http://www.exforms.org/exf/1-0"
     xmlns:v="http://www.example.com/validation"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
     xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<xh:head>
    <xh:title>Untitled Form</xh:title>
    <xf:model id="fr-form-model" xxf:expose-xpath-types="true">
        <xf:instance id="fr-form-instance">
            <form>
                <section-1>
                    <control-1/>
                </section-1>
            </form>
        </xf:instance>
        <xf:instance id="user-info">
            <user-info>
                <first-name/>
                <last-name/>
                <customer-number/>
            </user-info>
        </xf:instance>
        <xf:bind xmlns:dataModel="java:org.orbeon.oxf.fb.DataModel" id="fr-form-binds"
                 ref="instance('user-info')">
            <xf:bind id="first-name-bind" ref="first-name" name="first-name" required="true()"/>
            <xf:bind id="last-name-bind" ref="last-name" name="last-name" required="true()"/>
            <xf:bind id="customer-number-bind" ref="customer-number" name="customer-number"
                     required="true()"/>
        </xf:bind>

        !-- Temporary validation result --&gt;
        <xf:instance id="validation-result">
            <dummy/>
        </xf:instance>
        <xf:instance xxf:readonly="true" id="fr-form-metadata">
            <metadata>
                <application-name>test</application-name>
                <form-name>TestProstoZprzykladu</form-name>
                <title xml:lang="en">Untitled Form</title>
                <description xml:lang="en"/>
            </metadata>
        </xf:instance>
        <xf:instance id="fr-form-attachments">
            <attachments>
                <css mediatype="text/css" filename="" size=""/>
                <pdf mediatype="application/pdf" filename="" size=""/>
            </attachments>
        </xf:instance>
        <xf:instance id="fr-form-resources" xxf:readonly="false">
            <resources>
                <resource xml:lang="en">
                    <section-1>
                        <label>Untitled Section</label>
                    </section-1>
                    <control-1>
                        <label/>
                        <hint/>
                        <alert/>
                    </control-1>
                </resource>
            </resources>
        </xf:instance>
        <xf:instance id="fr-service-request-instance" xxf:exclude-result-prefixes="#all">
            <request/>
        </xf:instance>
        <xf:instance id="fr-service-response-instance" xxf:exclude-result-prefixes="#all">
            <response/>
        </xf:instance>
    </xf:model>
</xh:head>
<xh:body>
    <fr:view>
        <fr:body xmlns:xbl="http://www.w3.org/ns/xbl"
                 xmlns:dataModel="java:org.orbeon.oxf.fb.DataModel"
                 xmlns:p="http://www.orbeon.com/oxf/pipeline"
                 xmlns:oxf="http://www.orbeon.com/oxf/processors">
            <xf:group id="form-group" class="fields">
                <xh:div>
                    <xf:input bind="first-name-bind">
                        <xf:label>First name</xf:label>
                        <xf:alert value="'The first name is required'"/>
                    </xf:input>
                </xh:div>
                <xh:div>
                    <xf:input bind="last-name-bind">
                        <xf:label>Last name</xf:label>
                        <xf:alert value="'The last name is required'"/>
                    </xf:input>
                </xh:div>
                <xh:div>
                    <xf:input bind="customer-number-bind">
                        <xf:label>Customer number</xf:label>
                        <xf:alert value="'The customer number is required'"/>
                    </xf:input>
                </xh:div>
            </xf:group>
            <xf:trigger>
                <xf:label>
                    <xh:img src="/apps/fr/style/images/silk/disk.png"/>
                    <xh:span>Save</xh:span>
                </xf:label>
                <xf:action ev:event="DOMActivate">
                    <xf:dispatch name="fr-visit-all" targetid="error-summary"/>
                </xf:action>
            </xf:trigger>
        </fr:body>
    </fr:view>
    <fr:error-summary id="error-summary" observer="form-group">
        <fr:label>Errors in this form (non-incremental)</fr:label>
    </fr:error-summary>
</xh:body>

祝你好运!

1 个答案:

答案 0 :(得分:0)

您链接到的页面包含一个非常大的免责声明,声明该页面上描述的解决方案已过时使用Orbeon Forms 4:

Solution obsolete

如果您想要错误摘要,我建议您使用Form Builder创建表单,您将获得开箱即用的错误摘要等等。

相关问题