Xpages 将值添加到组合框中 [英] Xpages add values into Combo Box
本文介绍了Xpages 将值添加到组合框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个组合框,我希望可以使用按钮和输入字段在组合框中添加新值.我试过:
I have a Combo Box and I would like to have the possibility to add new values in the Combo Box using a button and an Input Field. I tried with:
var value = getComponent("input").getValue();
getComponent("combobox").setValue(value);
但它不起作用.
谢谢,
弗洛林
推荐答案
使用 viewScope 例如viewScope.selectItems
变量.
Use a viewScope e.g. viewScope.selectItems
variable.
- 将此 viewScope 用作 selectItems 列表.
- 向其添加初始值.
- 稍后,向此 viewScope 添加一个额外的新项目,然后它将出现在组合框的选择项目列表中.
这是一个工作示例:
<xp:comboBox
id="comboBox1"
value="#{sessionScope.test}">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:
if (!viewScope.selectItems) {
viewScope.selectItems = ["your","initial","values"];
}
return viewScope.selectItems;}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
<xp:inputText
id="inputText1"
value="#{viewScope.newItem}">
</xp:inputText>
<xp:button
value="Add to selectItems"
id="button1">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:
viewScope.selectItems.add(viewScope.newItem);
viewScope.newItem = "";
}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
这篇关于Xpages 将值添加到组合框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文