Search code examples
jsfjsf-2primefaces

p:commandLink not working with dataTable


My dataTable is populated by an ajax call, my commandLink (in the datataable) is not pointing to the correct location and always render the same page.and show me in the console : HtmlLabelRend W Attribute 'for' of label component with id j_id1471051656_3ffdbef6:j_id1471051656_3ffdbfc6 is not defined

But when I put the commandlink outside the datatable the action method works fine.

This problem is rare!, How Can I solve it?

Thanks in advance.

My Jsf Page:

<h:form>
        <p:panel header="Busqueda">
            <p:panelGrid style="width:100%;">
                <p:row>
-----------------------------------(inputs)---------------------------------------
                    <p:column>
                        <p:commandButton value="Buscar" update="grilla"
                            action="#{devolucionAdminController.buscarSD()}">´
                            </p:commandButton>
                    </p:column>
                </p:row>
            </p:panelGrid>
            <p:messages closable="true" redisplay="true" id="msj"></p:messages>
        </p:panel>
        <p:dataTable id="grilla" var="r"
            value="#{devolucionAdminController.listado}"
            emptyMessage="No se han encontrado solicitudes de devolución">
            <p:column headerText="Sec">
                <h:outputText value="#{r.idSoliDevo}" />
            </p:column>
            <p:column headerText="Cuenta">
                <h:outputText value="#{r.cuentaId}" />
            </p:column>
            <p:column headerText="Ver Detalle Sol. Dev ">
                <p:commandLink 
                    action="#{bajaController.mostrarSolicitudBaja(r.cuentaId,r.idSoliDevo)}" ajax="false">
                    <p:commandButton icon="ui-icon-search" title="Ver Detalle" />
                </p:commandLink>
                </p:column>
        </p:dataTable>

<!--works fine  -->
    <p:commandLink action="#{bajaController.mostrarSolicitudBaja(80003,340)}"
            ajax="false">
            <p:commandButton icon="ui-icon-search" title="Ver Detalle" />
        </p:commandLink>
        </h:form>

My first Managed Bean:

@ManagedBean
@RequestScoped
public class DevolucionAdminController {
 List<TaSoliDevo> listado;
//getters and setters
........................
public void buscarSD() {

   .............................
}

My second Managed Bean:

@ManagedBean
@RequestScoped
public class BajaController {

    public String mostrarSolicitudBaja(long cuentaId, long solicDevId) {
    .........................
    return "goResult";

}}

Solution

  • replace your commandLink with

    <p:commandButton  icon="ui-icon-search" title="Ver Detalle"
    action="#{bajaController.mostrarSolicitudBaja(r.cuentaId,r.idSoliDevo)}" ajax="false"/>
    

    Really no need to put a command button inside a command Link, just to put an icon