0
以下是處理:我有一個dataTable,由我的託管bean中的列表填充。我想要的是打開一個簡單的primefaces對話框與選定的對象的信息,我想通過使用setPropertyActionListener和onclick事件來做到這一點。如何在javascript onclick事件之前執行JSF setPropertyActionListener事件
<p:commandButton id="basic" value="Resumo" onclick="dlg1.show();"
type="button"
>
<f:setPropertyActionListener target="#{consultaArtigoBean.artigoSelecionado}"
value="#{artigo}" />
</p:commandButton>
和對話
<p:dialog id="basicDialog" header="Resumo - #{consultaArtigoBean.artigoSelecionado.titulo}"
widgetVar="dlg1"
dynamic="true">
#{consultaArtigoBean.artigoSelecionado.resumo}
</p:dialog>
的事情是setPropertyActionListener生效之前的操作執行。所以對話框彈出,沒有任何對象。
我該怎麼做才能確保setProperty在動作之前執行,從而設置我的對象。
更新
的其他話題在這裏幫助回答這個問題。 Pass a value from h:outputLink to JSF after onclick event
,其結果是:
<p:commandLink id="basic" value="Resumo"
oncomplete="dlg1.show();"
update="@form">
<f:setPropertyActionListener target="#{consultaArtigoBean.artigoSelecionado}"
value="#{artigo}" />
</p:commandLink>
和對話
<p:dialog id="basicDialog" header="Resumo - #{consultaArtigoBean.artigoSelecionado.titulo}"
widgetVar="dlg1"
dynamic="true">
#{consultaArtigoBean.artigoSelecionado.resumo}
</p:dialog>