【问题标题】:Reevaluate onComplete JSF - primefaces重新评估 onComplete JSF - primefaces
【发布时间】:2016-04-19 16:44:55
【问题描述】:

我正在尝试通过单击 primefaces 命令链接来更新窗口的内容:

<p:commandLink oncomplete="if( #{documentController.documentAlreadyOpenedInExternalWindow} ) window.open('previewDocument.xhtml?documentId=#{documentController.documentId(task)}', 'new');"

但条件检查似乎永远不会被再次测试?

<p:commandLink oncomplete="if( true ) window.open('previewDocument.xhtml?documentId=#{documentController.documentId(task)}', 'new');"

上面的语句当然会在每次点击时打开窗口..

我该如何解决这个问题?

Primefaces 5.2

【问题讨论】:

  • 通过更新 commandLink 本身...
  • @Kukeltje 试过了,但似乎没有用。
  • “似乎没有工作”...会发生什么?响应是什么样的?你到底做了什么?
  • @Kukeltje 我已经修复了它,我将在今天晚些时候发布解决方案。但是发生了什么:我只想“更新”(打开)已经打开的屏幕(参见布尔条件)。即使在后端为 true,该布尔值也从未变为 true,因为链接没有更新,因为初始打开发生在 target="new" 的 ajax=false commandLink 中。正如我所说,我将在今天晚些时候发布我的解决方案。

标签: jsf primefaces


【解决方案1】:

我理解的问题是你正在尝试更新窗口的内容,如果它已经打开,否则打开新窗口你可以使用条件运算符,如果你的字段 documentAlreadyOpenedInExternalWindowis 是布尔值,那么你可以像这样使用

    <p:commandLink oncomplete="
        #{documentController.documentAlreadyOpenedInExternalWindow?alert('succeed');
    :window.open('previewDocument.xhtml?documentId=#{documentController.documentId(task)}', 'new')" 
update="yourElement/Form ID"/>

【讨论】:

  • 这就是我的问题中的内容并且不起作用。 onComplete 在我的页面呈现时被评估,而不是在操作完成后。
  • 控制器是否在视图范围内?并且您打开的页面和您打开的页面指的是同一个控制器以及这些控制器的范围是什么尝试在字段的构造函数和设置器中放置一个调试点我认为您的字段正在重新初始化导航到其他窗口或单击单击时documentAlreadyOpenedInExternalWindow 的值是什么。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-02-20
  • 2013-04-23
  • 1970-01-01
  • 1970-01-01
  • 2020-08-19
  • 1970-01-01
  • 2019-06-23
相关资源
最近更新 更多