myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "l.penet@senat.fr" <l.pe...@senat.fr>
Subject Re: @FlowScoped, @Named and @ManagedBean
Date Tue, 11 Feb 2014 09:28:55 GMT
On 11/02/2014 03:30, Leonardo Uribe wrote:
> Hi
Thank you for your quick reply.
2014-02-10 11:56 GMT-05:00 l.penet@senat.fr <l.penet@senat.fr>:
>> Dear all,
>>
>> I am starting to really use JSF 2.2. I am trying to use Faces Flows. I am
>> starting with a very simple flow, whose name is "flow1".
>>
>> So, under src/main/webapp, I have a flow1 directory containing
>>
>> flow1-flow.xml
>> flow1.xhtml
>> flow1b.xhtml
>>
>> flow1-flow.xml contains :
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <faces-config
>>      xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
>>      xmlns='http://xmlns.jcp.org/xml/ns/javaee'
>>      xsi:schemaLocation='http://xmlns.jcp.org/xml/ns/javaee
>> http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd'
>>      version='2.2' >
>>      <flow-definition id="flow1">
>>          <flow-return id="returnFromFlow1">
>>              <from-outcome>/accueil</from-outcome>
>>          </flow-return>
>>      </flow-definition>
>> </faces-config>
>>
>>
>> With such a simple config, using conventions would be a better choice than
>> configuration, but I plan to add more things to it... :-)
>>
>> I use a @FlowScoped bean declared this way :
>>
>> @Named
>> @FlowScoped("flow1")
>> public class MinintFileContext implements Serializable {
>>
>>      ....
>> }
>>
>> and it does not work. I have the following exception :
>>
>> javax.servlet.ServletException: javax.servlet.ServletException:
>> javax.el.ELException: javax.enterprise.context.ContextNotActiveException:
>> WebBeans context with scope type annotation @FlowScoped does not exist
>> within current thread
>>
>>
>> To make it work, I have to use @ManagedBean instead of @Named.
>>
>> My first question is : I do not understand why... In my (obviously wrong)
>> understanding, @Named was a super-set of CDI-managed beans, including
>> @ManagedBean-s.
>>
>
> @FlowScoped annotation is for CDI only, so it will not work for JSF
> managed beans. In your case, I believe the bean is instantiated but it
> is not stored in any context, so once is created is discarded, giving
> the impression that the bean is working but it is not.
>
> In MyFaces it is possible to create a custom flow scope annotation for
> other containers that works just like @FlowScoped, implementing
> org.apache.myfaces.spi.FacesFlowProvider SPI interface. You are
> already in CDI, so you don't need to bother about that.
>
> I have seen @Named annotation working with Spring, so it is not
> something specific for CDI, but @FlowScoped depends of CDI API.
I am using CODI 1.0.5 (I heavily use its @ViewAccessScoped annotation) 
with OpenWebBeans 1.2.1.

So, I thought  was ok on the CDI side...

...but after reading your mail, it seems to me that this CDI 
implementation was provided before JSF 2.2 release, and so that it must 
not include proper @FacesFlow support.

Should I switch to another implementation, like DeltaSpike ?

I must have misunderstood your mail from Sep 26 2013 ( 
http://myfaces.10567.n7.nabble.com/JSF-2-2-status-amp-snapshot-usage-td115852.html 
) inviting us to try Faces Flows in MyFaces 2.2.

Thanks again,

Ludovic

|
| AVANT D'IMPRIMER, PENSEZ A L'ENVIRONNEMENT.
|

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message