在 JSF 支持 bean 中,我将值定义为,
private List<Cite> cites = new ArrayList<Cite>();
并且Cite
有一个类似的字符串
Cite {
private String value;
}
JSF 代码
<h:panelGroup>
<h:outputText value="Cite"/>
<h:inputText id="citeTxt" style="width:75px" value="#{manualDataEntryRegText.cite}">
<f:ajax execute="@this" render="citeTxt" />
</h:inputText>
</h:panelGroup>
<h:panelGroup>
<h:commandButton value="Add" action="#{manualDataEntryRegText.editCite}">
<f:ajax execute="@this" render="dtCites" />
</h:commandButton>
</h:panelGroup>
<h:panelGroup>
<h:selectManyListbox style="width:75px" id="dtCites" value="#{manualDataEntryRegText.cites}" var="cite" size="3">
<c:selectItems id="citeSelectItems" value="#{cite.value}" />
<c:ajax event="change" />
</h:selectManyListbox>
</h:panelGroup>