Reputation: 1
I write code in JSF/Facelets file to show a form but it did not show anything. Here's my surveyform.xhtml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:view>
<h:form>
<h:panelGrid columns="2">
<h:graphicImage alt="There is error" name="form-icon.jpg" library="image"/>
<h1>Khảo sát</h1>
<img src="resources/image/form.png" alt="This is error" style="width: 30px; height: 30px"/>
</h:panelGrid>
<h:panelGrid columns="2">
<h:outputLabel value="Họ tên"/>
<h:inputText id="txtHoTen"/>
<h:outputLabel value="Năm sinh"/>
<h:inputText id="txtNamSinh"/>
<h:selectOneRadio id="rdoGioiTinh">
<f:selectItem itemValue="Nam" itemLabel="Nam"/>
<f:selectItem itemValue="Nữ" itemLabel="Nữ"/>
</h:selectOneRadio>
</h:panelGrid>
</h:form>
</f:view>
</html>
I tried to use <h:graphicImage>
, <h:panelGrid>
, <h:outputLabel>
, ... before but it did not display anything. Otherwise, html tags like <h1>
or <img>
still work fine. So what happened? Why facelets component code can not run?
I searched and chatGPT said that I need to add following code to my web.xml file:
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
But when I added this to my file, my glassfish server even did not run properly, there was an error during artifact deployment (my war file got in trouble). I looked at log and see this error:
Artifact surveywebapp:war exploded: java.io.IOException: com.sun.enterprise.admin.remote.RemoteFailureException: Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalStateException: CDI is not available
Upvotes: 0
Views: 25