0

Hello I am trying to implement some primefaces commandbuttons in a p:datatable. My need is almost identical to this post: f:setPropertyActionListener not invoked

Basically I need to have a column of buttons in a , click on one button will pass the object of the current row to the bean, and a dialog will pop out, showing some information of the chosen object.

The following is the relevant code:

<f:view>
    <body>
        <h:form id="theForm">

            <p:dataTable id="testFailures" value="#{testDetails.report.failures}" var="failure"
                styleClass="baseTable">
                <p:column id="requestColumn">
                    <f:facet name="header">
                        <h:outputText value="Request" id="requestHeaderText" />
                    </f:facet>
                    <p:commandButton value="Detail" update="requestDialog"
                        oncomplete="PF('dlg1').show();" type="button">
                        <f:setPropertyActionListener
                            target="#{testDetails.selectedFailure}" value="#{failure}" />
                    </p:commandButton>
                    <h:message for="requestDialog" />
                    <p:dialog id="requestDialog" header="Request Dialog"
                        widgetVar="dlg1" dynamic="true">
                        <h:outputText value="#{selectedFailure.request}" />
                    </p:dialog>

                </p:column>
            </p:dataTable>
        </h:form>
        <h:message for="theForm" />

        <h:message for="responseDialog" />
        <p:dialog id="responseDialog" header="Request Dialog"
            widgetVar="dlg2" dynamic="true">
            <h:form>
                <h:outputText value="#{selectedFailure.request}" />
            </h:form>
        </p:dialog>
    </body>
</f:view>

I tried to put the dialog in different positions (see my "dlg1" and "dlg2"). But neither works. No dialog showing. does not show anything either. And I don't see any error message in the browser's console window. (I think there is a exclamation warning).

I have tried debug mode, and set method for the property "selectedFailure" is not called.

Community
  • 1
  • 1
bookmonkie
  • 439
  • 6
  • 21

1 Answers1

0

Try to remove type="button" from your commandButton and it should work. Also dialogs should not be placed inside dataTables so the position of "dlg2" is more correct.

Emil Kaminski
  • 1,886
  • 2
  • 16
  • 26
  • Thanks! I will try tomorrow once I get back to my workstation, then I will accept this answer if it works. – bookmonkie Mar 25 '14 at 23:50
  • After remove the type="button", I am getting this message. Cannot find component with expression "responseDialog" referenced from "theForm:testFailures:0:j_id2139004342_7f7e9ef6". – bookmonkie Mar 26 '14 at 14:36
  • I also noticed that the p:dialog is not added to the rendered html page. – bookmonkie Mar 26 '14 at 14:44
  • I also changed my update into something like this: update=":theID" I also made my bean @ViewScoped – bookmonkie Mar 26 '14 at 16:34