Permalink
Browse files

Add @Eager support for Add JSF 2.2 javax.faces.view.ViewScoped.

  • Loading branch information...
1 parent 94709a6 commit 09f187dd7c96f9b4cd08ecadaf6395bf96a4bea0 @BalusC BalusC committed Jan 2, 2015
@@ -56,6 +56,7 @@
* Currently supported scopes:
* <ol>
* <li> CDI {@link RequestScoped}
+ * <li> CDI {@link javax.faces.view.ViewScoped}
* <li> OmniFaces {@link ViewScoped}
* <li> CDI {@link SessionScoped}
* <li> CDI {@link ApplicationScoped}
@@ -170,15 +171,15 @@
* JSF services will not be available (yet) when the bean is instantiated this way.
* <p>
* If both this attribute and {@link Eager#viewId()} is specified, this attribute takes precedence for {@link RequestScoped}.
- * This attribute <b>can not</b> be used for {@link ViewScoped} beans.
+ * This attribute <b>can not</b> be used for <code>ViewScoped</code> beans.
*
* @return The request URI relative to the context root.
*/
@Nonbinding
String requestURI() default "";
/**
- * (Required when combined with {@link RequestScoped} or {@link ViewScoped}) The id of the view for which a request or view scoped bean
+ * (Required when combined with {@link RequestScoped} or <code>ViewScoped</code>) The id of the view for which a request or view scoped bean
* should be instantiated. When this attribute is specified the bean will be instantiated during invocation of the
* {@link FacesServlet}, namely right after the RESTORE_VIEW phase (see {@link PhaseId#RESTORE_VIEW}).
*
@@ -187,7 +188,7 @@
*
* <p>
* If both this attribute and {@link Eager#requestURI()} is specified and the scope is {@link RequestScoped}, the
- * <code>requestURI</code> attribute takes precedence. If the scope is {@link ViewScoped} <code>requestURI</code> is ignored and only
+ * <code>requestURI</code> attribute takes precedence. If the scope is <code>ViewScoped</code> <code>requestURI</code> is ignored and only
* this attribute is considered.
*
* @return The view ID.
@@ -38,9 +38,9 @@
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.Extension;
import javax.enterprise.inject.spi.ProcessBean;
+import javax.faces.view.ViewScoped;
import org.omnifaces.cdi.Eager;
-import org.omnifaces.cdi.ViewScoped;
/**
* CDI extension that collects beans annotated with {@link Eager}. After deployment
@@ -91,7 +91,6 @@
} else if (getAnnotation(beanManager, annotated, SessionScoped.class) != null) {
sessionScopedBeans.add(bean);
} else if (getAnnotation(beanManager, annotated, RequestScoped.class) != null) {
-
if (!isEmpty(eager.requestURI())) {
getRequestScopedBeansByRequestURI(eager.requestURI()).add(bean);
} else if (!isEmpty(eager.viewId())) {
@@ -105,6 +104,12 @@
} else {
logger.severe(format(MISSING_VIEW_ID, bean.getBeanClass().getName(), ViewScoped.class.getName()));
}
+ } else if (getAnnotation(beanManager, annotated, org.omnifaces.cdi.ViewScoped.class) != null) {
+ if (!isEmpty(eager.viewId())) {
+ getRequestScopedBeansByViewId(eager.viewId()).add(bean);
+ } else {
+ logger.severe(format(MISSING_VIEW_ID, bean.getBeanClass().getName(), org.omnifaces.cdi.ViewScoped.class.getName()));
+ }
}
}
}

0 comments on commit 09f187d

Please sign in to comment.