public class GuiceResolver extends ManagedBeanResolver
Register this ELResolver in faces-config.xml.
 <application> 
 <el-resolver>org.apache.myfaces.el.unified.resolver.GuiceResolver</el-resolver>
 </application>
 
 Implement and configure a ServletContextListener in web.xml .
 <listener> 
 <listener-class>com.your_company.GuiceServletContextListener</listener-class> 
 </listener>
 
 Configure Guice in your ServletContextListener implementation, and place the Injector in application scope.
 public class GuiceServletContextListener implements ServletContextListener {
 
 public void contextInitialized(ServletContextEvent event) { ServletContext ctx = event.getServletContext(); //when on
 Java6, use ServiceLoader.load(com.google.inject.Module.class); Injector injector = Guice.createInjector(new
 YourModule()); ctx.setAttribute(GuiceResolver.KEY, injector); }
 
 public void contextDestroyed(ServletContextEvent event) { ServletContext ctx = event.getServletContext();
 ctx.removeAttribute(GuiceResolver.KEY); }
 
 }
 | Modifier and Type | Field and Description | 
|---|---|
| static String | KEY | 
_scopes, STANDARD_SCOPES| Constructor and Description | 
|---|
| GuiceResolver() | 
| Modifier and Type | Method and Description | 
|---|---|
| Object | getValue(jakarta.el.ELContext ctx,
        Object base,
        Object property) | 
getCommonPropertyType, getFeatureDescriptors, getType, isReadOnly, runtimeConfig, setValuepublic static final String KEY
public Object getValue(jakarta.el.ELContext ctx, Object base, Object property) throws NullPointerException, jakarta.el.PropertyNotFoundException, jakarta.el.ELException
getValue in class ManagedBeanResolverNullPointerExceptionjakarta.el.PropertyNotFoundExceptionjakarta.el.ELExceptionCopyright © 2021 The Apache Software Foundation. All rights reserved.