【问题标题】:Can't change button href dynamically in primefaces无法在primefaces中动态更改按钮href
【发布时间】:2022-01-22 21:59:58
【问题描述】:

我试图在单击按钮时访问控制器。事实是,我需要动态更改按钮的 url。

<p:button styleClass="btn-openHtml" href="#{data.htmlRenderUrl}" value="button html" target="_blank"></p:button>

当我的 bean 的属性更改时,href 属性不会更新。当 data.htmlRenderUrl 更改时,我怎样才能更新 href 的值?

【问题讨论】:

标签: jsf primefaces


【解决方案1】:

您必须使用 ajax 更新按钮。 当您更新 bean 中的属性时:

...
htmlRenderUrl = "/home";
//update your button
PrimeFaces.current().ajax().update("button-id");
...

【讨论】:

    猜你喜欢
    • 2015-08-23
    • 2020-02-28
    • 1970-01-01
    • 2013-06-17
    • 2017-05-10
    • 2014-12-21
    • 1970-01-01
    • 2017-12-26
    • 2020-07-25
    相关资源
    最近更新 更多