gpt4 book ai didi

jsf - Parent is not of type ActionSource, 类型是 : com. sun.faces.component.PassthroughElement

转载 作者:行者123 更新时间:2023-12-04 15:47:17 25 4
gpt4 key购买 nike

我在我的 JSF 项目中使用 Passthrough 元素,需要做类似的事情:

<h:commandLink action="#{myBean.acao()}" value="click me">
<f:setPropertyActionListener target="#{myBean.object}" value="#{localObject}"/>
</h:commandLink>

但是使用 Passthrough 元素可以更好地控制我的前端,如下所示:
<a href="#" jsf:action="#{myBean.acao()}">click me
<f:setPropertyActionListener target="#{myBean.object}" value="#{localObject}"/>
</a>

但显然这不起作用,我收到以下错误消息:
<f:setPropertyActionListener> Parent is not of type ActionSource, type is: com.sun.faces.component.PassthroughElement

有谁知道我该如何解决这个问题?

最佳答案

看起来只是您的 Mojarra 版本中的一个错误。它适用于当前最新的 2.2.12 版本。

您可以通过使用传递方法参数的 EL 2.2 特性来解决它。另见 Invoke direct methods or methods with arguments / variables / parameters in EL .它肯定在您的环境中可用,如 #{myBean.acao()}显然没有抛出 EL 异常(EL 2.2 之前不支持此语法)。

<a href="#" jsf:action="#{myBean.acao(localObject)}">click me</a>

如果您绝对需要在 Action 监听器事件期间调用 setter,例如因为你想控制 action 的调用通过 throw AbortProcessingException如果设置值无效,另见 Differences between action and actionListener ,然后声明一个 jsf:actionListener .
<a href="#" jsf:actionListener="#{myBean.setObject(localObject)}" jsf:action="#{myBean.acao}">click me</a>

关于jsf - <f :setPropertyActionListener> Parent is not of type ActionSource, 类型是 : com. sun.faces.component.PassthroughElement,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34275813/

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