Wednesday, May 15, 2013

JSF2.2 ViewScope Using CDI

JSF 2.0 introduced annotation @ViewScoped; A bean annotated with this scope maintained its state as long as the user stays on the same view(reloads or navigation - no intervening views).

One problem with the @ViewScoped is that it doesn't work with CDI (@Named); so one had to annotate bean as @ManagedBean to be ViewScoped.

JSF2.2 has introduced a NEW annotation @ViewScoped in javax.faces.view.ViewScoped (NOT reusing the existing javax.faces.bean.ViewScoped) which is CDI compatible.

Here is a working sample using Glassfish B4 v72.

Click here to download source code




Prasanna Bhale


6 comments:

  1. Nice Article. We are authorised support partner in Quickbooks Payroll. If you required any help for Quickbooks Payroll Support Phone Number 1-800-986-4607 if you are Expand your business to a new hike, with progressive approach. Seeking for the best accounting software? Then, get quickbooks installed in your system. The software proves to be more profitable to the business

    ReplyDelete
  2. Need any assistance or facing any issue while using QuickBooks? Don’t hesitate to call us, on Quickbooks Tech Support Phone Number 1800-986-4591.

    ReplyDelete
  3. We have a panel of QuickBooks Proadvisor Support Phone Number experts who can help you to solve your QuickBooks related issues. The solutions we deliver will take only few seconds of you. We have the availability 365 days a year and 24 hours a day!

    ReplyDelete
  4. These are genuinely fantastic ideas about blogging really. You have touched some very nice points here. Please keep up this good writing.

    ReplyDelete