我目前正在创建一个带有可以接受参数的方法签名的 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 个包装器对象中,但我仍然很好奇是否有办法解决使用多个参数调用方法的问题。
请分享你的想法!
谢谢你。