【问题标题】:Closing dialog doesnt work关闭对话框不起作用
【发布时间】:2014-05-09 09:02:14
【问题描述】:

我正在使用 primefaces 5.0,我遇到了这种情况:

<composite:implementation>

<p:dialog id="confirmDialog#{cc.attrs.someParam}"
    rendered="#{cc.attrs.nextState.warnRequired}" severity="alert" resizable="false" modal="#{cc.attrs.modal}"
    widgetVar="confirmation#{cc.attrs.someParam}">

    <p:commandButton value="#{msg[cc.attrs.nextState.buttonKey]}" icon="#{nextStatus.icon}"
        action="#{someActionCalled}"
        update="#{cc.attrs.update}" process="#{cc.attrs.process}"
        oncomplete="if (!args.validationFailed) { PF('confirmation#{cc.attrs.someParam}').hide(); }">
    </p:commandButton>

    
    <p:commandButton id="decline" value="#{msg['action.cancel']}" icon="ui-icon ui-icon-cancel"
        onclick="PF('confirmation#{cc.attrs.someParam}').hide()"  />

</p:dialog>


</composite:implementation>

当我点击“拒绝”/取消按钮时,confirmDialog 关闭/隐藏。没关系。 显然确认#{cc.attrs.someParam} 可以找到 widgetVar 并关闭此对话框。
但是,当我单击第一个按钮进行确认并在 back bean 中采取一些操作时,我得到:

Widget for var 'confirmationSomeParam' not available!
primef...mefaces (line 1)
detailed error: TypeError: PF(...) is null

{cc.attrs.someParam}

被传递到组件中。它的评估干净和值在那里(显然是因为第二个按钮可以关闭对话框。
所以很奇怪第一个按钮找不到这个对话框 widgetVar 而第二个按钮可以吗?

【问题讨论】:

    标签: ajax primefaces


    【解决方案1】:

    所以我有时间再次检查我的应用程序的这个关键部分并在这里发布,以便将来有人可能会发现这很有用:)

    我在代码中的两个按钮下都添加了 p:remoteCommand:

    &lt;p:remoteCommand name="somethingToDo" update="#{cc.attrs.update}" /&gt;

    在第一个按钮中,我删除了更新参数。

    为什么?因为正如错误所说,它找不到一些 dialogId(在本例中为 'confirmation332m' ),并且由于更新参数正在更新整个表单,所以对话框被删除/更新。

    所以我将更新参数从按钮移动到远程命令并在 onComplete 我只是在检查完所有验证后打电话给somethingToDo();。

    也许它不是最好的解决方案,但现在它可以工作;)

    PF 论坛链接(未来问题):http://forum.primefaces.org/viewtopic.php?f=3&t=37851

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-02-12
      • 1970-01-01
      • 2014-08-02
      • 2017-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多