gpt4 book ai didi

jsf-2 - 是否可以在复合组件内调用参数化方法签名?

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

我目前正在创建一个带有可以接受参数的方法签名的 JSF 复合组件。

这是摘录:

<composite:interface>
....
<composite:attribute name="activateHeroMethod" method-signature="java.util.List action(id.co.sofcograha.core.Dto, id.co.sofcograha.core.Dto)" />
</composite:interface>

<composite:implementation>
....
<p:commandLink value="#{hero.map['heroName']}"
process="@this"
update="#{cc.attrs.update}"
oncomplete="infoRaceDialog.hide()"
image="ui-icon ui-icon-search">
<f:setPropertyActionListener value="#{hero}"
target="#{cc.attrs.activateHeroMethod(infoRaceBean.race, hero)}" />
</p:commandLink>
....
</composite:implementation>

target="#{cc.attrs.activateHeroMethod(infoRaceBean.race, hero)}"失败并显示以下错误消息:
javax.faces.view.facelets.TagAttributeException: /resources/sofco/infoRace.xhtml @57,76 target="#{cc.attrs.activateHeroMethod(infoRaceBean.race, hero)}" /resources/sofco/infoRace.xhtml @57,76 target="#{cc.attrs.activateHeroMethod(infoRaceBean.race, hero)}" Illegal attempt to pass arguments to a composite component lookup expression (i.e. cc.attrs.[identifier]).
at com.sun.faces.facelets.tag.TagAttributeImpl.getValueExpression(TagAttributeImpl.java:401)
at com.sun.faces.facelets.tag.TagAttributeImpl.getValueExpression(TagAttributeImpl.java:351)
at com.sun.faces.facelets.tag.jsf.core.SetPropertyActionListenerHandler.applyAttachedObject(SetPropertyActionListenerHandler.java:128)
at com.sun.faces.facelets.tag.jsf.core.SetPropertyActionListenerHandler.apply(SetPropertyActionListenerHandler.java:101)

是否可以从复合组件的属性调用参数化方法?
我认为我可以处理多个作为在一种方法中使用多个参数的解决方法,但我不喜欢这种方法,因为它会随着参数的增加而增长。

我可以将每个参数包装到 1 个包装器对象中,但我仍然很好奇是否有办法解决使用多个参数调用方法的问题。

请分享您的想法!

谢谢你。

最佳答案

是的,可以这样做,这样做:

<composite:interface displayName="Image uploader with preview list">
<composite:attribute name="backingBean" required="true" />
<composite:attribute name="imageType" required="true" />
</composite:interface>
....
<p:commandButton value="Save" actionListener="#{cc.attrs.backingBean.imageUploaded(cc.attrs.imageType)}"/>

希望这对一些 body 有帮助。

关于jsf-2 - 是否可以在复合组件内调用参数化方法签名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6605695/

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