我想编写一个或多或少的 gemeric 组件,我在其中提交一个控制器 bean,并且组件应该显示一些 CRUD 按钮。
以下复合组件:
<composite:interface>
<composite:attribute name="controller" />
<composite:attribute name="object" />
</composite:interface>
<composite:implementation>
<h:panelGrid columns="3" columnClasses="celltop">
<h:commandButton id="save" value="#{msg.saveButtonLabel}"
action="#{cc.attrs.controller.save}" />
<h:commandButton id="delete" value="#{msg.deleteButtonLabel}"
action="#{cc.attrs.controller.delete(cc.attrs.object)}" />
<h:commandButton id="cancel" value="#{msg.backButtonLabel}"
action="#{cc.attrs.controller.cancel}" immediate="true" />
</h:panelGrid>
</composite:implementation>
<viewController:buttons controller="customerController" object="#{customerController.customer}"/>
@Named
@ConversationScoped
public class CustomerController implements Serializable {
public String cancel() {
customer = null;
if (!conversation.isTransient()) {
conversation.end();
}
return "cancelled";
}
当我单击取消按钮时导致以下异常:
javax.faces.el.MethodNotFoundException: javax.el.MethodNotFoundException: /resources/components/viewController/buttons.xhtml @25,65 action="#{cc.attrs.controller.cancel}": Method not found: customerController.cancel()
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:92)
不能在给 CC 的 bean 上调用方法吗?