I have a list that is populated by data from an xml file and another list that is returned from a query in the database. I would like to know if it is possible for me to compare existing code in these 2 lists. If the codes are the same, they do not display this element in the dataTable.
Example:
Lista 1 (xml): [processo[cod= 123, nome=Diego], processo[cod= 321, nome=Bruno]]
Lista 2 (bd): [processo[cod=321, nome Bruno], processo[cod = 456, nome=josé]]
The process of code 321
and name Bruno
exists in both lists, so it does not appear in dataTable
DataTable:
Código Nome
123 Diego
456 José
How do I get to this result?
Bean:
@ManagedBean(name = "dtBasicView")
@ViewScoped
public class SolicitacoesBean {
private List<Solicitacoes> list;
private List<Solicitacoes> listaFiltrada;
@PostConstruct
public void init() {
// pega a lista com os dados do .xml
try {
list = XmlParserSolicitacoes
.realizaLeituraXML("C:\Solicitacoes.xml");
System.out.println(list);
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Method that returns the database query in a list:
public List<SolicitacoesBD> listar(){
SolicitacoesDAO dao = new SolicitacoesDAO();
List<SolicitacoesBD>lista = dao.listar();
for(SolicitacoesBD s : lista){
System.out.println(s);
}
return lista;
}
My dataTable:
<p:dataTable emptyMessage="Nenhum registro encontrado" var="lista"
value="#{dtBasicView.list}"
filteredValue="#{dtBasicView.listaFiltrada}" rows="10"
paginator="true" style="margin-top: 5px;"
rowKey="#{lista.codigoBeneficiario}">
<p:column headerText="Código" filterBy="#{lista.codigoBeneficiario}" style="width:20%" >
<h:outputText value="#{lista.codigoBeneficiario}" />
</p:column>
<p:column headerText="Nome" filterBy="#{lista.nomePessoa}" style="width:45%;"
sortBy="#{lista.nomePessoa}">
<h:outputText value="#{lista.nomePessoa}" />
</p:column>
<p:column headerText="Senha" style="width:10%">
<h:outputText value="#{lista.senha}" />
</p:column>
<p:column headerText="Data Solic." style="width:20%">
<h:outputText value="#{lista.dataSolicitacao}" />
</p:column>
<p:column headerText="Status" style="width:22%" sortBy="#{lista.status}" filterBy="#{lista.status}">
<h:outputText value="#{lista.status}" />
</p:column>
<p:column headerText="Opções" style="width:7%">
<p:commandButton icon="ui-icon-search"
action="#{dtBasicView.abrirDialogo}" process="@this">
<!-- Mandar informação para outra página -->
<f:setPropertyActionListener target="#{dtBasicView.solicitacoes}" value="#{lista}" />
</p:commandButton>
</p:column>
</p:dataTable>