填充模型后,对话框不会更新 [英] Dialog not updating after populating model in action method
本文介绍了填充模型后,对话框不会更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< h:form>
< h:dataTable binding =#{table}value =#{item.itemList}>
< h:column>
< h:link value =#{item.itemList [table.rowIndex]}outcome =item>
< f:param name =itemNamevalue =#{item.itemList [table.rowIndex]}/>
< / h:link>
< / h:column>
< h:column>
< p:commandButton action =#{item.setItem(item.itemList [table.rowIndex])}id =showDialogButton
type =linkvalue =Deleteonclick = dlg.show()/>
< / h:column>
< / h:dataTable>
< br />
< p:dialog header =ItemwidgetVar =dlgresizable =false>
<! - 我也尝试过Item:#{item.item} - >
< p>项目:< f:attribute name =contentIdvalue =#{item.item}/> < / p为H.
< p:commandButton id =submitButtonvalue =是action =
#{item.deleteItem}oncomplete =dlg.hide();>
< / p:commandButton>
< p:commandButton id =cancelButtonvalue =取消oncomplete =dlg.hide(); />
< / p:dialog>
< / h:form>
我的getter和setter只是通用的getter和setter。
解决方案
在开始之前忘了更新对话框。
p:commandButton ... update =dialogId/>
我还建议使用 oncomplete
而不是 onclick
打开对话框。
另请参见:
- 了解PrimeFaces的流程和更新属性
- 如何从p:dataTable中显示当前行的详细信息ap:对话框
- 如果update =dlg,则原始对象不总是显示;在commandButton
I am using a primefaces dialog box. I have a list of items, and whenever I choose an item, I want the dialog box to display that item name. However, this is not happening. Rather than displaying the item name, the dialog is not displaying any name at all. I've posted my code below.
<h:form>
<h:dataTable binding="#{table}" value="#{item.itemList}" >
<h:column>
<h:link value="#{item.itemList[table.rowIndex]}" outcome="item">
<f:param name="itemName" value="#{item.itemList[table.rowIndex]}" />
</h:link>
</h:column>
<h:column>
<p:commandButton action="#{item.setItem(item.itemList[table.rowIndex])}" id="showDialogButton"
type="link" value="Delete" onclick="dlg.show()" />
</h:column>
</h:dataTable>
<br />
<p:dialog header="Item" widgetVar="dlg" resizable="false">
<!-- I've also tried Item: #{item.item} -->
<p>Item: <f:attribute name="contentId" value="#{item.item}"/> </p>
<p:commandButton id="submitButton" value="Yes" action=
"#{item.deleteItem}" oncomplete="dlg.hide();">
</p:commandButton>
<p:commandButton id="cancelButton" value="Cancel" oncomplete="dlg.hide();" />
</p:dialog>
</h:form>
My getters and setters are just generic getters and setters.
解决方案
You forgot to update the dialog before opening.
<p:commandButton ... update="dialogId" />
I also suggest to use oncomplete
instead of onclick
to open the dialog.
See also:
- Understanding process and update attributes of PrimeFaces
- How to show details of current row from p:dataTable in a p:dialog
- Primefaces p:dialog doesn't always show up if update="dlg" in commandButton
这篇关于填充模型后,对话框不会更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文