在操作方法中填充模型后对话框未更新 [英] Dialog not updating after populating model in action method

查看:22
本文介绍了在操作方法中填充模型后对话框未更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 primefaces 对话框.我有一个项目列表,每当我选择一个项目时,我希望对话框显示该项目名称.然而,这并没有发生.该对话框根本不显示任何名称,而不是显示项目名称.我已经在下面发布了我的代码.

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>

我的 getter 和 setter 只是通用的 getter 和 setter.

My getters and setters are just generic getters and setters.

推荐答案

您忘记在打开之前更新对话框.

You forgot to update the dialog before opening.

<p:commandButton ... update="dialogId" />

我还建议使用 oncomplete 而不是 onclick 来打开对话框.

I also suggest to use oncomplete instead of onclick to open the dialog.

这篇关于在操作方法中填充模型后对话框未更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆