0

私は JSF 1.2 を学んでおり、リクエスト Bean を使用してビュー「profile.jsf」がレンダリングされるシナリオがありますBeanProfile。Bean「BeanProfile」は、リクエストごとに更新されたデータとビューの更新が必要なため、リクエスト Bean です。ビューには<h:commandButton/>、セッション Bean のメソッドをトリガーする があり、LoginBean永続化する前にユーザー プロファイルを更新する必要があります。したがって、プロファイル ビューのすべての情報をセッション Bean のメソッドに渡す必要があります。私はこのように を使ってみ<f:attribute/>ました<h:commandButton/>:

<h:commandButton id="submit" actionListener="#{beanLogin.updateUser}" value="Update">
    <f:attribute name="ttt" value="789"/> <!-- just for debug -->
    <f:attribute name="name" value="#{name}" /> <!-- I will pass just that one for the moment -->
</h:commandButton>

およびコンポーネント:

<h:inputText id="name"
             binding="#{name}"
             value="#{beanProfile.name}"
             required="true" /> 

私の方法では:

public void updateUser(ActionEvent event) {
    /*Debug*/
    System.err.println("size: "+event.getComponent().getAttributes().size());
    System.err.println("--"+(String) event.getComponent().getAttributes()
            .get("ttt")+"--");;
    UIInput input = (UIInput) event.getComponent().getAttributes().get("name");
    String text = (String) input.getSubmittedValue();
    System.err.println("++"+text+"++");
}

その結果、次のようになります。

2014-12-20T01:43:25.850+0100|Severe: size: 1
2014-12-20T01:43:25.850+0100|Severe: --789--
java.lang.NullPointerException ...

そのため、2 つのパラメーターを渡しましたが、セッション Bean のメソッドで 1 つしか取得できず、それがjava.lang.NullPointerException. 何が間違っているのかわかりません。私は動的 Web モジュール 3.0 と Mojarra 2.2.7 を含む GlassFish Server Open Source Edition 4.1 を使用して Eclipse 4.4.1 SR1 で作業しています。

アップデート:

GlassFish と Mojarra で既に使用していた tomcat 8.0.15、MyFaces 1.2.12、および JSTL 1.2 を使用して同じコードを試しました。私は同じ問題を抱えており、Bean インジェクションは、managed-property使用した両方の構成で、faces-config.xml のどちらも機能しない (null 値) と考えていることがわかりました。

4

0 に答える 0