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
Related
Since I have upgraded to WildFly 8 I have problems with my JSF custom components: the first time the custom component is loaded, an error is throw:
IllegalStateException: Component ID formDlgPesqPccs:pesqOcupacaoCC:pesquisaOcupacaoDlg:pesquisaOcupacaoDlgbuttonpesquisaOcupacao has already been found in the view.
After first time, the component is rendered normally. I'm using Mojarra 2.2.10.
The composite component (pesquisarOcupacao.xhtml):
<composite:interface>
<composite:attribute name="beanReference"
type="seb.sarh.pccs.PesquisarOcupacaoBean" required="true"/>
<composite:attribute name="updatePesquisa" required="true"/>
<composite:attribute name="pesquisaScrollHeight" required="true"/>
<composite:attribute name="estilo" required="true"/>
<composite:attribute name="estiloPesquisa" required="true"/>
<composite:attribute name="edicao" default="true"/>
</composite:interface>
<composite:implementation>
<div id="divWraperPesqOcupacao" style="#{cc.attrs.estilo}">
<p:panel styleClass="panelgrid">
<h:panelGrid columns="2">
<p:fieldset legend="Tipo da Pesquisa">
<p:selectOneRadio value="#{cc.attrs.beanReference.tipo}"
requiredMessage="Selecione o tipo de pesquisa.">
<f:selectItem itemValue="1" itemLabel="Cargo " />
<f:selectItem itemValue="2" itemLabel="Função" />
</p:selectOneRadio>
</p:fieldset>
<p:fieldset legend="Criterio da Pesquisa">
<p:selectOneRadio value="#{cc.attrs.beanReference.criterio}"
requiredMessage="Selecione o criterio de pesquisa.">
<f:selectItem itemValue="2" itemLabel="Código" />
<f:selectItem itemValue="1" itemLabel="Descrição" />
</p:selectOneRadio>
</p:fieldset>
</h:panelGrid>
</p:panel>
<div id="divPesquisa" class="reference" style="clear: left">
<p:fieldset legend="Texto a pesquisar" style="#{cc.attrs.estiloPesquisa} ">
<p:commandButton id="#{cc.id}buttonpesquisaOcupacao"
style="float: right"
update="#{cc.attrs.updatePesquisa}"
actionListener="#{cc.attrs.beanReference.pesquisarOcupacao}"
icon="ui-icon-search" process="#form" />
<div style="overflow: hidden; padding: 2px 15px 0 0; margin-right: 4px">
<p:inputMask id="cod" value="#{cc.attrs.beanReference.texto}"
mask="?99999" rendered="#{cc.attrs.beanReference.criterio == 2}"
style="width: 100%" />
<p:inputText id="desc" value="#{cc.attrs.beanReference.texto}"
rendered="#{cc.attrs.beanReference.criterio == 1}"
style="width: 100%" />
</div>
</p:fieldset>
</div>
<div id="divExpandPesqEstrutura" class="expand">
<p:fieldset id="#{cc.id}fldsetOcupacoesPesquisadas"
styleClass="expand-content" legend="Resultados da Pesquisa"
style="#{cc.attrs.estiloPesquisa}">
<p:dataTable id="datatable" styleClass="corner" emptyMessage=""
selectionMode="single" selection="#{cc.attrs.beanReference.selecaoPesquisa}"
value="#{cc.attrs.beanReference.listOcupacoes}" var="cargo"
scrollable="true" rowKey="#{cargo.hashCode()}"
scrollHeight="#{cc.attrs.pesquisaScrollHeight}">
<p:ajax event="rowSelect"
listener="#{cc.attrs.beanReference.onRowSelect}" />
<p:column width="10%">
<f:facet name="header">
<h:outputText value="Código" />
</f:facet>
<h:outputText value="#{cargo.codigo}" />
</p:column>
<p:column width="68%">
<f:facet name="header">
<h:outputText value="Descrição" />
</f:facet>
<h:outputText value="#{cargo.descricao}" />
</p:column>
<c:if test="#{cc.attrs.edicao}">
<p:column width="10%" style="text-align:center">
<f:facet name="header">
<h:outputText value="" />
</f:facet>
<p:commandButton id="editarOcupacaoButton" icon="ui-icon-pencil"
style="width: 20px; height: 20px" />
<p:tooltip for="editarOcupacaoButton"
value="Editar Cargo/Função" />
</p:column>
<p:column width="10%" style="text-align:center">
<f:facet name="header">
<h:outputText value="" />
</f:facet>
<p:commandButton id="excluirOcupacaoButton" icon="ui-icon-trash"
style="width: 20px; height: 20px" />
<p:tooltip for="excluirOcupacaoButton"
value="Excluir Cargo/Função" />
</p:column>
</c:if>
</p:dataTable>
</p:fieldset>
</div>
</div>
</composite:implementation>
The web.xml:
<?xml version="1.0" encoding="UTF-8"?>
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>SARH</display-name>
<error-page>
<error-code>404</error-code>
<location>/xhtml/error.xhtml</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/xhtml/error.xhtml</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/xhtml/error.xhtml</location>
</error-page>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>redmond</param-value>
</context-param>
<context-param>
<param-name>javax.faces.SERIALIZE_SERVER_STATE</param-name>
<param-value>true</param-value>
</context-param>
<!-- Welcome page -->
<welcome-file-list>
<welcome-file>/xhtml/selecionar_empresa.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<display-name>RelatorioServlet</display-name>
<servlet-name>RelatorioServlet</servlet-name>
<servlet-class>seb.sarh.util.RelatorioServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RelatorioServlet</servlet-name>
<url-pattern>/RelatorioServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<mime-mapping>
<extension>png</extension>
<mime-type>image/png</mime-type>
</mime-mapping>
<session-config>
<tracking-mode>COOKIE</tracking-mode>
</session-config>
<listener>
<listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
</listener>
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<resource-env-ref>
<resource-env-ref-name>BeanManager</resource-env-ref-name>
<resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
</resource-env-ref>
My jsf page on IE won't show anything on firefox i atleast get the text. Strange thing is that there is no error so i am not sure what is wrong. I looked around for information and even added a f:view for the page but still nothing. Thank you for your time.
<!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://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j" >
<f:view contentType="text/html">
<h:head>
<title>QC-Form</title>
<link href="./css/styles.css"
rel="stylesheet" type="text/css"/>
</h:head>
<h:body>
<h1 class="title">QC Form</h1>
<br/> <br/>
<font face="comic sans MS" size="2" color="#33CCFF">
<p><b>Enter the information below: </b> </p>
</font>
<h:form>
<font face="comic sans MS" size="2">
<h:panelGroup id="initialInfo">
<b>Your initials: </b>
<h:inputText value="#{qcFormBean.techNameValue}"/><br/>
<br/>
<b>Model #: </b>
<h:selectOneMenu value="#{qcFormBean.modelValue}">
<f:selectItem itemValue="3600" itemLabel="3600" />
<f:selectItem itemValue="7200" itemLabel="7200" />
<f:selectItem itemValue="8300" itemLabel="8300" />
<f:selectItem itemValue="8400" itemLabel="8400" />
<f:selectItem itemValue="8500p" itemLabel="8500p" />
<f:selectItem itemValue="8800" itemLabel="8800" />
<f:selectItem itemValue="9000" itemLabel="9000" />
<f:selectItem itemValue="9008" itemLabel="9008" />
<f:selectItem itemValue="9200" itemLabel="9200" />
<f:selectItem itemValue="9300" itemLabel="9300" />
</h:selectOneMenu><br/>
<br/>
<b>Date : </b>
<h:outputText value="#{currentDate}"/>
<br/> <br/>
<b>Serial #: </b>
<h:inputText value="#{qcFormBean.serialValue}"/><br/>
<br/>
<b>Customer Name: </b>
<h:inputText value="#{qcFormBean.customerNameValue}"/><br/>
<br/>
<b>Special Instructions: </b>
<h:inputText value="#{qcFormBean.specialInstructionsValue}"/><br/>
</h:panelGroup>
</font>
<font face="comic sans MS" size="2" color="#33CCFF">
<p><b>QC Process</b> </p>
</font>
<font face="comic sans MS" size="2">
<h:panelGroup id="dliSerial">
<b>1.Unit Serial number has been applied: </b>
<h:selectOneMenu value="#{qcFormBean.unitSerialValue}">
<f:selectItems value="#{qcFormBean.valueQcValue}"/>
</h:selectOneMenu>
<br/>
</h:panelGroup>
<br/>
<b>2.Screen Protector has been applied: </b>
<h:panelGroup id="dliSticker">
<h:selectOneMenu value="#{qcFormBean.dliStickerValue}">
<f:selectItem itemValue="P" itemLabel="Pass or Not applicable" />
<f:selectItem itemValue="M" itemLabel="FAIL-Mechanical" />
<f:selectItem itemValue="E" itemLabel="FAIL-Electrical" />
<f:selectItem itemValue="C" itemLabel="FAIL-Cosmetic" />
<f:selectItem itemValue="S" itemLabel="FAIL-Software" />
<a4j:ajax event="change" execute="#this" render="perfbyDliSticker" limitRender="true" />
</h:selectOneMenu>
</h:panelGroup>
<h:panelGroup id="perfbyDlitcSticker">
<h:selectOneMenu value="#{qcFormBean.stickerFreq}"
rendered="#{!qcFormBean.dliStickerValue eq 'P'}">
<f:selectItem itemValue="A" itemLabel="Always" />
<f:selectItem itemValue="O" itemLabel="Often" />
<f:selectItem itemValue="S" itemLabel="Seldom" />
</h:selectOneMenu>
</h:panelGroup>
<br/>
</font>
<h:commandButton action="#{qcFormBean.submitForm()}"/>
</h:form>
</h:body>
</f:view>
</html>
Update: Right clicking on the source file on firefox does show the raw code being displayed like this:
<b>Your initials: </b>
<h:inputText value=""></h:inputText><br />
<br />
<b>Model #: </b>
<h:selectOneMenu value="">
</h:selectOneMenu><br />
<br />
and my web.xml file has the following servlet information.
<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>*.jsf</url-pattern>
</servlet-mapping>
As per the symptoms described in the comments, the <f:xxx> and <a4j:xxx> tags are properly processed by JSF, but the <h:xxx> tags not. Now, let's look at their XML namespace declarations, which is where all the processing starts:
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j" >
The xmlns.jcp.org domain as you've declared for the <h:xxx> XML namespace is introduced since JSF 2.2. The symptom of it being unprocessed thus indicates that you aren't running JSF 2.2 at all, but an older JSF 2.x version, such as 2.0 or 2.1, which don't recognize the new XML namespace domains yet.
You've basically 2 options:
Either fix the <h:xxx> XML namespace accordingly to match JSF 2.0/2.1 specification:
xmlns:h="http://java.sun.com/jsf/html"
Or, just upgrade to JSF 2.2.
That means your jsf tags are not parsed to plain html. To confirm this one see the page view source if you could see the plain jsf tags then that is the problem.
The primary reason for tags not being parsed means your request is not being handed by Faces servlet. You should have some thing like this in your web.xml
<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>*.xhtml</url-pattern>
</servlet-mapping>
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>
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;
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>