This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Application Scoped Data Updating  RSS feed

 
nikos karanikos
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I have an application scoped and i want to edit it from request scoped data. I use this code but application scoped data are not updating. What i am doing wrong?

Application Scoped Data



Request Scoped Data



Thank you a lot
 
Tim Holloway
Bartender
Posts: 18709
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's because you're instantiating a new ApplicationData in your request object. You want to use the existing ApplicationData instance.

That's easy in JSF. Since Application Scope is longer-lived than Request scope, you can simply inject the application scope object instance ("applicationData") as a Managed Property into your EditingClass instance.

Of course, since Application Scope is shared between all users of the application, you should also ensure that any updating you do to the applicationData object are done in a thread-safe manner (synchronized).

And be very careful about using Request Scope. Request Scope is almost, but not quite 100% useless in JSF.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!