0

我有这个代码

<select id="vlm" name="vlm" class="pnx-inline-edit-select">
    <option value="#{agreement.valueForNiVlmVersion}">
        <h:outputText value="#{agreement.valueForNiVlmVersion}"/>
    </option>
</select>

这将显示一个下拉框,其中包含 valueForNiVlmVersion 的内容。现在,在同一个 bean 中,我有一个名为 validValues 的值列表,需要在那里显示而不是单个 valueForNiVlmVersion。因此,我需要删除 valueForNiVlmVersion,而是添加来自 validValues 的值。问题是我不确定如何遍历列表以动态提取值。我可以使用 javascript 和 jquery 1.9。

谢谢!

4

1 回答 1

2

You can use an iterative component for this purpose like <ui:repeat>, to produce custom HTML code in a way you like:

<select id="vlm" name="vlm" class="pnx-inline-edit-select">
    <ui:repeat value="#{bean.validValues}" var="val">
        <option value="#{val.value}">#{val.label}</option>
    </ui:repeat>
</select>

But ultimately, why are you not considering a standard <h:selectOneMenu> solution?

于 2013-09-12T19:59:35.927 回答