ber*_*tie 5 composite-component jsf-2
我目前正在创建一个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>
Run Code Online (Sandbox Code Playgroud)
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)
Run Code Online (Sandbox Code Playgroud)
是否可以从复合组件的属性中调用参数化方法?我认为我可以处理多个作为在一个方法中使用多个参数的解决方法,但我不喜欢这种方法,因为它会随着参数的增加而变大.
我可以将每个参数包装成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)}"/>
Run Code Online (Sandbox Code Playgroud)
希望这有助于一些身体.
归档时间: |
|
查看次数: |
6518 次 |
最近记录: |