Bootsfaces按钮,如何执行actionListener

Bootsfaces button, how to perform actionListener

我需要使用按钮来调用托管 Bean 的方法,但它没有任何 ActionListener。我有这样的东西:

<b:button value="Tes1"  look="warning"size="lg"/>

我无法使用 commandButton。有什么办法吗? 谢谢!

在问题和尝试的解决方案中,确实是从错误的方式接近它。一个 b:commandButton 可以按以下方式使用:

<b:commandButton value="Trigger (JSF passthrough)2" actionListener="#{managedBeanName.performCall}" immediate="true" update="@(#id_element)"/>

此解决方案的关键是 immediate=true 进行验证和 update="@(#id_element)" 仅更新屏幕的一部分。您也可以使用 update="@none" 不更新屏幕。

它需要在一个表单中。

另一种选择是使用 process="@this" 而不是 immediate=true。这样,它不会执行任何验证,因为它不会从表单提交任何输入。

<b:commandButton value="Trigger (JSF passthrough)2" actionListener="#{managedBeanName.performCall}" process="@this" update="@(#id_element)"/>

自从在 JSF 中引入 'ajax' 后,后一种解决方案更为常用。

另请参阅:

  • Should immediate="true" never be used when dealing with an AJAXified JSF 2.0 component?