Вопрос

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.

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top