0

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).

snooperman
  • 13
  • 5
  • @Oskars Pakers I know p:wizard work with ViewScope, the reason I can't use it, is because I have a which is dinamicaly rendered. – snooperman Apr 01 '14 at 13:54

1 Answers1

0

Regarding primefaces wizard component:

As primefaces wizard component is in a single view you can use ViewScoped manage bean to store information.

Regarding session scope

Here and here are good threads about session scope bean destruction. In brief: In properly designed web applications, there should never be the need to manually terminate a scope.

Community
  • 1
  • 1
Oskars Pakers
  • 699
  • 3
  • 11