开发者

Why actionListener is called after ajax process using p:commandButton?

I'm trying to open a dialog when a button inside a data table is clicked. The dialog contains another data table with details related to the row the button is belonging to. The listener sets a variable that is required for the detail data table. Using the following snippet it seems that the update (and so the creation of the list used by the detail data table) is performed before the actionListener gets fired, so the dataTable in the dialog is always empty. Why? Is that the wanted behaviour? Is there another way to solve my problem?

I used action instead of actionListener with the same result.

Here is the element button in the first data table:

                       <p:column style="width:16px;padding-left:4px;padding-right:4px;">  
                            <f:facet name="header">

                            </f:facet>
                            <p:commandButton image="ui-icon ui-icon-search"
                                             style="width:开发者_如何学Go1.8em;height:1.8em"
                                             onsuccess="tDialog.show()"
                                             title="#{msgs.dettaglio}"
                                             process="@this, timbrature_dt"
                                             update="timbrature_dt"
                                             immediate="true"
                                             actionListener="#{dispCongediMBean.timbratureDettAction(dett)}">  
                            </p:commandButton>  
                        </p:column>

Here is the dialog:

       <p:dialog header="#{msgs.timbrature}" widgetVar="tDialog" resizable="false">  

                    <p:dataTable id="timbrature_dt" 
                                 value="#{dispCongediMBean.timbratureDataList}" 
                                 var="tdett">
                        <p:column>
                            <f:facet name="header">  
                                #{msgs.data}  
                            </f:facet>  
                            <h:outputText value="#{tdett.sDtComp}"/> 
                        </p:column>
                        ....

Here is the sequence of calls:

INFO: getTimbratureDataList
INFO: Nessuna timbratura.
INFO: getTimbratureDataList
INFO: Nessuna timbratura.
INFO: getTimbratureDataList
INFO: Nessuna timbratura.
INFO: getDettaglioDataList list dettaglio: 4
INFO: timbratureDettAction
INFO: gius corrente 315

as you can see, the method getTimbratureDataList() is called before the actionListener timbratureDettAction() which correctly set the value which is unfortunately not used.

I'm using Glassfish and primefaces 2.1.1.


It looks to me like you're trying to process both the current button, and also the dialog content itself. Since this means it will need to rebuild the component tree, of course the getter will be called for the detail dialog.

Thus you need to process only the button, and re-render only the detail table: <p:commandButton image="ui-icon ui-icon-search" style="width:1.8em;height:1.8em" onsuccess="tDialog.show()" title="#{msgs.dettaglio}" process="@this" update="timbrature_dt" immediate="true" actionListener="#{dispCongediMBean.timbratureDettAction(dett)}">

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜