-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<f:view transient="true" /> + org.omnifaces.cdi.ViewScoped instantiating the bean twice #463
Comments
Cannot reproduce this. Curiously in your case the request scoped bean is also instantiated twice. I strongly suspect classpath pollution with multiple Mojarra libraries. Did you use WildFly-provided Mojarra, or did you install another one via the webapp? |
Actually using Mojarra library from server.
Testing with:
Beans instantiated once. Testing with:
Beans instantiated once. Testing with:
Beans instantiated once. Testing with:
Beans instantiated once. Testing with:
Beans instantiated once. Testing with:
Beans instantiated twice. Testing with:
Beans instantiated twice. Testing with:
Beans instantiated twice. |
I think I see what you're getting at. On initial page load, the bean is instantiated only once. But when you reload the page, the beans are indeed instantiated twice. First one for the unload of the previous page and second one for the refreshed page. This is caused by the unload feature which is indeed basically useless when the view is stateless. |
Fixed in 2.7-SNAPSHOT and 3.2-SNAPSHOT. It will now skip registering the unload script and instead log a warning. |
Problem:
When using
<f:view transient="true" />
with one or more beans annotated asorg.omnifaces.cdi.ViewScoped
all beans in the current view are getting instantiated twice.Environment:
WildFly 11.0.0.Final
JSF Mojarra 2.3.3
OmniFaces 3.1
Steps to reproduce:
Page:
test.xhtml
CDI Beans:
ApplicationBean.java
UtilityBean.java
Output:
17:29:34,541 INFO [stdout] (default task-117) AppBean: coreBeans.ApplicationBean@26d14bec
17:29:34,553 INFO [stdout] (default task-117) UtilityBean: utilities.UtilityBean@229f918c
17:29:34,594 INFO [stdout] (default task-119) AppBean: coreBeans.ApplicationBean@750bc969
17:29:34,599 INFO [stdout] (default task-119) UtilityBean: utilities.UtilityBean@714550db
Capture:
Beans don't get instantiated twice when:
We use
<f:view transient="false" />
We use
javax.faces.view.ViewScoped
instead oforg.omnifaces.cdi.ViewScoped
We don't use
<h:form />
Additional notes:
We already know that
ViewScoped
's concept is not valid when using<f:view transient="true" />
, but it shouldn't instantiate twice those beans.The text was updated successfully, but these errors were encountered: