カスタム JSF コンポーネントを作成し、それにメソッド式を追加しようとしています。これは私のカスタム コンポーネントのコードです。
@FacesComponent(AjaxCommand2.COMPONENT_TYPE)
public class AjaxCommand2 extends UIComponentBase {
public static final String COMPONENT_TYPE = "local.test.component.AjaxCommand2";
public static final String COMPONENT_FAMILY = "local.test.component.AjaxCommand2";
private MethodExpression listener;
public MethodExpression getListener() {
return listener;
}
public void setListener(MethodExpression listener) {
this.listener = listener;
}
@Override
public String getRendererType() {
return null;
}
@Override
public String getFamily() {
return COMPONENT_FAMILY;
}
}
これは私のタグ lib ファイルです。
<?xml version="1.0" encoding="UTF-8"?>
<facelet-taglib id="test"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd" version="2.0">
<namespace>http://local.test/ui</namespace>
<tag>
<tag-name>ajaxCommand2</tag-name>
<component>
<component-type>local.test.component.AjaxCommand2</component-type>
</component>
<attribute>
<name>listener</name>
<required>false</required>
<type>javax.el.MethodExpression</type>
</attribute>
</tag>
</facelet-taglib>
そして、これは JSF ページの関連コードです。
<test:ajaxCommand2 listener="#{testSessionBean.testActionAjax}" />
私の問題は、カスタム コンポーネントでリスナーのセッターが呼び出されず、常にリスナー プロパティで null を取得していることです。
どこに問題があるのか わかりません。アイデアはありますか?リスナー プロパティを、1 つのバッキング Bean の特定のメソッドを指すように設定したいと思います。