1
I have the following table:
<p:dataTable id="tabelaDisciplinasSelelecionadas" var="disciplina" value="#{disciplinaBean.droppedDisciplinas}"
rendered="#{not empty disciplinaBean.droppedDisciplinas}">
<p:column headerText="Id">
<h:outputText value="#{disciplina.idDisciplina}" />
</p:column>
<p:column headerText="Nome">
<h:outputText value="#{disciplina.nomeDisciplina}"/>
</p:column>
<p:column headerText="Código">
<h:outputText value="#{disciplina.codigoDisciplina}" />
</p:column>
<p:column headerText="Vagas">
<h:outputLabel for="vagas" value="Vagas: " />
<p:spinner id="vagas" value="#{editalDisciplinaBean.editalDisciplina.vagas}" />
</p:column>
<p:column style="width:32px">
<p:commandButton update=":formDisciplina:display" oncomplete="PF('disciplinaDialog').show()" icon="ui-icon-search">
<f:setPropertyActionListener value="#{disciplina}" target="#{disciplinaBean.disciplinaSelecionada}" />
</p:commandButton>
</p:column>
</p:dataTable>
Editaldisciplinabean.java
ManagedBean(name="editalDisciplinaBean")
@SessionScoped
public class EditalDisciplinaBean {
private EditalDisciplina editalDisciplina;
private EditalDisciplinaDAO editalDisciplinaDAO = new EditalDisciplinaDAO();
private List<EditalDisciplina> lista;
private List<EditalDisciplina> listaFiltro;
private Edital edital;
private Disciplina disciplina;
public EditalDisciplina getEditalDisciplina() {
if (editalDisciplina == null)
editalDisciplina = new EditalDisciplina();
return editalDisciplina;
}
public void setEditalDisciplina(EditalDisciplina editalDisciplina) {
this.editalDisciplina = editalDisciplina;
}
public EditalDisciplinaDAO getDisciplinaDAO() {
return editalDisciplinaDAO;
}
public void setDisciplinaDAO(EditalDisciplinaDAO disciplinaDAO) {
this.editalDisciplinaDAO = disciplinaDAO;
}
public List<EditalDisciplina> getLista() {
if (lista == null)
lista = editalDisciplinaDAO.getListaEditalDisciplina();
return lista;
}
public void setLista(List<EditalDisciplina> lista) {
this.lista = lista;
}
public List<EditalDisciplina> getListaFiltro() {
return listaFiltro;
}
public void setListaFiltro(List<EditalDisciplina> listaFiltro) {
this.listaFiltro = listaFiltro;
}
public Edital getEdital() {
return edital;
}
public void setEdital(Edital edital) {
this.edital = edital;
}
public EditalDisciplinaDAO getEditalDisciplinaDAO() {
return editalDisciplinaDAO;
}
public void setEditalDisciplinaDAO(EditalDisciplinaDAO editalDisciplinaDAO) {
this.editalDisciplinaDAO = editalDisciplinaDAO;
}
public Disciplina getDisciplina() {
return disciplina;
}
public void setDisciplina(Disciplina disciplina) {
this.disciplina = disciplina;
}
}
Vacancies is an attribute of my entity Editaldisciplina (which is a many relationship table for many of Notice and Discipline). So for each row of the table there is a Spinner for me to enter as many vacancies for that discipline, but it turns out that the vacancies are not in the discipline, so I can’t use the datatable variable, so when I give the Submit all Editaldiscipline objects get the same number of vacancies. How do I for each Editaldisciplina have their number of vacancies?
I’m trying to reproduce your state, but a concept escapes me from understanding... Each
EditalDisciplina
has a list that stores voidsDisciplina
s and a list that holds the vacancies of eachDisciplina
? I see a way for you to do what qr... but I don’t know if it would work. Put a Map inside the Notice, and with a method go adding each wave to its equivalent Discipline. This method should be in the button. Have you tried something like this?– Gustavo Cinque