1

I use Primefaces 3.1, JSF 2.1.6 on Glassfish 3.1.1.

I have loads of commandbuttons which work fine, but this one doesn't and I can't figure out why. The javascript alert fires but the controller method is never called.

Note that the first commandbutton fires perfectly (the Filter button) but the edit button inside the datatable does not fire. Instead of a dataGrid I tried ui:repeat but this gives the same effect/issue. I have a lot of other datatables with a commandbutton but they all work fine...strange.

<h:form id="memberships" prependId="false">
        <h:panelGrid columns="3">
            <h:outputLabel value="Filter on EPS" />
            <p:selectOneMenu value="#{epsMembershipViewController.selectedEps}"
                style="width:200px" effect="fold" editable="false" id="selectEps">
                <f:selectItem itemLabel="Select One" itemValue="" />
                <f:selectItems value="#{epsMembershipViewController.allEps}" />
            </p:selectOneMenu>
            <p:commandButton value="Filter"
                action="#{epsMembershipViewController.repopulateView}" ajax="false" />
        </h:panelGrid>
        <br />

        <p:dataGrid var="eps" value="#{epsMembershipViewController.ldapEpss}"
            columns="1">

            <h:outputLabel value="#{eps}"
                style="font-weight: bold;font-size: 14px;" />

            <p:dataTable var="ldapUser" id="id_#{eps}"
                value="#{epsMembershipViewController.getUsersByEpsFromLdap(eps)}"
                paginator="false" selectionMode="single" rowKey="#{ldapUser.name}"
                rowStyleClass="#{ldapUser.expired == 'Yes' ? 'expired' : null}">

                ....... columns



                <p:column style="width:20px">
                    <f:facet name="header">
                        <h:outputText value="" />
                    </f:facet>
                    <p:commandButton icon="ui-icon-extlink"
                        onclick="alert('this event does not work')" ajax="false"
                        action="#{epsMembershipViewController.edit()}" />
                </p:column>

            </p:dataTable>

            <br />
            <br />

        </p:dataGrid>
    </h:form>

Bean code

public String edit(ActionEvent e) {

    log.debug("EDIT USER 22222 ");


    return "eps-search";
}

Thanks for your help, Coen

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Coen Damen
  • 2,009
  • 5
  • 29
  • 51
  • Try to shorten your example. While doing this you have good chances to figure out your problem. Otherwise we have better chances to find the relevant lines of code in your example. – Thor Feb 16 '12 at 15:42
  • As per OP's comments on my (deleted) answer, the cause turns out to be a missing `` inside the ``. – BalusC Feb 16 '12 at 16:40

1 Answers1

1

Aaarghh, as ever so often, after half a day of tweaking I posted the question and 10 mins later I see the problem.

The problem is that the datatable is not wrapped inside a p:column. It is rendered OK but that is causing the form to just do a submit without calling the backing bean method.

<p:dataGrid var="eps" value="#{epsMembershipViewController.ldapEpss}"
            columns="1">

            <p:column> THIS WAS NOT PRESENT !!!!

                <f:facet name="header">
                    <h:outputText value="#{eps}" />
                </f:facet>

                <p:dataTable var="ldapUser" id="id_#{eps}"
                    value="#{epsMembershipViewController.getUsersByEpsFromLdap(eps)}"
                    paginator="false" selectionMode="single" rowKey="#{ldapUser.name}"
                    rowStyleClass="#{ldapUser.expired == 'Yes' ? 'expired' : null}">

                                           ..... COLUMNS .........

                    <p:column style="width:20px">
                        <f:facet name="header">
                            <h:outputText value="" />
                        </f:facet>
                        <p:commandButton icon="ui-icon-extlink"
                            onclick="alert('this event does not work')" ajax="false"
                            action="#{epsMembershipViewController.edit()}" />
                    </p:column>

                </p:dataTable>

            </p:column>
Coen Damen
  • 2,009
  • 5
  • 29
  • 51
  • awesome, I got the exact same problem. Note to myself, check stackoverflow first, avoid waisting 3 hours of sh*tting around – roel Sep 16 '13 at 14:29