我想在 JSF(Primefaces)中动态创建一个 SelectOnListBox,但我不知道如何用“Verde”和“Azul”填写值
FacesContext fCtx = FacesContext.getCurrentInstance();
ELContext elCtx = fCtx.getELContext();
ExpressionFactory ef = fCtx.getApplication().getExpressionFactory();
getL_valores().put("Verde", "Verde");
getL_valores().put("Azul", "Azul");
javax.faces.component.html.HtmlSelectOneListbox lista = new javax.faces.component.html.HtmlSelectOneListbox();
lista.setRendererType("javax.faces.Listbox");
lista.setId("variacion1");
lista.setValue(getL_valores());
lista.setLabel("lista1");
dynamicFieldGroup = new HtmlPanelGrid();
dynamicFieldGroup.setColumns(4);
dynamicFieldGroup.getChildren().add(lista);
这是我的 xhtml
<h:form id="Form1">
<p:panelGrid columns="2" binding="#{b_detalle_productos.dynamicFieldGroup}"></p:panelGrid>
</h:form>