This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Refresh data in JSF page

 
Minh Phuc
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 pages. The page 1 will transfer some data into page 2 so i have to use session scoped for bean in page 1. In page 2, i have to change some data which will influence data in page 1. But i go back page 1, the data is still not change. If i use View scope in page 1 i cannot transfer into page 2. Please help me do!
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18027
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Minh!

SInce bean1 seems to be the base bean for this workflow and bean2 is a modifier of it, the easiest way to handle that is to inject bean1 into bean2 and let the bean2 page do what it needs, passing the results back to the injected bean1. In a case like that, putting bean2 in View scope should work, and probably you'll want a @PostConstruct method to pre-configure bean2 based on bean1's properties. For older systems where @PostConstruct didn't work, we had to kind of hack things, since there was no clear method call for the time where the managed properties were all set but nothing was yet being fetched for display.

In some cases, you need a more permanent connection running both ways. In that case, make both beans be session scoped, inject bean2 into bean1 and code the bean2 to set itself into the bean1 using a "setBean2" method that you add to bean1. You would probably do this in the bean2 "setBean1 method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic