Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to re-initialize bean from JSF??

rashmi prakash
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am using JSF in my web project.

I have a MyBean class, where I am initiazing the bean with some hardcoded values of some products.
In my webpage, I display these products and I have a "details" command button for each displayed product/

When I click on this,
I want to navigate to some details page.
For this, I want to catch the instance on which the button was clicked using "setPropertyActionListerner"

And in MyBean class, I just return the navigation.
In my webpage2, I can see the correct instance(which ever I clicked on)

Problem is:
The bean is session scoped.
When I am in webpage2…and I click 'back' and click on details button of some other product
Again I get the same instance.

Is there a way I can re-initialize my bean now??
i) I used this approach, but it doesn’t work

MyBean myBeanObject = new MyBean();
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("myNewBean", myBeanObject )

How do I re-initialize my bean now?

Thanks for the help.
Regards, Rashmi
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic