use of jakarta.faces.webapp.FacesServlet 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);
}
}
use of jakarta.faces.webapp.FacesServlet in project myfaces by apache.
the class MyFacesProcessor method buildServlet.
@BuildStep
void buildServlet(WebMetadataBuildItem webMetaDataBuildItem, BuildProducer<FeatureBuildItem> feature, BuildProducer<ServletBuildItem> servlet, BuildProducer<ListenerBuildItem> listener) throws IOException {
WebMetaData webMetaData = webMetaDataBuildItem.getWebMetaData();
ServletMetaData facesServlet = null;
if (webMetaData.getServlets() != null) {
facesServlet = webMetaData.getServlets().stream().filter(servletMeta -> FacesServlet.class.getName().equals(servletMeta.getServletClass())).findFirst().orElse(null);
}
if (facesServlet == null) {
// Only define here if not explictly defined in web.xml
servlet.produce(ServletBuildItem.builder("Faces Servlet", FacesServlet.class.getName()).setMultipartConfig(new MultipartConfigElement("")).addMapping("*.xhtml").build());
}
// sometimes Quarkus doesn't scan web-fragments?! lets add it manually
listener.produce(new ListenerBuildItem(StartupServletContextListener.class.getName()));
}
use of jakarta.faces.webapp.FacesServlet in project mojarra by eclipse-ee4j.
the class FacesServletTestCase method testPositiveInitWithNoContextParams.
public void testPositiveInitWithNoContextParams() throws Exception {
FacesServlet me = new FacesServlet();
me.init(config);
this.sendRequest(me, "OPTIONS");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "GET");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "HEAD");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "POST");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "PUT");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "DELETE");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "TRACE");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "CONNECT");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
}
use of jakarta.faces.webapp.FacesServlet in project mojarra by eclipse-ee4j.
the class FacesServletTestCase method testNegativeInitWithContextParamsOfKnownHttpMethods.
public void testNegativeInitWithContextParamsOfKnownHttpMethods() throws Exception {
FacesServlet me = new FacesServlet();
servletContext.addInitParameter(ALLOWED_HTTP_METHODS_ATTR_COPY, "GET POST GET POST");
me.init(config);
this.sendRequest(me, "OPTIONS");
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
this.sendRequest(me, "GET");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "HEAD");
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
this.sendRequest(me, "POST");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "PUT");
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
this.sendRequest(me, "DELETE");
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
this.sendRequest(me, "TRACE");
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
this.sendRequest(me, "CONNECT");
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
}
use of jakarta.faces.webapp.FacesServlet in project mojarra by eclipse-ee4j.
the class FacesServletTestCase method testPositiveInitWithContextParamsOfUnknownAndKnownHttpMethods.
public void testPositiveInitWithContextParamsOfUnknownAndKnownHttpMethods() throws Exception {
FacesServlet me = new FacesServlet();
servletContext.addInitParameter(ALLOWED_HTTP_METHODS_ATTR_COPY, "GET\tPOST\tGETAAAAA");
me.init(config);
this.sendRequest(me, "OPTIONS");
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
this.sendRequest(me, "GET");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "HEAD");
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
this.sendRequest(me, "POST");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "PUT");
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
this.sendRequest(me, "DELETE");
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
this.sendRequest(me, "TRACE");
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
this.sendRequest(me, "CONNECT");
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
this.sendRequest(me, "BOO_YA");
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
this.sendRequest(me, "GETAAAAA");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
}
Aggregations