複合コンポーネント (jsf) への ActionListener の委任に関する具体的な質問があります。個人ユーザーデータ (属性「ユーザー」) を表示 (参照) および編集するための複合コンポーネントを作成しました。
<body>
<co:interface>
<co:attribute name="editAction" required="false" targets="edit" method-signature="java.lang.String f()"/>
<co:attribute name="saveAction" required="false" targets="save" method-signature="java.lang.String f()"/>
<co:attribute name="cancelAction" required="false" targets="cancel" method-signature="java.lang.String f()"/>
<co:attribute name="isBrowseModus" required="true"/>
<co:attribute name="user" required="true"/>
<co:attribute name="isDeveloper" required="true"/>
<co:actionSource name="edit"/>
<co:actionSource name="save"/>
<co:actionSource name="cancel"/>
</co:interface>
............
<p:inplace id="inpLand" editor="true"
toggleable="#{not cc.attrs.isBrowseModus}"
style="#{cc.attrs.isBrowseModus ? 'color: black' : 'color: blue'}">
<p:inputText value="#{cc.attrs.user.land}" label="text"/>
</p:inplace>
...........
<c:if test="#{cc.attrs.isBrowseModus}">
<h:commandButton id="edit" value="Edit"/>
</c:if>
........
実際には、この複合コンポーネントはmyData.xhtmlを呼び出すビューによって呼び出されます。
<ui:define name="center">
<h3>MyData Developer </h3>
<h4>Welcomne</h4>
<h:form id="dataForm">
<mc:UserData user="#{dataBean.user}" isDeveloper="#{dataBean.developer}" isBrowseModus="#{dataBean.browseModus}" cancelAction="#{dataBean.cancel}"
saveAction="#{dataBean.save}" editAction="#{dataBean.edit}">
<f:actionListener for="edit" binding="#{dataBean.editActionListener}"/>
</mc:UserData>
</h:form>
</ui:define>
</ui:composition>
複合コンポーネント内には (id = edit) があり、配信された actionListener (myData 内の f:actionListener を参照) をこの commandButton (id = edit) にバインドする必要があります。これは、さまざまなフォーラムの議論といくつかのドキュメントを読んだ後の私の理解です。
残念ながら、Edit-Button をクリックしても editActionListener メソッドが起動されません。その理由はわかりません。確かに、このeditActionListenerメソッドは managedBean "dataBean" (myData.java) 内に存在します。
public void editActionListener(ActionEvent ae) {
browseModus = false;
FacesContext.getCurrentInstance().renderResponse();
}
私の目的は何ですか:その複合コンポーネント内で、ユーザーは「編集」ボタンをクリックしてユーザーデータを変更できます。PRIMEFACES の inplace タグを使用することを好みます。編集ボタンをクリックすると、変更可能なすべてのフィールドが青色で表示されます。
私の質問:
- 境界付きの editActionListener メソッドが起動されない理由を誰か説明してもらえますか?
- 一般に、これは「isBrowseModus」属性を設定する正しい方法ですか (編集ボタンをクリックした後に false にします)? または、この結果を達成するためのより便利な方法はありますか?
- 私はプライムフェイスを使用しており、最初に p:commandButton を使用しようとしましたが、残念ながら機能しません。p:commandButton の使用中に、編集ボタンをクリックした後に例外が発生しました。JSF が managedBean 内で editActionListener メソッドを見つけられませんでした (PropertyNotFoundException)?!?!?
どんな助けでも感謝します。よろしくお願いします。よろしく、ボードー