2015-11-07 311 views
0

我想通知用户有些字段未完成。 我试过使用here的代码,但是这个解决方案对我来说并不合适。任何人都可以帮助我,我做错了什么?这是Orbeon这里是我的代码,版本4.4:Orbeon验证所有字段的错误

<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> 

最好的问候!

回答

0

该网页链接到包含一个相当大的免责声明,该网页上所描述的方案是过时与Orbeon表格4:

Solution obsolete

如果你想有错误总结,我会建议你使用Form Builder来创建表单,你会得到一个开箱即用的错误摘要,等等。