CDI missing @ViewScoped and @FlashScoped

前端 未结 2 633
谎友^
谎友^ 2020-12-06 13:33

Why is Java EE 6 CDI missing the @ViewScoped and @FlashScoped annotations? (especially the former makes me wonder, because CDI stems from the Seam world, which already knew

2条回答
  •  萌比男神i
    2020-12-06 14:12

    You can implement the context and use the @NormalScope to create your own CDI Scope witout using any other framework or waiting for the new JEE7

    • CDI fires an event AfterBeanDiscovery after each bean call
    • You can use CDI extension to @Observes this event and add your context implementation
    • In your scope implementation you can :
      1. Use Contextual to get your bean by its name from FacesContext ViewRoot Map and return it after each ajax call back
      2. Use CreationalContext if the bean name from first step is not found to create it in the FacesContext ViewRoot Map

    for a more in-depth explanation i recommand this link : http://www.verborgh.be/articles/2010/01/06/porting-the-viewscoped-jsf-annotation-to-cdi/

提交回复
热议问题