gpt4 book ai didi

jsf - JSF 中合成页面内的命令按钮

转载 作者:行者123 更新时间:2023-12-04 05:10:46 28 4
gpt4 key购买 nike

我遇到了与 user1598186 在他的问题中提到的相同的问题:p:commandButton doesn't call bean's method in an <ui:include> page

但是,没有给出解决方案(他完全删除了 <ui:include> 标签并使用变量代替)

有什么使用方法<ui:include>当我在 commandButton 中调用它时,仍然会执行我的支持 bean 的方法。

任何帮助将不胜感激。

最佳答案

EL 2.2 方法参数(因此, #{bean.method()} 而不是 #{bean.method} )可用于传递可在 actionListener 中使用的方法签名命令按钮的属性。以下是传递 ManagedBean 属性以及传递方法签名的示例:

主页

<ui:include src="/jointeam.xhtml">
<ui:param name="propertyValue" value="#{managedBean.property1} />
<ui:param name="method" value="#{managedBean.performAction()}" />
</ui:include>

jointeam.xhtml
...

<h:inputText value="#{propertyValue}" />

...

<p:commandButton value="Submit" actionListener="#{method}" />

您可以看到这在代码重用方面是多么强大,而且在许多情况下,它比复合组件更简洁、更易于使用。

关于jsf - JSF 中合成页面内的命令按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14956144/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com