JBoss AS 7 で、JSF 2.0 アプリケーション内で、CDI の実装 Weld を使用しようとしています。
実際には、@ConversationSconed @Named Bean は、会話を開始したときに状態を維持していないようです。
それを確認するために、Primefaces と ajax を使用して、コマンド ボタンをクリックするたびにインクリメントするカウンターを使用しています。
beans.xml はクラスパス (META-INF、WEB-INF ...) に存在し、@SessionScoped Bean または @ManagedBean @ViewScoped で正確に動作するようにしたいだけです。
しかし、@ManagedBean を使用するよりも、@ConversationScoped を使用して @Named Bean を使用することを好みます。
JBoss AS 7 または web.xml で追加の設定を行う必要があるかもしれませんが、わかりません...
これが私の @ConversationScoped Bean です:
@Named
@ConversationScoped
public class ConversationTest implements Serializable {
private int counter;
@Inject
private Conversation conversation;
public void startConversation() {
System.out.println(counter);
counter++;
if(conversation.isTransient())
conversation.begin();
}
public void stopConversation() {
if (!conversation.isTransient())
conversation.end();
}
public int getCounter() {
return counter;
}
public void setCounter(int counter) {
this.counter = counter;
}
}
そして、ここに私のxhtmlページのコンテンツがあります:
<h:form prependId="false">
<h:panelGroup id="tests">
<h:outputText value="#{conversationTest.counter}" /> <br/>
<h:outputText value="Test : #{conversationTest.testHello}" /> <br/><br/>
</h:panelGroup>
<p:commandButton
value="Start !"
actionListener="#{conversationTest.startConversation}"
update="tests" />
<br/>
<p:commandButton
value="Stop !"
actionListener="#{conversationTest.stopConversation}"
update="tests" />
</h:form>
私は何を間違っていますか?私は何かを忘れていますか?
ご回答ありがとうございます。