更新时间:2022-05-27 18:12:27
作为一种变通办法,我重新编写了该组件,以将动作bean和动作方法作为两个单独的参数来解决,如下所示
As a work-around I rewrote the component to give action bean and action method as two separate parameters resolving them as following
xhtml:
<io:removeButton
id="removeButton"
actionBean="#{createAction}"
actionMethod="removeRating"
immediate="true"
render=":#{rich:clientId('ratingTblId')}" />
复合成分:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:cc="http://java.sun.com/jsf/composite">
<!-- INTERFACE -->
<cc:interface>
<cc:attribute name="actionBean" />
<cc:attribute name="actionMethod" />
<cc:attribute name="render" required="false" />
</cc:interface>
<!-- IMPLEMENTATION -->
<cc:implementation>
<h:commandButton
id="remove"
action="#{cc.attrs.actionBean[cc.attrs.actionMethod]}"
onclick="if (!confirm('Do you really?')) { return false; }">
<f:ajax execute="@this" render="#{cc.attrs.render}" />
</h:commandButton>
</cc:implementation>
</ui:composition>
还更改了操作方法签名以返回String
而不是void
.那看起来不再那么性感了,但是行得通. :-/
also changing the action methods signature to return String
instead of void
. That does not look that super sexy anymore, but works. :-/