I'm using the Drag and Drop DataTable component. Contextualizing is as follows:
I have a registration based on steps. Where in the first step I enter the information of an Edital X, which is manipulated by the editalBean, already in the second step I have the Drag and Drop component with the Disciplines to be chosen, so far so good. If I do not even suggest the documentation I can make it work fine. But here comes the problem: The method of my disciplinesBean needs to be passed a center (entity) as a parameter and this center is in the editalBean. My solution was to put the list of selected disciplines in the Bean disciplines and the complete list of disciplines in the editalBean (which is where I can pass the parameter).
The method that handles these two lists is this (when they are in the same bean):
public void onDisciplinaDrop(DragDropEvent ddEvent) {
Disciplina disciplina = ((Disciplina) ddEvent.getData());
listaSelecionadoss.add(disciplina);
listaCompleta.remove(disciplina);
}
Then the discipline is added to one table and removed from another. But as I put the full list of disciplines on another bean, I do not know how to remove it.
My method onDisciplinaDrop is in the Beanclass and myComplete list is in the editalBean. How can I do to make the correct removal?
My codes:
EditalBean.java
@ManagedBean(name="editalBean")
@SessionScoped
public class EditalBean {
private Edital edital;
private EditalDAO editalDAO = new EditalDAO();
private Centro centro;
private CentroDAO centroDAO = new CentroDAO();
private DisciplinaDAO disciplinaDAO = new DisciplinaDAO();
private List<Disciplina> listaPorCentro;
public List<Disciplina> getListaPorCentro() {
listaPorCentro = disciplinaDAO.getListaDisciplinaPorCentro(edital.getAno(), edital.getPeriodo(), centro);
return listaPorCentro;
}
public void setListaPorCentro(List<Disciplina> listaPorCentro) {
this.listaPorCentro = listaPorCentro;
}
DisciplineBean.java
@ManagedBean(name="disciplinaBean")
@SessionScoped
public class DisciplinaBean {
private Disciplina disciplina;
private Disciplina disciplinaSelecionada;
private List<Disciplina> droppedDisciplinas = new ArrayList<Disciplina>();
private DisciplinaDAO disciplinaDAO = new DisciplinaDAO();
public void onDisciplinaDrop(DragDropEvent ddEvent) {
if(droppedDisciplinas != null){
droppedDisciplinas.add(d);
}else {
System.out.println("droppedDisciplinas é nulo.");
}
}
If you need more details try to explain better. Thank you.