Pessoal,
Estou inciando os meus estudos em JSF e para isto estou criando,
aos poucos, um pequeno aplicativo de cadastro de usuários. Não estou
conseguindo configurar corretamente o arquivo de mensagens.
Ao tentar rodar a aplicação, aparece a seguinte mensagem de erro :
java.util.MissingResourceException:Can't find bundle for base name
src.messages.message_pt_BR, locale pt_BR
Seguem, abaixo os arquivos de configuração e códigos-fonte
envolvidos :
Arquivo web.xml
-----------------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="
http://java.sun.com/xml/
ns/j2ee" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>WebUserManager2</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</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-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
</web-app>
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Arquivo faces-config.xml
----------------------------------------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0"?>
<faces-config 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-facesconfig_1_2.xsd"
version="1.2">
<application>
<resource-bundle>
<base-name>src.messages.message_pt_BR</base-name>
<var>msgs</var>
</resource-bundle>
<message-bundle>messages_pt_BR</message-bundle>
<locale-config>
<default-locale>pt_BR</default-locale>
<supported-locale>en_US</supported-locale>
</locale-config>
</application>
<managed-bean>
<managed-bean-name>loginForm</managed-bean-name>
<managed-bean-class>beans.LoginFormBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>UsuarioBean</managed-bean-name>
<managed-bean-class>beans.UsuarioBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/login.jsp</from-view-id>
<navigation-case>
<from-outcome>menu</from-outcome>
<to-view-id>/menu.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/login.jsp</from-view-id>
<navigation-case>
<from-outcome>falha</from-outcome>
<to-view-id>/erro_login.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/cadastraUsuario.jsp</from-view-id>
<navigation-case>
<from-outcome>sucesso</from-outcome>
<to-view-id>/sucesso_cadastro.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/cadastraUsuario.jsp</from-view-id>
<navigation-case>
<from-outcome>falha</from-outcome>
<to-view-id>/erro_cadastro.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
------------------------------------------------------------------------------------------------------------------------------------------------------------------
Arquivo messages_pt_BR.properties
------------------------------------------------------------------------------------------------------------------------------------------------------------------
cpf_vazio=Campo CPF naum pode ser vazio
nome_vazio=Campo NOME naum pode ser vazio
senha_vazio=Campo SENHA naum pode ser vazio
confsenha_vazio=Campo CONFIRMACAUM DE SENHA naumpode ser vazio
emailprinc_vazio=Campo EMAIL PRINCIPAL naum pode ser vazio
emailalter_vazio=Campo EMAIL ALTERNATIVO naum pode ser vazio
telefone_vazio=Campo TELEFONE naum pode ser vazio
perfil_vazio=Campo PERFIL naum pode ser vazio
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Arquivo CadastraUsuario.jsp
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
%@taglib uri="
http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="
http://java.sun.com/jsf/html" prefix="h" %>
<%@taglib uri="
http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<title>WebUserManager - Cadastramento de Usuário</title>
</head>
<body>
<f:view>
<h:outputText value="Preencha os dados do Usuário" />
<br />
<br />
<h:form>
<h:panelGrid columns="3">
<h:outputText value="CPF :"></h:outputText>
<h:inputText id="cpf" value="#{UsuarioBean.cpf}" required="true"></
h:inputText>
<h:outputText value="#{msgs.cpf_vazio}"></h:outputText>
<h:outputText value="Nome :"></h:outputText>
<h:inputText id = "nome" value="#{UsuarioBean.nome}"
required="true"></h:inputText>
<h:message for="nome" style="color: red"></h:message>
<h:outputText value="Senha :"></h:outputText>
<h:inputSecret id="senha" value="#{UsuarioBean.senha}"
required="true"></h:inputSecret>
<h:message for="senha"style="color: red"></h:message>
<h:outputText value="Confirma Senha :"></h:outputText>
<h:inputSecret id="confirmaSenha" value="#
{UsuarioBean.confirmaSenha}" required="true"></h:inputSecret>
<h:message for="confirmaSenha" style="color: red"></h:message>
<h:outputText value="Email Principal :"></h:outputText>
<h:inputText id = "emailPrincipal" value="#
{UsuarioBean.emailPrincipal}" required="true"></h:inputText>
<h:message for="emailPrincipal" style="color: red"></h:message>
<h:outputText value="Email Alternativo :"></h:outputText>
<h:inputText id="emailAlternativo" value="#
{UsuarioBean.emailAlternativo}" required="true"></h:inputText>
<h:message for="emailAlternativo" style="color: red"></h:message>
<h:outputText value="Telefone :"></h:outputText>
<h:inputText id="telefone" value="#{UsuarioBean.telefone}"
required="true"></h:inputText>
<h:message for="telefone" style="color: red"></h:message>
<h:outputText value="Perfil :"></h:outputText>
<h:inputText id="perfil" value="#{UsuarioBean.perfil}"
required="true"></h:inputText>
<h:message for="perfil" style="color: red"></h:message>
<br />
<h:commandButton type="submit" value="Enviar" action="#
{UsuarioBean.validaSenha}"/>
</h:panelGrid>
<br />
<br />
<h:outputLink value = "menu.jsf">
<h:outputText value="< Voltar" />
</h:outputLink>
<br />
<br />
<h:outputLink value = "login.jsf">
<h:outputText value="< Sair" />
</h:outputLink>
</h:form>
</f:view>
</body>
</html>
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Bem, é isto. Logo acima estão os arquivos de configuração, de
mensagens e de pagínas JSF.
Espero que alguém consiga me ajudar.
Agracece,
Max Carvalho