F: setPropertyActionListener not called

I am trying to move p:dialogfrom h:formbecause I read that this is the preferred way (however, I would like to understand the reason because my p:dialoginside a formworks well in my application).

The only difficulty is that the title of the dialog needs to be updated dynamically. A dialog box appears when button c is pressed p:dataTable.

Here is my old xhtml (before changes) that works fine:

<p:dataTable var="event" value="#{eventBean.lazyModel}" selection="#{eventBean.selectedEvent}" />
    ...
    <p:column headerText="#{msgs.Persons}">
        <p:commandButton value="#{msgs.ViewPersons}" update=":viewPersonsForm" oncomplete="viewPersonsDlg.show()"> 
            <f:setPropertyActionListener value="#{event}" target="#{eventBean.selectedEvent}" />
        </p:commandButton>
    </p:column>
</p:dataTable>
<h:form id="viewPersonsForm">
    <p:dialog modal="true" widgetVar="viewPersonsDlg" dynamic="true" header="#{eventBean.selectedEvent.name}" >
        ...
    </p:dialog>
</h:form>

And here is the new xhtml, with eventBean # setSelectedEvent (), which is not being called.

<p:dataTable var="event" value="#{eventBean.lazyModel}" selection="#{eventBean.selectedEvent}" />
    ...
    <p:column headerText="#{msgs.Persons}">
        <p:commandButton value="#{msgs.ViewPersons}" update=":viewPersonsDlgId" oncomplete="jQuery('#viewPersonsDlgId .ui-dialog-title').text('#{eventBean.selectedEvent.name}');viewPersonsDlg.show()"> 
            <f:setPropertyActionListener value="#{event}" target="#{eventBean.selectedEvent}" />
        </p:commandButton>
    </p:column>
</p:dataTable>
<p:dialog modal="true" id="viewPersonsDlgId" widgetVar="viewPersonsDlg" dynamic="true" >
    ...
</p:dialog>

So, again, why is the eventBean # setSelectedEvent () not called in the second script? And, if possible, why is the first scenario not optimal?

+5
source share
2

p:dialog h:form, , - , :

p:dialog h:form 1

p:dialog h:form 2

, jQuery oncomplete , f:setPropertyActionListener. , , . :

<p:dataTable var="event" value="#{eventBean.lazyModel}" selection="#{eventBean.selectedEvent}" />
    ...
    <p:column headerText="#{msgs.Persons}">
        <p:commandButton value="#{msgs.ViewPersons}" update=":viewPersonsDlgId" oncomplete="viewPersonsDlg.show()"> 
            <f:setPropertyActionListener value="#{event}" target="#{eventBean.selectedEvent}" />
        </p:commandButton>
    </p:column>
</p:dataTable>
<p:dialog modal="true" id="viewPersonsDlgId" widgetVar="viewPersonsDlg" dynamic="true" header="#{eventBean.selectedEvent.name}" >
    ...
</p:dialog>

jQuery .

+4

(pf 3.5):

<p:tabView id="cashFlowTabContainer" style="width:100%" activeIndex="0"
    widgetVar="cashFlowTabContainerVar">
    <p:tab title="#{labels['cashflow_incoming']}">
        <p:outputPanel id="incomingPanel">
            <p:dataTable value="#{cashFlowController.incomingCashFlows}"
                var="cashFlow">
<p:column headerText="#{labels.cashflow_actions}">
                    <p:commandButton value="Edit"
                        action="#    {cashFlowController.editIncoming}" update="@form" oncomplete="editInputVar.show();">
                        <f:setPropertyActionListener     value="#{cashFlow}"
                            target="#{cashFlowController.selectedIncoming}" />
                    </p:commandButton>
                </p:column>

:

<p:dialog id="editInput" header="Dynamic Dialog"
    widgetVar="editInputVar" resizable="false" draggable="false"
    modal="true">
    <p:panel>
        <h:panelGrid columns="2" cellpadding="5">
...
<h:outputText value="#{labels.cashflow_description}:" />
            <h:inputText
                value="#{cashFlowController.selectedIncoming.description}" />

... , . , , .

, "rendered":

<p:dialog id="editInput" header="Dynamic Dialog"
    widgetVar="editInputVar" resizable="false" draggable="false"
    modal="true">
    <p:panel **rendered="#{cashFlowController.selectedIncoming != null}"**>
        <h:panelGrid columns="2" cellpadding="5">

, , ... :)

+2

All Articles