i want to implement a login page using jsf for that i wanted
to implement a form:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Login</title>
<link href="../resources/css/basic.css" type="text/css" rel="stylesheet" />
</h:head>
<h:body>
<div id="wrapper">
<ul id="menu">
<li id="menutab"><a class="link" href="../index.jsp">Home</a></li>
<li id="menutab"><a class="link" href="../jsf/list.jspx">Liste</a></li>
<li id="menutab"><a class="link" href="../servlets/DataServlet">Daten</a></li>
<li id="menutab"><a class="link" href="../servlets/ListMoviesServlet">Movies</a></li>
<li id="menutab"><a class="link" href="../servlets/ListPeopleServlet">People</a></li>
</ul>
<br></br>
<h2 id="title">Login</h2>
<h:form id="j_security_check">
<center>
<h:messages errorClass="errorMessage" infoClass="infoMessage" warnClass="warnMessage"></h:messages>
<h:panelGrid columns="2">
<h:outputText value="Username : "/>
<h:inputText id="j_username" value="#{loginBean.username}"/>
<h:outputText value="Password : "/>
<h:inputSecret id="j_password" value="#{loginBean.password}"/>
<h:commandButton value="Submit" action="#{loginBean.login}" type="submit"/>
</h:panelGrid>
</center>
</h:form>
</div>
</h:body>
</html>
The page is shown but the form defined here isnt shown. everything
after the title is just a white screen.
Why the form isnt rendered?
Ok i got it!
This is the jsf mapping in my web.xml:
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jspx</url-pattern>
</servlet-mapping>
As you see the url-pattern describes ".jspx"
So i have to call my jsf with "myjsf.jspx" instead of "myjsf.xhtml"
<login-config>
<auth-method>FORM</auth-method>
<realm-name>loginRealm</realm-name>
<form-login-config>
<form-login-page>/jsf/login.jspx</form-login-page>
<form-error-page>/jsf/error.jspx</form-error-page>
</form-login-config>
</login-config>
Related
My web application includes 3 pages:
index.xhtml
welcome.xhtml
nextround.xhtml
I have two javaBean classes:
1.webTimeBean
2.userBean
the webtimeBean class is #ApplicationScoped.
the userBean class is #SessionScoped.
I also have class for SQL requests and User class for user information.
I have a navigation issue.
After the user login (index.xhtml) the welcome page loads correctly with data from database.
Then the user can click on a next round link but instead to navigate to nextround.xjtml the application send him back to the index.xhtml page.
<?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:f="http://xmlns.jcp.org/jsf/core">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css"/>
<h:head>
<title>Web TIme : A simple example Title</title>
<meta http-equiv="refresh" content="60"/>
</h:head>
<h:body>
<div class="w3-container w3-light-grey w3-border">
<p>Today : #{webTimeBean.time}</p>
</div>
<h:form>
<br></br>
<h:inputText value="#{userBean.email}" class="w3-input" />
<h:inputText value="#{userBean.password}" class="w3-input" />
<h:commandButton value="Log In" class="w3-btn-block w3-teal" action="#{userBean.verifyLogin()}" />
</h:form>
</h:body>
</html>
<?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:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css"/>
<h:head>
<title>Goalim Game </title>
<meta http-equiv="refresh" content="300"/>
</h:head>
<h:body>
<div class="w3-container w3-light-grey w3-border">
<p>Today : #{webTimeBean.time}</p>
</div>
<table class="w3-table w3-bordered w3-striped">
<tr>
<th>User Name</th>
<th>Score</th>
</tr>
<ui:repeat var="elem" value="#{userBean.tblScore}" >
<tr>
<td>
<h:outputText value="#{elem.userName}" />
</td>
<td>
<h:outputText value="#{elem.totalPoints}" />
</td>
</tr>
</ui:repeat>
</table>
<form>
<h:commandButton value="Next Round" class="w3-btn-block w3-teal" action="/nextround.xhtml" />
</form>
</h:body>
</html>
<?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:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css"/>
<h:head>
<title>Web TIme : A simple example Title</title>
<meta http-equiv="refresh" content="60"/>
</h:head>
<h:body>
<div class="w3-container w3-light-grey w3-border">
<p>Today : #{webTimeBean.time}</p>
<p>Hello : #{userBean.userName}</p>
</div>
</h:body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
<resource-ref>
<description>postgress database</description>
<res-ref-name>jdbc/postgres</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
I have a jsf project, that i made using only core and html jsf taglibs, but the components of the forms look awful, so i'm now trying to add richfaces so i can add a skin to them, the jars i've added for richfaces are:
richfaces-core-api-4.3.4.Final.jar
richfaces-core-impl-4.3.4.Final.jar
richfaces-components-api-4.3.4.Final.jar
richfaces-components-ui-4.3.4.Final.jar
cssparser-0.9.5.jar
guava-r09.jar
sac-1.3.sources,jar
and my web.xml looks like this
<servlet>
<servlet-name>FacesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<filter>
<!-- Nome que indentifica o filtro pode ser qualquer um -->
<filter-name>LoginWard</filter-name>
<!-- Endereço da classe que herda de javax.servlet.Filter com o nome dos pacotes e sem .java ex: org.otkdrg.NomeDaClasse -->
<filter-class>br.com.gbcCalcados.moduloVendas.filter.LoginWard</filter-class>
</filter>
<filter-mapping>
<filter-name>LoginWard</filter-name>
<url-pattern>*.xhtml</url-pattern>
</filter-mapping>
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>enable</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>classic</param-value>
</context-param>
Still nothing happens when i run the project everthing still the same not even an exception.
Here is a page
<!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://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
>
<ui:composition template="/WEB-INF/templates/gbcTemplate.xhtml"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j" >
<ui:define name="Conteudo">
<div id="funcFormDiv" align="center">
<h:form>
<h:messages/>
<h:outputLabel for="campoNome" value="Nome Completo:"/><br/>
<h:inputText id="campoNome" required="true" value="#{cadastroFuncBean.nomeCompleto}" validatorMessage="O nome completo é composto de um ou mais nomes e não pode conter numeros" requiredMessage="O nome completo é obrigatorio" >
<f:validateRegex pattern="\D* \D*"/>
</h:inputText><br/>
<h:outputLabel for="campoUsuario" value="Nome de usuário:"/><br/>
<h:inputText id="campoUsuario" required="true" value="#{cadastroFuncBean.usuario}" requiredMessage="O nome de usuario é obrigatorio" validatorMessage="O nome de usuário deve conter no minimo 6 e no maximo 15 letras">
<f:validateLength minimum="6" maximum="15"/>
</h:inputText><br/>
<h:outputLabel for="campoSenha" value="Senha:"/><br/>
<h:inputSecret id="campoSenha" required="true" value="#{cadastroFuncBean.senha}" requiredMessage="A senha é obrigatoria" validatorMessage="A senha deve conter no minimo 3 e no maximo 10 letras">
<f:validateLength minimum="3" maximum="10"/>
</h:inputSecret><br/>
<h:outputLabel for="campoNumContrato" value="Numero do contrato:"/><br/>
<h:inputText id="campoNumContrato" required="true" value="#{cadastroFuncBean.numContrato}" requiredMessage="O numero de contrato é obrigatorio" validatorMessage="Numero de contrato invalido">
<f:validateRegex pattern="^9\d{5}"/>
</h:inputText><br/><br/><br/>
<h:commandButton value="Enviar" action="#{cadastroFuncBean.cadastrar}" /><input type="reset" value="Resetar" />
<br/>
<h:button id="voltar" value="Voltar para Login" outcome="login" />
</h:form>
</div>
</ui:define>
</ui:composition>
</html>
the template:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j" >
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>GBC calçados</title>
<h:outputStylesheet name="arquivo.css" library="css"/>
</h:head>
<h:body>
<div id="LoginInfoTab"><span id="LoginInfo">Usuário Logado:<h:outputText value="#{sessionScope['usuario_logado'] }" /></span></div>
<div id="TopBanner"><h:graphicImage width="100%" library="images" name="TopBanner.jpg" /></div>
<div id="Menu" >
<h:form>
<h:link outcome="clientesHome">
<div class="menuItem">
<span class="menuItemTexto">Clientes</span>
</div>
</h:link>
<h:link outcome="vendasHome" >
<div class="menuItem" id="botaoVendas">
<span class="menuItemTexto">Vendas</span>
</div>
</h:link>
</h:form>
</div>
<div id="Content" align="center">
<ui:insert name ="Conteudo"/>
</div>
<div id="BottomBanner"><h:graphicImage width="100%" library="images" name="BottomBanner.jpg" /></div>
</h:body>
</html>
JSF 2.2
Richfaces 4.3.3
Java 7
Netbeans 7.3.1
Im trying to use a richfaces popup calender, but it does not popup, i can see the input field aswell as the calender icon but when i click it nothing happens. when setting popup to false i can see the whole calender.
Page examples:
<?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://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<ui:composition template="/template.xhtml" >
<ui:define name="title">
<h:outputText value="#{bundle.CreateTimeLoggingDetailTitle}"></h:outputText>
</ui:define>
<ui:define name="pagetitle">
<h:outputText value="Client Details" styleClass="auto-style3"></h:outputText>
</ui:define>
<ui:define name="heads">
<h:link outcome="/login/admin.xhtml" value="#{bundle.CreateTimeLoggingDetailIndexLink}"/>
</ui:define>
<ui:define name="body">
<!-- CLIENT INFORMATION-->
<h:panelGroup id="messagePanel" layout="block">
<h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
</h:panelGroup>
<h:form>
<h:panelGrid columns="4">
<h:outputText value="#{bundle.ViewTimeLoggingLabel_employeesEmployeeNo}"/>
<h:outputText value="#{employeesController.getEmployees(timeLoggingController.selected.employeesEmployeeNo).name} #{employeesController.getEmployees(timeLoggingController.selected.employeesEmployeeNo).surname}" title="#{bundle.ViewTimeLoggingTitle_employeesEmployeeNo}"/>
<h:outputText value="#{bundle.ViewTimeLoggingLabel_customersId}"/>
<h:outputText value="#{customersController.getCustomers(timeLoggingController.selected.customersId).name}" title="#{bundle.ViewTimeLoggingTitle_customersId}"/>
<h:outputText value="#{bundle.ViewTimeLoggingLabel_projectsId}"/>
<h:outputText value="#{projectsController.getProjects(timeLoggingController.selected.projectsId).description}" title="#{bundle.ViewTimeLoggingTitle_projectsId}"/>
<h:outputText value="#{bundle.ViewTimeLoggingLabel_tasksId}"/>
<h:outputText value="#{tasksController.getTasks(timeLoggingController.selected.tasksId).description}" title="#{bundle.ViewTimeLoggingTitle_tasksId}"/>
<br/>
</h:panelGrid>
<h:outputText value="Log Time" styleClass="auto-style3" />
<!-- LOG TIME PANEL-->
<br/>
<br/>
<table border="1" style="text-align: center" class="jsfcrud_odd_row,jsfcrud_even_row, jsfcrud_list_form">
<tr>
<th><h:outputLabel value="#{bundle.CreateTimeLoggingDetailLabel_date}" for="date" /></th>
<th><h:outputLabel value="#{bundle.CreateTimeLoggingDetailLabel_description}" for="description" /></th>
<th><h:outputLabel value="#{bundle.CreateTimeLoggingDetailLabel_normalHours}" for="normalHours" /></th>
<th><h:outputLabel value="#{bundle.CreateTimeLoggingDetailLabel_overtimeHours}" for="overtimeHours" /></th>
<th><h:outputLabel value="#{bundle.CreateTimeLoggingDetailLabel_doubleTimeHours}" for="doubleTimeHours" /></th>
<th><h:outputLabel value="#{bundle.CreateTimeLoggingDetailLabel_billTypesId}" for="billTypesId" /></th>
</tr>
<tr>
<td>
<rich:calendar value="#{timeLoggingDetailController.selected.date}" locale="Locale.US" popup="true" datePattern="MM/dd/yyyy" style="width:200px"/>
</td>
<td><h:inputText id="description" value="#{timeLoggingDetailController.selected.description}" title="#{bundle.CreateTimeLoggingDetailTitle_description}" size="18" /></td>
<td><h:inputText id="normalHours" value="#{timeLoggingDetailController.selected.normalHours}" title="#{bundle.CreateTimeLoggingDetailTitle_normalHours}" size="10"/></td>
<td><h:inputText id="overtimeHours" value="#{timeLoggingDetailController.selected.overtimeHours}" title="#{bundle.CreateTimeLoggingDetailTitle_overtimeHours}" size="10" /></td>
<td><h:inputText id="doubleTimeHours" value="#{timeLoggingDetailController.selected.doubleTimeHours}" title="#{bundle.CreateTimeLoggingDetailTitle_doubleTimeHours}" size="16" /></td>
<td><h:selectOneMenu id="billTypesId" value="#{timeLoggingDetailController.selected.billTypesId}">
<f:selectItems value="#{billTypesController.items}" var="i" itemLabel="#{i.description}" itemValue="#{i.id}" />
</h:selectOneMenu></td>
<td> <h:commandLink onclick="#{timeLoggingDetailController.selected.timeLoggingId=timeLoggingController.selected.id}" action="#{timeLoggingDetailController.create}" value="#{bundle.CreateTimeLoggingDetailSaveLink}" styleClass="linkbutton"/></td>
</tr>
</table>
<br/>
</h:form>
where i use the calender:
<rich:calendar value="#{timeLoggingDetailController.selected.date}" locale="Locale.US" popup="true" datePattern="MM/dd/yyyy" style="width:200px"/>
My web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>org.richfaces.skin</param-name>
<param-value>plain</param-value>
</context-param>
</web-app>
I also have <h:head></h:head> in my template file
I develop a java application with jsf and eclispeLink with netbeans 7.3.1 but my character don't save correctly. I look at request variable and saw that my character are not correctly show in the request object.
My Jsf sample :
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition template="/template.xhtml">
<ui:define name="title">
<h:outputText value="#{bundle.CreateTblAccessTitle}"></h:outputText>
</ui:define>
<ui:define name="body">
<h:panelGroup id="messagePanel" layout="block">
<h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
</h:panelGroup>
<h:form>
<h:panelGrid columns="2">
<h:outputLabel value="#{bundle.CreateTblAccessLabel_id}" for="id" />
<h:inputText id="id" value="#{tblAccessController.selected.id}" title="#{bundle.CreateTblAccessTitle_id}" required="true" requiredMessage="#{bundle.CreateTblAccessRequiredMessage_id}"/>
<h:outputLabel value="#{bundle.CreateTblAccessLabel_userName}" for="userName" />
<h:inputText id="userName" value="#{tblAccessController.selected.userName}" title="#{bundle.CreateTblAccessTitle_userName}" />
<h:outputLabel value="#{bundle.CreateTblAccessLabel_userTypeId}" for="userTypeId" />
<h:selectOneMenu id="userTypeId" value="#{tblAccessController.selected.userTypeId}" title="#{bundle.CreateTblAccessTitle_userTypeId}" >
<f:selectItems value="#{tblUserTypeController.itemsAvailableSelectOne}"/>
</h:selectOneMenu>
<h:outputLabel value="#{bundle.CreateTblAccessLabel_formId}" for="formId" />
<h:selectOneMenu id="formId" value="#{tblAccessController.selected.formId}" title="#{bundle.CreateTblAccessTitle_formId}" required="true" requiredMessage="#{bundle.CreateTblAccessRequiredMessage_formId}">
<f:selectItems value="#{tblFormController.itemsAvailableSelectOne}"/>
</h:selectOneMenu>
<h:outputLabel value="#{bundle.CreateTblAccessLabel_activitesId}" for="activitesId" />
<h:selectOneMenu id="activitesId" value="#{tblAccessController.selected.activitesId}" title="#{bundle.CreateTblAccessTitle_activitesId}" required="true" requiredMessage="#{bundle.CreateTblAccessRequiredMessage_activitesId}">
<f:selectItems value="#{tblAccessActivitiesController.itemsAvailableSelectOne}"/>
</h:selectOneMenu>
</h:panelGrid>
<br />
<h:commandLink action="#{tblAccessController.create}" value="#{bundle.CreateTblAccessSaveLink}" />
<br />
<br />
<h:commandLink action="#{tblAccessController.prepareList}" value="#{bundle.CreateTblAccessShowAllLink}" immediate="true"/>
<br />
<br />
<h:link outcome="/index" value="#{bundle.CreateTblAccessIndexLink}"/>
</h:form>
</ui:define>
</ui:composition>
</html>
MY Filter to change encoding :
public class EncodingFilter implements Filter{
private String encoding;
#Override
public void init(FilterConfig filterConfig) throws ServletException {
encoding = filterConfig.getInitParameter("requestEncoding");
if( encoding==null ) encoding="UTF-8";
}
#Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
httpRequest.setCharacterEncoding(encoding);
httpResponse.setCharacterEncoding(encoding);
response.setContentType("text/html;charset=utf-8");
chain.doFilter(httpRequest, httpResponse);
}
#Override
public void destroy() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
My Template.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><ui:insert name="title">Default Title</ui:insert></title>
<h:outputStylesheet name="css/jsfcrud.css"/>
</h:head>
<h:body>
<h1>
<ui:insert name="title">Default Title</ui:insert>
</h1>
<p>
<ui:insert name="body">Default Body</ui:insert>
</p>
</h:body>
</html>
My web.xml
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>business.EncodingFilter</filter-class>
<init-param>
<param-name>requestEncoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<jsp-config>
<jsp-property-group>
<url-pattern>*.xhtml</url-pattern>
<page-encoding>UTF-8</page-encoding>
</jsp-property-group>
</jsp-config>
</web-app>
what is the problem? how could i solve it?
Every things look fine! You should check the following:
a) Check whether your Glassfish Resources has following inside :
<property name="useUnicode" value="true"/>
<property name="characterEncoding" value="UTF8"/>
b) Whether your database and the table are UTF-8 CHARCTER SET
for mysql use following code:
ALTER DATABASE dbname DEFAULT CHARACTER SET utf8;
USE dbname;
ALTER TABLE tblname CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
As per title. I'm following the JavaServer Faces 2.0 tutorial (found here) - search for "To declare these components" to find roughly where I'm at.
Everthing works up until a certain point, however when I'm told to comment out the html form component, and uncomment the JSF form component, nothing displays. If I recomment out the JSF form and use the html one instead, it works fine. As far as I can see, I've followed the tutorial exactly. Any ideas?
For the record, this is what my index.xhtml looks like:
<!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://java.sun.com/jsf/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="css/stylesheet.css" rel="stylesheet" type="text/css" />
<!--<h:outputStylesheet name="css/stylesheet.css" />-->
<title>Greeting</title>
</head>
<body>
<div id="mainContainer">
<div id="left" class="subContainer greyBox">
<h4>Hi, my name is Duke!</h4>
<h5>I'm thinking of a number
<br/>
between
<span class="highlight">1</span> and
<span class="highlight">10</span>.</h5>
<h5>Can you guess it?</h5>
<!--<form action="response.xhtml">
<input type="text" size="2" maxlength="2" />
<input type="submit" value="submit" />
</form>-->
<h:form>
<h:inputText size="2" maxlength="2" value="#{UserNumberBean.userNumber}" />
<h:commandButton id="submit" value="submit" action="response" />
</h:form>
</div>
<div id="right" class="subContainer">
<img src="duke.png" alt="Duke waving" />
<!--<h:graphicImage url="/duke.png" alt="Duke waving" />-->
</div>
</div>
</body>
make sure that your web.xml says:
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>