I have an application loading a datatable from a backing bean. The SubAreas datatable loads the correct number of rows, however they are empty as seen on the image. After debuging I can see that listaArea atribute on the backing bean(responsible for populating the table) is getting the correct data from the database. Area is the entity.
Another datatable on the same screen, called Membros works without a problem.
AREA.XHTML
<div>
<fieldset style="display:#{(areaMB.state == 'update')?'block':'none'}">
<p:dataTable var="teste" id="dtTeste" value="#{areaMB.listaArea}"
widgetVar="dtArea" paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="20, 50, 100"
rows="20" rowKey="#{area.idArea}"
emptyMessage="Nenhum registro" paginatorPosition="bottom">
<p:column headerText="#" width="10%">
<h:outputText value="#{area.idArea}" />
</p:column>
<p:column headerText="Descrição" width="40%"
filterBy="#{area.descricao}"
filterMatchMode="contains">
<h:outputText value="#{area.descricao}" />
</p:column>
<p:column headerText="Sigla" width="20%">
<h:outputText value="#{area.sigla}" />
</p:column>
<p:column headerText="Ativo" width="20%">
<h:outputText value="ATIVO" rendered="#{area.flgAtivo==1}" />
<h:outputText value="INATIVO" rendered="#{area.flgAtivo==0}" />
</p:column>
<p:column headerText="" width="10%" style="text-align:center">
<p:commandButton action="#{areaMB.preparaAlterar}"
update=":formu"
icon="fa fa-pencil" style="margin-right:10px"
title="Alterar"
styleClass="btn btn-default btn-xs">
<f:setPropertyActionListener target="#{areaMB.area}" value="#{area}" />
</p:commandButton>
</p:column>
</p:dataTable>
</fieldset>
</div>
</h:panelGroup>
MANAGED BEAN
@Named
@ViewScoped
public class AreaMB implements Serializable {
private String state = "search";
private String descricao;
private Area area = new Area();
private Area subArea = new Area();
private Usuario usuario = new Usuario();
private AreaUsuario areaUsuario = new AreaUsuario();
private List<Usuario> listaUsuario;
private List<Area> listaArea;
private List<AreaUsuario> listaAreaUsuario;
private List<SelectItem> listaMembro;
private List<Area> listaSubAreas;
private List<TipoArea> listaTipoArea;
private List<Area> listaAreaVinculada;
@PostConstruct
public void init() throws Exception {
pesquisar();
}
public void pesquisar() {
try {
listaArea = AreaService.getInstancia().pesquisar(area, 0, 0);
listaTipoArea = TipoAreaService.getInstancia().getAll();
//a area vinculada nao pode ser ela mesma
listaAreaVinculada = AreaService.getInstancia().getAll();
if (listaAreaVinculada.contains(area)) {
listaAreaVinculada.remove(area);
}
} catch (Exception e) {
// TODO: handle exception
}
}
public void preparaAlterar() {
try {
state = "update";
AreaUsuario au = new AreaUsuario();
au.setIdArea(area.getIdArea());
listaAreaUsuario = AreaUsuarioService.getInstancia().pesquisar(au, AreaUsuarioService.JOIN_USUARIO, 0);
listaMembro = new ArrayList<SelectItem>();
for (AreaUsuario aUsuario : listaAreaUsuario) {
listaMembro.add(new SelectItem(aUsuario.getIdUsuario(), aUsuario.getUsuario().getNome()));
}
listaAreaVinculada.remove(area);
listaSubAreas = AreaService.getInstancia().getSubAreas(area);
} catch (Exception e) {
System.out.println(e.getStackTrace());
}
}
Why is it bringing empty cells?