Properties for xbl file

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Properties for xbl file

piechos
This post was updated on .
Hi!
I created my own control and I had to hardcode some information in xbl file. Here is the code of my control:


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

Now I would like to take hardcoded information:
- /collection/dictionary
- key
- value
- http://localhost:8080/OrbeonForm/resources/dictionaries/
out of xbl file and store it in some properties file or in database. Is that possibly? If so how can I do it?
Reply | Threaded
Open this post in threaded view
|

Re: Properties for xbl file

Erik Bruchez
Administrator
You can use the XPath function xxf:property() to read properties which you place in your properties-local.xml file:

    http://doc.orbeon.com/xforms/xpath/extension-core.html#xxfproperty

Regards,

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: Properties for xbl file

Erik Bruchez
Administrator