Command Lnks inside DataTable
deibys Jan 24, 2008 1:24 PMHello Guys!!
I have the following code :
<rich:dataTable id="prospectoTable" value="#{SearchProspecto.prospectoItems}" var="prospecto" rowKeyVar="index" onRowMouseOver="this.style.backgroundColor='#FFE4E1'" onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'" > <h:column> <f:facet name="header"> <h:outputText value="#" /> </f:facet> <h:outputText value="#{index+1}" /> </h:column> <h:column> <f:facet name="header"> <h:outputText value="Identificacion" /> </f:facet> <h:outputText value="#{prospecto.identificacion}" /> </h:column> <h:column> <f:facet name="header"> <h:outputText value="Nombre" /> </f:facet> <h:outputText value="#{prospecto.fullName}" /> </h:column> <h:column> <h:form> <a4j:region> <a4j:commandLink immediate="true" value="Editar" action="#{SearchProspecto.editar}" > <a4j:actionparam name="prospectoIdSelected" assignTo="#{SearchProspecto.prospectoIdSelected}" value="#{prospecto.id}" /> </a4j:commandLink> </a4j:region> </h:form> </h:column> <%-- <rich:componentControl event="onRowDblClick" for="propectoDetails" operation="show"> <f:param value="#{prospecto.id}" name="prospectoId" /> </rich:componentControl> --%> </rich:dataTable>
One of the columns (violet colour) has a command link.....that calls a method in the backing bean
public String editar() throws NamingException, SQLException { System.out.println("prospecto_id="+prospectoIdSelected); Prospecto prospecto = Prospecto.getProspectoById(prospectoIdSelected); FacesUtil.setRequestMapValue("prospecto", prospecto); if (prospecto.getTipoCliente() == 1) { return "editar_empresarial"; } else { return "editar_individual"; } }
I have two weird issues:
1. Only the last row of the table seems to call the method specified in the action attribute
2. When I click on the link on the last row , method gets called, but it does not navigate according to my rules in faces-config.xml
<navigation-rule> <from-view-id>/Prospectacion/searchProspecto.jsp</from-view-id> <navigation-case> <from-outcome>editar_empresarial</from-outcome> <to-view-id>/Prospectacion/editProspecto_e.jsp</to-view-id> </navigation-case> <navigation-case> <from-outcome>editar_individual</from-outcome> <to-view-id>/Prospectacion/editProspecto_i.jsp</to-view-id> </navigation-case> </navigation-rule>
Why this stranged behaviour ?