I created a wizard (p:wizard) where a user can define his profile. In one of the wizard's tabs, the user can upload his profile photo. The photo will be rendered in the final wizard step. So, my question is, what Scope should I use? I tried View, but p:graphicImage with dynamic image doesn't work with View scope (will throw npe, because two requests are made when rendering the image). I tried Request, but in the wizard when you click next/back, a new request is made, and all my previous entered data is lost (bean is reinitialized). Finally, I`ve put Session scope, and it works. I'm not a big fan of Session scope, because the bean remains in scope untill the session is invalidated/expires. What would be the correct aproach? Invalidate the bean?
FacesContext context = FacesContext.getCurrentInstance();
context.getExternalContext().getSessionMap.put("#{MySessionBean}", null);
Is it "ethically" correct to "destroy" a session bean? Should I create a reset() method wich makes all his attributes null? (Bean will still remain in session).