我有另一个问题。 我想创建新的自定义控件,这几乎与动态数据下拉菜单相同。区别在于用户而不是输入控件详细信息数据,如下所示:
应该只通过
并且URL和其他数据的其余部分应该是默认值并在控件中记住。因此,不应该有4个输入字段(url,item,label,value),而应该只有1个(字典)。我已经说明了如何删除这些输入字段并添加我想要的字段:
我只是替换了这部分代码:
<xf:input ref="@resource">
<xf:label lang="en">Resource URL</xf:label>
<xf:label lang="es">URL del Recurso</xf:label>
<xf:label lang="fi">Resurssi URL</xf:label>
<xf:label lang="fr">URL de la ressource</xf:label>
<xf:label lang="ru">URL ресурса</xf:label>
<xf:label lang="it">URL della risorsa</xf:label>
<xf:label lang="de">URL der Ressource</xf:label>
<xf:label lang="sv">Resursens adress</xf:label>
<xf:label lang="nl">Resource URL</xf:label>
<xf:label lang="pt">URL do Recurso</xf:label>
<xf:hint lang="en">HTTP URL returning data used to populate the dropdown</xf:hint>
<xf:hint lang="es">HTTP URL retornando datos para poblar la lista</xf:hint>
<xf:hint lang="fi">HTTP URL palauttaa pudotusvalikon täyttämiseen käytettyä dataa</xf:hint>
<xf:hint lang="fr">URL HTTP auquel réside le service</xf:hint>
<xf:hint lang="ru">HTTP URL сервиса, данными из которого будет заполнен выпадающий список</xf:hint>
<xf:hint lang="it">URL HTTP che da i dati per il menu a tendina</xf:hint>
<xf:hint lang="de">HTTP URL die die Inhalte für das Dropdown-Menü liefert</xf:hint>
<xf:hint lang="sv">Vanligen en Internetadress som börjar med http://</xf:hint>
<xf:hint lang="nl">HTTP URL als bron voor de gegevens in de selectie</xf:hint>
<xf:hint lang="pt">HTTP URL devolvendo dados para preencher a lista de opções</xf:hint>
</xf:input>
<xf:input ref="xf:itemset/@ref">
<xf:label ref="$resources/dialog-actions/items/label"/>
<xf:hint ref="$resources/dialog-actions/items/hint"/>
</xf:input>
<xf:input ref="xf:itemset/xf:label/@ref">
<xf:label ref="$resources/dialog-actions/item-label/label"/>
<xf:hint ref="$resources/dialog-actions/item-label/hint"/>
</xf:input>
<xf:input ref="xf:itemset/xf:value/@ref">
<xf:label ref="$resources/dialog-actions/item-value/label"/>
<xf:hint ref="$resources/dialog-actions/item-value/hint"/>
</xf:input>
用这个:
<xf:input ref="@resource">
<xf:label lang="en">Dictionary</xf:label>
<xf:hint lang="en">Dictionary returning data used to populate the dropdown</xf:hint>
</xf:input>
现在我不知道如何存储应该记住的默认值以及如何将它们绑定到方法,以便它可以从url检索元素到我的下拉控件。请帮忙
答案 0 :(得分:0)
好的,我做过类似的事情:
<xbl:xbl xmlns:xh="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:my="http://www.example.com/"
xmlns:saxon="http://saxon.sf.net/"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:xxbl="http://orbeon.org/oxf/xml/xbl">
<metadata xmlns="http://orbeon.org/oxf/xml/form-builder">
<display-name lang="en">Custom Controls</display-name>
</metadata>
<xbl:binding id="my-dictionary-selector" element="my|dictionary-selector" xxbl:mode="lhha binding value">
<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:template>
<my:dictionary-selector>
<xf:label ref=""/>
<xf:hint ref=""/>
<xf:help ref=""/>
<xf:alert ref=""/>
<xf:itemset ref="()">
<xf:label ref="()"/>
<xf:value ref="()"/>
</xf:itemset>
</my:dictionary-selector>
</fb:template>
<fb:control-details>
<xf:input ref="@resource" name="aa">
<xf:label lang="en">Dictionary</xf:label>
<xf:hint lang="en">Dictionary name returning data used for the suggestions</xf:hint>
</xf:input>
</fb:control-details>
</fb:metadata>
<xbl:template>
<xf:select1 appearance="minimal" ref="xxf:binding('my-dictionary-selector')">
<xf:item>
<xf:label>[Select...]</xf:label>
<xf:value/>
</xf:item>
<xf:itemset nodeset="doc('http://localhost:8080/OrbeonForm/resources/dictionaries/colors')/collection/dictionary">
<xf:label ref="key"/>
<xf:value ref="value"/>
</xf:itemset>
</xf:select1>
</xbl:template>
</xbl:binding>
</xbl:xbl>
并且它有效(从给定的xml获取值),但现在我想给用户机会选择字典的名称。因此,在xml文件(http://localhost:8080/form/resources/dictionaries/colors)的URL中,我想要在控件详细信息中插入用户放入字典输入的字符串代替颜色。我怎样才能实现它?用户点击控制详细信息后,是否会更改下拉列表?