Problem with dynamic columns...
cdelosrios Dec 7, 2011 2:12 PMhi, before to continue, let me tell you that I'm a newbie developer using richfaces and I'm facing a problem that I can't solve...so please I need your help!
well, I'll try to be the more specific I can...
this is my result in my db:
What I need is to pass the columns given by dates in columns....something like this (solved using ireport)
But my problem is trying to put it in a datatable, this is my code with jsp
<rich:dataTable value="#{auditoriaController.beanListAplicacion}" var="item">
<rich:column>
<f:facet name="header">
<h:outputText value="Opción" />
</f:facet>
<h:outputText value="#{item.strTransaccion}"></h:outputText>
</rich:column>
<rich:columns value="#{auditoriaController.beanListAplicacion}" var="columns" index="ind">
<f:facet name="header">
<h:outputText value="#{columns.daFecRegistro}" />
</f:facet>
<h:outputText value="#{item[ind].intCntAcceso}"/>
</rich:columns>
<rich:column>
<f:facet name="header">
<h:outputText value="APP" />
</f:facet>
<h:outputText value="----"></h:outputText>
</rich:column>
</rich:dataTable>
And this is my method that populates the grid:
public void listarAplicacion(ActionEvent event){
log.info("--------------------Debugging AuditoriaController.listarAplicacion-----------------------");
setService(auditoriaService);
log.info("Se ha seteado el Service");
SimpleDateFormat sdf2 = new SimpleDateFormat("dd/MM/yyyy");
Date daFecIni = getDaFechaIni();
String daFechaIni = (daFecIni == null ? "" : sdf2.format(daFecIni));
Date daFecFin = getDaFechaFin();
String daFechaFin = (daFecFin == null ? "" : sdf2.format(daFecFin));
HashMap prmtBusq = new HashMap();
prmtBusq.put("pDaFecIni", daFechaIni);
prmtBusq.put("pDaFecFin", daFechaFin);
ArrayList arrayAplicacion = new ArrayList();
ArrayList listaAplicacion = new ArrayList();
try {
arrayAplicacion = getService().listarAplicacion(prmtBusq);
} catch (DaoException e) {
log.info("ERROR getService().listarAplicacion() " + e.getMessage());
// TODO Auto-generated catch block
e.printStackTrace();
}
log.info("arrayAplicacion.size(): "+arrayAplicacion.size());
for(int i=0; i<arrayAplicacion.size(); i++){
Auditoria audit = (Auditoria) arrayAplicacion.get(i);
log.info("ID_EMPRESA = "+audit.getIntIdEmpresa());
log.info("ID_PERSONA = "+audit.getIntIdPersona());
log.info("ID_TRANSACCION = "+audit.getStrIdTransaccion());
log.info("VC_TRANSACCION = "+audit.getStrTransaccion());
log.info("D_FECREGISTRO = "+audit.getDaFecRegistro());
log.info("CNT_ACCESO = "+audit.getIntCntAcceso());
listaAplicacion.add(audit);
//List<FechasAuditoria> beanListColumns = new ArrayList<FechasAuditoria>();
/*beanListColumns.add(new FechasAuditoria(audit.getDaFecRegistro()));
listaTran.add(beanListColumns);*/
}
log.info("listaAplicacion.size(): "+listaAplicacion.size());
log.info("listaTran.size(): "+listaTran.size());
setBeanListAplicacion(listaAplicacion);
}
and finally this is my bean
public class Auditoria {
private Integer intIdEmpresa;
private Integer intIdPersona;
private String strIdTransaccion;
private String strTransaccion;
private String daFecRegistro;
private Integer intCntAcceso;
private List lstFechas;
//Getters and Setters
.
.
.
}
I was trying to use use the rich:columns example that exist in the demos but I couldn't do it.
I can't have a result like I did in my report...I think that I'm making something wrong or maybe everything is wrong. Please help me with this problem...I have many hours trying to solve it and I can't do it.
Sorry for my english.
Thanks.