2

私は単純な複合コンポーネントを持っていますbutton.xhtml:

<composite:interface>
    <composite:attribute name="action" method-signature="void listener(java.lang.String)"/>
</composite:interface>

<composite:implementation>
    <h:form>
        <h:commandButton value="button" action="#{cc.attrs.action}"/>
    </h:form>
</composite:implementation>

details.xhtml次のページで使用されます。

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:comp="http://java.sun.com/jsf/composite/comp">
    <comp:button action="#{actionBeanParam.doAction('someParam')}"/>
</ui:composition>

details.xhtmlページが別のページに含まれています。に注意してactionBeanParamください。にパラメータとして渡されますdetails.xhtml。ページには 2 つのボタンが表示されます (テスト用)。最初のボタンは、複合コンポーネントが機能することを確認するためのものです。2番目のボタンは、私が達成したいものです:

<h:body>
    <comp:button action="#{actionBean.doAction('simpleButton')}"/>
    <ui:include src="/WEB-INF/blocks/details.xhtml">
        <ui:param name="actionBeanParam" value="#{actionBean}"/>
    </ui:include>
</h:body>

そして最後にバッキングビーン:

@Named
@SessionScoped
public class ActionBean implements Serializable {
    public void doAction(String param) {
        System.out.println("Param: " + param);
        // some action
    }
}

トップボタンを押すと正常に動作します。コンソールに次のように表示されます。

パラメータ: シンプルボタン

下のボタンを押すと(私のシナリオ)、例外がスローされます:

javax.el.PropertyNotFoundException: JBWEB006016: ターゲット到達不能、識別子 ''actionBeanParam'' が null に解決されました: javax.faces.el.E​​valuationException: javax.el.PropertyNotFoundException: JBWEB006016: ターゲット到達不能、識別子 ''actionBeanParam'' が null に解決されました

私はここで同様の問題を見つけました: Facelet パラメーターとしての Managed Bean により、複合コンポーネントの解決が防止されます

しかし、アクションにパラメーターがあるため、この問題の回避策を使用できません。

c:setinを介してパラメーターを再設定する回避策がありますdetails.xhtml

<c:set var="actionBeanParam" scope="view" value="#{actionBeanParam}" />

details.xhtmlが複数回含まれていると正しく動作しません。

私が使用しているもの: JBoss EAP 6.2.1、Mojarra 2.1.19-jbossorg-1

助言がありますか?

4

0 に答える 0