pessoal estou cm a seguint duvida …
tenho uma pagina jsf cm um h:selectOneMenu e ao lado um h:command… qnd carrego a pagina, ela vem cm apenas um select e qnd clico no link eu adiciono selects fiz esse teste soh Q nao tah dando certo…
c alguem puder me ajudar fico grato
FormBean
import javax.faces.component.UIPanel;
import javax.faces.component.UISelectItem;
import javax.faces.component.UISelectOne;
public class XFB {
private UIPanel panel;
private UISelectOne menu;
private Long id;
public XFB() {
System.out.println("-----XFB-----");
id = (long) 1;
}
public String addSelect() {
UISelectItem item1 = new UISelectItem();
item1.setId(getNewId());
item1.setItemLabel("AAA");
item1.setItemValue("AAA");
UISelectItem item2 = new UISelectItem();
item2.setId(getNewId());
item2.setItemLabel("BBB");
item2.setItemValue("BBB");
UISelectOne one = new UISelectOne();
one.setId(getNewId());
one.getChildren().add(item1);
one.getChildren().add(item2);
panel.getChildren().add(one);
return null;
}
private String getNewId() {
return "componente" + System.currentTimeMillis() + "-" + (id++);
}
public String next() {
return "ok";
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
JSF
<%@ taglib uri=“http://java.sun.com/jsf/core” prefix=“f” %>
<%@ taglib uri=“http://java.sun.com/jsf/html” prefix=“h” %>
<f:view>
<h:messages />
<h:form id=“form”>
<h:panelGrid columns=“1” width=“80%” binding="#{XFB.panel}">
<h:commandLink value=“Adicionar novo” action="#{XFB.addSelect}" />
<h:selectOneMenu binding="#{XFB.menu}">
<f:selectItem itemLabel=“XXX” itemValue=“XXX” />
<f:selectItem itemLabel=“YYY” itemValue=“YYY” />
</h:selectOneMenu>
</h:panelGrid>
</h:form>
</f:view>