use of org.apache.myfaces.webapp.MyFacesContainerInitializer in project org.openntf.xsp.jakartaee by OpenNTF.
the class NSFJsfServlet method doInit.
public void doInit(HttpServletRequest req, ServletConfig config) throws ServletException {
try {
CDI<Object> cdi = ContainerUtil.getContainer(NotesContext.getCurrent().getNotesDatabase());
ServletContext context = config.getServletContext();
// $NON-NLS-1$
context.setAttribute("jakarta.enterprise.inject.spi.BeanManager", ContainerUtil.getBeanManager(cdi));
// TODO investigate why partial state saving doesn't work with a basic form
// $NON-NLS-1$ //$NON-NLS-2$
context.setInitParameter("jakarta.faces.PARTIAL_STATE_SAVING", "false");
Properties props = LibraryUtil.getXspProperties(module);
// $NON-NLS-1$
String projectStage = props.getProperty(ProjectStage.PROJECT_STAGE_PARAM_NAME, "");
context.setInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME, projectStage);
Bundle b = FrameworkUtil.getBundle(FacesServlet.class);
{
ServletContainerInitializer initializer = new MyFacesContainerInitializer();
Set<Class<?>> classes = null;
HandlesTypes types = initializer.getClass().getAnnotation(HandlesTypes.class);
if (types != null) {
classes = buildMatchingClasses(types, b);
}
initializer.onStartup(classes, getServletContext());
}
{
// Re-wrap the ServletContext to provide the context path
javax.servlet.ServletContext oldCtx = ServletUtil.newToOld(getServletContext());
ServletContext ctx = ServletUtil.oldToNew(req.getContextPath(), oldCtx, 5, 0);
ctx.addListener(StartupServletContextListener.class);
ServletUtil.getListeners(ctx, ServletContextListener.class).forEach(l -> l.contextInitialized(new ServletContextEvent(ctx)));
}
this.delegate = new FacesServlet();
delegate.init(config);
} catch (NotesAPIException e) {
throw new ServletException(e);
}
}
Aggregations