actionListener and open modalPanel
ascen Jan 17, 2011 6:41 AMI want call a ModalPanel from a dataTable, but First I want to read data from a database in a method in a Bean.
it doesn´t work OK.
That is my code:
-.....
<rich:column width='25%'>
<h:commandLink actionListener="#{listaHorariosBean.setearHora}" immediate="true" reRender="paneldetalle">
<f:param id="fecha" var="fecha" value="#{fila.fecha}" pattern="dd/MM/yyyy" />
<h:graphicImage value="/img/lupa.gif" id="sen1" />
</h:commandLink>
<rich:componentControl for="paneldetalle" attachTo="sen1" operation="show" event="onclick">
</rich:componentControl>
</rich:column>
.....
<rich:modalPanel id="paneldetalle" top="350" left="725" height="275" resizable="true" onbeforehide="Cerrar">
<h:form>
<f:facet name="header">
<h:outputText value="Fichajes"></h:outputText>
</f:facet>
<f:facet name="controls">
<h:panelGroup>
<h:graphicImage value="/img/close.png" style="cursor:pointer" id="paneldetalle" />
<rich:componentControl for="paneldetalle" attachTo="paneldetalle" operation="hide" event="onclick" />
</h:panelGroup>
</f:facet>
<h:outputText value="El Día " ></h:outputText>
<h:outputText value="#{listaHorariosBean.fec3}" >
</h:outputText>
<rich:dataTable id="listhorarios" var="histhor" value="#{listaHorariosBean.listFichajes}" width="80%" rows="8">
<rich:column width='25%'>
<f:facet name="header">HORA</f:facet>
<h:outputText value="#{histhor.hora}" />
</rich:column>
<rich:column width='25%'>
<f:facet name="header">TIPO DE FICHAJE</f:facet>
<h:outputText value="#{histhor.tipo}" />
</rich:column>
<rich:column width='25%'>
<f:facet name="header">INCIDENCIA</f:facet>
<h:outputText value="#{histhor.incidencia}" />
</rich:column>
<rich:column width='25%'>
<f:facet name="header">ESTADO</f:facet>
<h:outputText value="#{histhor.estado}" />
</rich:column>
</rich:dataTable>
</h:form>
</rich:modalPanel>
And Bean: listaHorariosBean.java:
public String setearHora(ActionEvent event){
String nif;
int a=0;
BeanHorario beanHorario = (BeanHorario)
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("beanHorario");
nif=beanHorario.getNif();
UIParameter component = (UIParameter)
event.getComponent().findComponent("fecha");
String fec=component.getValue().toString() ;
String dia_s=fec.substring(0, 2);
String mes_s=fec.substring(3, 5);
String ano_s=fec.substring(6, 10);
String fec2=dia_s+mes_s+ano_s;
fec3=dia_s+"/"+mes_s+"/"+ano_s;
this.setfec3(fec3);
listFichajes.clear();
HorarioDAO p = new HorarioDAO();
LicenciasDAO l = new LicenciasDAO();
try {
this.listHorFichajes = p.getFLst(nficha, nif, fec2);
a=listHorFichajes.size();
if (a>0) {
for (int i=0;i<listHorFichajes.size();i++){
if (listHorFichajes!=null) {
String hh="";
String mm="";
String hora="";
String tipo="";
String incidencia="";
String est="";
String estado="";
String clic="";
String hor=listHorFichajes.get(i).getId().getHora();
hh=listHorFichajes.get(i).getId().getHora().substring(0,2);
mm=listHorFichajes.get(i).getId().getHora().substring(2,4);
hora=hh+":"+mm;
if (listHorFichajes.get(i).getId().getControl().equals("EM")) {tipo="Entrada Mañana";}
else if (listHorFichajes.get(i).getId().getControl().equals("SM")) {tipo="Salida Mañana";}
else if (listHorFichajes.get(i).getId().getControl().equals("ET")) {tipo="Entrada Tarde";}
else if (listHorFichajes.get(i).getId().getControl().equals("ST")) {tipo="Salida Tarde";}
else if (listHorFichajes.get(i).getId().getControl().equals("EN")) {tipo="Entrada Noche";}
else if (listHorFichajes.get(i).getId().getControl().equals("SN")) {tipo="Salida Noche";}
else if (listHorFichajes.get(i).getId().getControl().equals("ED")) {tipo="Salida Desayuno";}
else if (listHorFichajes.get(i).getId().getControl().equals("RD")) {tipo="Regreso Desayuno";}
else if (listHorFichajes.get(i).getId().getControl().equals("EI")) {tipo="Salida Incidencia";
clic=listHorFichajes.get(i).getId().getCodIncidencia();
Licencias lic=l.getNlic(clic);
incidencia=lic.getNLic();
if ((clic.equals("11")) || (clic.equals("19"))){
est=listHorFichajes.get(i).getId().getEstado();
if (est.equals("J")){ estado="Justificado";}
else {estado="No Justificado";}
}
}
else if (listHorFichajes.get(i).getId().getControl().equals("RI")) {tipo="Regreso Incidencia";}
else if (listHorFichajes.get(i).getId().getControl().equals("EV")) {tipo="Visita";}
else if (listHorFichajes.get(i).getId().getControl().equals("SV")) {tipo="Visita";}
if ((listHorFichajes.get(i).getId().getCodIncidencia().equals(""))
& (listHorFichajes.get(i).getId().getEstado().equals("J"))){
estado="Justificado";
}
listFichajes.add(new Fichajes (hora, tipo, incidencia, estado ));
}
}
}
}
catch (Exception e) {
System.out.println("Error al obtener la lista de fichajes: " + e.getMessage());
}
return null;
}