填充模型后,对话框不会更新 [英] Dialog not updating after populating model in action method

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

问题描述

我正在使用一个原子对话框。我有一个项目列表,每当我选择一个项目,我想要对话框显示该项目名称。但是,这并没有发生。而不是显示项目名称,对话框根本不显示任何名称。我已经发布了我的代码。

 < 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 =showDialogBu​​tton
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 打开对话框。



另请参见:




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:

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

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