I am a little confused about which scope to use on my stateful backing bean, I currently have a bean that delivers users results into an xhtml page via JSF, the bean uses the default (conversation scope), with the @Create method marked as @Begin(join=true)....this should make the bean to join the currently long-running conversation, right?
But what I am finding is that when the user navigates to a different page, then back again, the @Create method is being called again on the backing bean, which I want to avoid
The only way around this I have found is to mark the bean as @Scope(ScopeType.SESSION) which maintains the bean for the life of the user login session (as expected).
But having read a few times in the SEAM documentation that it is bad practice to use session scoped backing beans in this way...my questions is, how do I stop the conversational scoped bean from reseting each time the page is reloaded...I feel like I am missing something fundamental about the conversation scope??! Can someone enlighten me please
I have included an edited version of the bean in question below...
@Stateful
@Scope(ScopeType.CONVERSATION)
@Name("sessionActions")
@Restrict("#{identity.isLoggedIn()}")
public class SessionActionsBean implements SessionActions, Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Logger private Log log;
@RequestParameter private String sId;
@In Redirect redirect;
@In private MessagePoster messagePoster;
@In private Map<String, String> messages;
@Create
@Begin(join=true)
@Override
public void create(){
log.debug("bean is being created")
}
//--------------------------- Cleanup methods
@Remove
@BypassInterceptors
@Override
public void cleanUp(){}
}