I'm interested What is the proper way to use JSF pages with AJAX when I use CDI.
I tested to configure the CDI beans with @SessionScoped
but I found that there is a problem with AJAX.
Is it proper to use AJAX with CDI beans configured with @ConversationScoped
?
And I found that I have to put conversation.begin();
into the Bean constructor and conversation.end();
into Java method which must be when the session is completed. Can I somehow do this automatically?
P.S Can I use this code to automatically free the resource when the user closes the page?
@Remove
public void finishIt(){
conversation.end();
}