2015-12-07 67 views
1

我创建了自己的控件,并且必须在xbl文件中硬编码一些信息。这里是我的控制代码:xbl文件的属性

<xbl:xbl xmlns:xh="http://www.w3.org/1999/xhtml" 
     xmlns:xf="http://www.w3.org/2002/xforms" 
     xmlns:xs="http://www.w3.org/2001/XMLSchema" 
     xmlns:ev="http://www.w3.org/2001/xml-events" 
     xmlns:xxf="http://orbeon.org/oxf/xml/xforms" 
       xmlns:my="http://www.example.com/" 
     xmlns:fr="http://orbeon.org/oxf/xml/form-runner" 
     xmlns:fb="http://orbeon.org/oxf/xml/form-builder" 
     xmlns:saxon="http://saxon.sf.net/" 
     xmlns:xbl="http://www.w3.org/ns/xbl" 
     xmlns:exf="http://www.exforms.org/exf/1-0" 
     xmlns:xxbl="http://orbeon.org/oxf/xml/xbl" 
     xmlns:oxf="http://www.orbeon.com/oxf/processors"> 

    <xbl:binding id="my-dictionary-selector" element="my|dictionary-selector" xxbl:mode="lhha binding value" xxbl:label-for="select1"> 
     <fb:metadata> 
      <fb:display-name lang="en">Dictionary selector</fb:display-name> 
      <fb:icon lang="en"> 
       <fb:small-icon>/forms/orbeon/builder/images/dropdown.png</fb:small-icon> 
       <fb:large-icon>/forms/orbeon/builder/images/dropdown.png</fb:large-icon> 
      </fb:icon> 
      <fb:datatype>xf:string</fb:datatype> 
      <fb:editors static-itemset="false"/> 
      <fb:template> 
       <my:dictionary-selector id="" appearance="minimal" ref="" resource="" xmlns:xf="http://www.w3.org/2002/xforms"> 
        <xf:label ref=""/> 
        <xf:hint ref=""/> 
        <xf:help ref=""/> 
        <xf:alert ref=""/> 
             <xf:input ref=""/> 
             <xf:resource ref=""/> 
        <xf:itemset ref="/collection/dictionary"> 
         <xf:label ref="key"/> 
         <xf:value ref="value"/> 
        </xf:itemset> 
       </my:dictionary-selector> 
      </fb:template> 
      <fb:control-details> 
       <xf:input ref="@resource" > 
        <xf:label lang="en">Dictionary</xf:label> 
        <xf:hint lang="en">Name of dictionary returning data used to populate the dropdown</xf:hint> 
       </xf:input> 
      </fb:control-details> 
     </fb:metadata> 
     <xbl:resources> 
      <xbl:style> 
       div.xbl-fr-databound-select1 { display: inline; } 
      </xbl:style> 
     </xbl:resources> 
     <xbl:implementation> 
      <xf:model id="xbl-model"> 

       <xf:instance id="itemset"><dummy/></xf:instance> 
       <xf:instance id="submission-ran"><count>0</count></xf:instance> 

       <xf:submission id="get-itemset" method="get" resource="http://localhost:8080/OrbeonForm/resources/dictionaries/{event('resource')}" replace="instance" serialization="none"> 
        <xf:setvalue ev:event="xforms-submit-done" ref="instance('submission-ran')" value=". + 1"/> 
        <xf:action ev:event="xforms-submit-error"> 
         <xf:insert ref="instance('itemset')" origin="xxf:element('dummy')"/> 
        </xf:action> 
       </xf:submission> 
      </xf:model> 
     </xbl:implementation> 
     <xbl:template> 
      <xf:var name="binding" value="xxf:binding('my-dictionary-selector')"/> 

      <xf:var name="resource-avt" xbl:attr="xbl:text=resource" xxbl:scope="outer"/> 
      <xf:var name="resource"> 
       <xxf:value value="xxf:evaluate-avt($resource-avt)" xxbl:scope="outer"/> 
       <xf:action ev:event="xforms-enabled xforms-value-changed"> 

        <xf:send if="string-length(normalize-space($resource)) > 0" submission="get-itemset"> 
         <xf:property name="resource" value="$resource"/> 
        </xf:send> 
       </xf:action> 
      </xf:var> 


      <xf:select1 ref="$binding" id="select1"> 

       <xf:item> 
        <xf:label/> 
        <xf:value/> 
       </xf:item> 

       <xf:choices context="instance()"> 

        <xbl:content includes=":root > xf|itemset, :root > xf|item, :root > xf|choices" xxbl:scope="inner"/> 
       </xf:choices> 
      </xf:select1> 


      <xf:var name="submission-ran" value="instance('submission-ran')/string()"> 
       <xf:action ev:event="xforms-value-changed"> 

        <xf:var name="new-values" value="xxf:itemset('select1', 'xml', false())//value/string()"/> 

        <xf:setvalue if="not($binding = ($new-values, ''))" ref="$binding"/> 

        <xf:insert context="$binding" if="empty(@itemset-empty)" origin="xf:attribute('itemset-empty')"/> 
        <xf:setvalue ref="$binding/@itemset-empty" value="count($new-values) = 1"/> 
       </xf:action> 
      </xf:var> 

     </xbl:template> 
    </xbl:binding> 
</xbl:xbl> 

现在我想借硬编码信息:

out of xbl文件并将其存储在某些属性文件或数据库中。那可能吗?如果是这样,我该怎么做?

回答

0

您可以使用XPath函数xxf:property()来读取您放置在properties-local.xml文件中的属性: