Internacionalização com Facelets e JSF

0 respostas
waslleys

Olá estou criando uma aplicação utilizando facelets, JSF e spring, mais quando eu tento acessar o meu arquivo labels.properties, ele nao consegue carregar as keys com dois nomes, como por exemplo, pagina.nome = Nome, apenas as com um nome, por exemplo, nome= Nome

Alguem sabe o q pode ser isso?

<faces-config>  	
  	<application>
    	<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
    	<locale-config>
    		<default-locale>pt_BR</default-locale>
		</locale-config>		
		<message-bundle>labels</message-bundle>
		<message-bundle>images</message-bundle>
  	</application>
	<navigation-rule>
		<from-view-id>*</from-view-id>
		<navigation-case>
			<from-outcome>grupoForm</from-outcome>
			<to-view-id>/pages/administrativo/grupoMb/form.xhtml</to-view-id>
		</navigation-case>
	</navigation-rule>
</faces-config>
faces-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:sa="https://spring-annotation.dev.java.net/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
    https://spring-annotation.dev.java.net/context https://spring-annotation.dev.java.net/nonav/context.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
	default-autowire="byName">
	
	<sa:annotation-autoload/>
	
	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
		<property name="driverClassName" value="com.mysql.jdbc.Driver" />
		<property name="url" value="jdbc:mysql://localhost/Original" />
		<property name="username" value="root" />
		<property name="password" value="root" />
	</bean>
	
	<bean id="sessionFactory" class="net.java.dev.springannotation.hibernate.AutomaticAnnotationSessionFactoryBean">
		<property name="configLocations" value="classpath*:hibernate.cfg.xml" />
		<property name="schemaUpdate" value="true" />
	</bean>
	
	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" />
	<!-- tx:annotation-driven/ -->
	
    <!-- bean id="jspViewResolver" 
    	class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
		<property name="prefix" value="/WEB-INF/jsp/" />
		<property name="suffix" value=".faces" />
	</bean -->
	
	<!-- bean id="messageSource"
		class="org.springframework.context.support.ResourceBundleMessageSource">
		<property name="basenames">
			<list>
				<value>images</value>
				<value>labels</value>
			</list>
		</property>
	</bean>
	
	<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"/ -->
    
</beans>
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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" 
         version="2.4">         
  
  	<display-name>Original Web</display-name>
  	
	<!-- Facelets -->
	<context-param>
		<param-name>facelets.REFRESH_PERIOD</param-name>
		<param-value>2</param-value>
	</context-param>
	
	<context-param>
		<param-name>facelets.DEVELOPMENT</param-name>
		<param-value>true</param-value>
	</context-param>
	
	<context-param>
     	<param-name>facelets.LIBRARIES</param-name>
     	<param-value>/WEB-INF/tomahawk.taglib.xml</param-value>
  	</context-param>
	
	<!-- Spring Annotation -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath*:applicationContext.xml</param-value>
	</context-param>
	
	<context-param>
		<param-name>contextClass</param-name>
		<param-value>net.java.dev.springannotation.web.TOAnnotationXmlWebApplicationContext</param-value>
	</context-param>
	
	<!-- Ajax4JSF -->
	<!-- context-param>
		<param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
		<param-value>com.sun.facelets.FaceletViewHandler</param-value>
	</context-param -->
	
	<context-param>
		<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
		<param-value>.xhtml</param-value>
	</context-param>
	
	<!-- JSF -->
	<context-param>
		<description>
			Set this flag to true if you want the JavaServer Faces Reference Implementation 
			to validate the XML in your faces-config.xml resources against the DTD. 
			Default value is false.
		</description>
		<param-name>com.sun.faces.validateXml</param-name>
		<param-value>true</param-value>
	</context-param>
	
	<context-param>
		<description>
			Set this flag to true if you want the JavaServer Faces Reference Implementation 
			to verify that all of the application objects you have 
			configured (components, converters, renderers, and validators) can be successfully created. 
			Default value is false.
		</description>
		<param-name>com.sun.faces.verifyObjects</param-name>
		<param-value>true</param-value>
	</context-param>
  
  	<!-- context-param>
    	<description>
    		Comma separated list of URIs of (additional) faces config files. (e.g. /WEB-INF/my-config.xml)
            See JSF 1.0 PRD2, 10.3.2
            Attention: You do not need to put /WEB-INF/faces-config.xml in here.
    	</description>
    	<param-name>javax.faces.CONFIG_FILES</param-name>
    	<param-value>/WEB-INF/examples-config.xml</param-value> 
  	</context-param -->
  
  	<context-param>
    	<description>
    		State saving method: "client" or "server" (= default)
            See JSF Specification 2.5.3
        </description>
    	<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    	<param-value>client</param-value>
  	</context-param>
  
  	<context-param>
    	<description>
    		Only applicable if state saving method is "server" (= default).
            Defines the amount (default = 20) of the latest views are stored in session.
        </description>
    	<param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
    	<param-value>20</param-value>
  	</context-param>
  	
  	<context-param>
    	<description>
    		Only applicable if state saving method is "server" (= default).
            If true (default) the state will be serialized to a byte stream before it 
            is written to the session.
            If false the state will not be serialized to a byte stream.
        </description>
    	<param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
    	<param-value>true</param-value>
  	</context-param>
  	
  	<context-param>
    	<description>
    		Only applicable if state saving method is "server" (= default) and if 
            org.apache.myfaces.SERIALIZE_STATE_IN_SESSION is true (= default)
            If true (default) the serialized state will be compressed before it 
            is written to the session. If false the state will not be compressed.
        </description>
    	<param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
    	<param-value>true</param-value>
  	</context-param>
  	
  	<context-param>
    	<description>
    		This parameter tells MyFaces if javascript code should be allowed in the
            rendered HTML output.
            If javascript is allowed, command_link anchors will have javascript code
            that submits the corresponding form.
            If javascript is not allowed, the state saving info and nested parameters
            will be added as url parameters.
            Default: "true"
        </description>
    	<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
    	<param-value>true</param-value>
  	</context-param>
  	
  	<context-param>
    	<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
    	<param-value>false</param-value>
  	</context-param>
  	
  	<context-param>
    	<description>
    		If true, rendered HTML code will be formatted, so that it is "human readable".
            i.e. additional line separators and whitespace will be written, that do not
            influence the HTML code.
            Default: "true"
        </description>
    	<param-name>org.apache.myfaces.PRETTY_HTML</param-name>
    	<param-value>true</param-value>
  	</context-param>
  	
  	<context-param>
    	<description>
    		If true, a javascript function will be rendered that is able to restore the
            former vertical scroll on every request. Convenient feature if you have pages
            with long lists and you do not want the browser page to always jump to the top
            if you trigger a link or button action that stays on the same page.
            Default: "false"
        </description>
    	<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
    	<param-value>true</param-value>
  	</context-param>
  
    <context-param>
    	<description>
    		Used for encrypting view state. Only relevant for client side
    		state saving. See MyFaces wiki/web site documentation for instructions
    		on how to configure an application for diffenent encryption strengths.
    	</description>
        <param-name>org.apache.myfaces.SECRET</param-name>
        <param-value>NzY1NDMyMTA=</param-value>
    </context-param>
    
    <context-param>
  		<description>
  			Validate managed beans, navigation rules and ensure that forms are not nested.
  		</description>
       	<param-name>org.apache.myfaces.VALIDATE</param-name>
       	<param-value>true</param-value>
    </context-param>
    
  	<context-param>
    	<description>
    		A class implementing the org.apache.myfaces.shared.renderkit.html.util.AddResource
		    interface. It is responsible to place scripts and css on the right position in your HTML document.
            Default: "org.apache.myfaces.shared.renderkit.html.util.DefaultAddResource"
            Follow the description on the MyFaces-Wiki-Performance page to enable
            StreamingAddResource instead of DefaultAddResource if you want to
            gain performance.
    	</description>
    	<param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>
    	<param-value>org.apache.myfaces.renderkit.html.util.DefaultAddResource</param-value>
    	<!--param-value>org.apache.myfaces.component.html.util.StreamingAddResource</param-value-->
  	</context-param>

  	<context-param>
    	<description>
	        A very common problem in configuring MyFaces-web-applications
	        is that the Extensions-Filter is not configured at all
	        or improperly configured. This parameter will check for a properly
	        configured Extensions-Filter if it is needed by the web-app.
	        In most cases this check will work just fine, there might be cases
	        where an internal forward will bypass the Extensions-Filter and the check
	        will not work. If this is the case, you can disable the check by setting
	        this parameter to false.
    	</description>
    	<param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
    	<param-value>true</param-value>
  	</context-param>

  	<filter>
    	<filter-name>extensionsFilter</filter-name>
    	<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
    	<init-param>
	      	<description>
	      		Set the size limit for uploaded files.
                Format: 10 - 10 bytes
                        10k - 10 KB
                        10m - 10 MB
                        1g - 1 GB
	        </description>
	      	<param-name>uploadMaxFileSize</param-name>
	      	<param-value>100m</param-value>
    	</init-param>
    	
    	<init-param>
	      	<description>
	      		Set the threshold size - files
	            below this limit are stored in memory, files above
	            this limit are stored on disk.
	
	            Format: 10 - 10 bytes
	                    10k - 10 KB
	                    10m - 10 MB
	                    1g - 1 GB
	        </description>
	      	<param-name>uploadThresholdSize</param-name>
	      	<param-value>100k</param-value>
    	</init-param>
  	</filter>
  	
  	<!-- filter>
		<display-name>Ajax4jsf Filter</display-name>
		<filter-name>ajax4jsf</filter-name>
		<filter-class>org.ajax4jsf.Filter</filter-class>
	</filter -->
	
	<filter>
		<filter-name>sessionInView</filter-name>
		<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
	</filter>
	
	<filter>
		<filter-name>extensionFilter</filter-name>
		<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
	</filter>
	
	<filter>
		<filter-name>requestContextFilter</filter-name>
		<filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
	</filter>
	
	<filter>
		<filter-name>multipartFilter</filter-name>
		<filter-class>org.apache.myfaces.component.html.util.MultipartFilter</filter-class>
	</filter>
  
  	<filter-mapping>
		<filter-name>extensionFilter</filter-name>
		<url-pattern>/faces/*</url-pattern>
	</filter-mapping>
	
  	<filter-mapping>
    	<filter-name>extensionsFilter</filter-name>
    	<url-pattern>*.faces</url-pattern>
  	</filter-mapping>
  	
  	<filter-mapping>
		<filter-name>sessionInView</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	
	<filter-mapping>
		<filter-name>requestContextFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	
	<!-- filter-mapping>
		<filter-name>ajax4jsf</filter-name>
		<url-pattern>*.faces</url-pattern>
	</filter-mapping -->
	
	<filter-mapping>
		<filter-name>multipartFilter</filter-name>
		<servlet-name>Faces Servlet</servlet-name>
	</filter-mapping>
	
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	
	<listener>
    	<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
  	</listener>
  
  	<servlet>
		<servlet-name>Faces Servlet</servlet-name>
		<servlet-class>org.apache.myfaces.webapp.MyFacesServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
	
	<!-- servlet>
		<servlet-name>dispatcher</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextClass</param-name>
			<param-value>net.java.dev.springannotation.utils.FakeWebApplicationContext</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet -->
	
  	<servlet-mapping>
    	<servlet-name>Faces Servlet</servlet-name>
    	<url-pattern>*.faces</url-pattern>
  	</servlet-mapping>
  	
  	<!-- servlet-mapping>
		<servlet-name>dispatcher</servlet-name>
		<url-pattern>*.do</url-pattern>
	</servlet-mapping -->  	
  	
  	<welcome-file-list>
    	<welcome-file>index.jsp</welcome-file>
  	</welcome-file-list>
</web-app>
web.xml
#-- PAIS --#
pais.nome = Nome
pais.sigla = Sigla
pais.titulo = País
teste = t
#-- USUARIO -- #
usuario.dtaCadastro = Data de cadastro
usuario.grupo = Grupo
usuario.login = Login
usuario.senha = Senha
usuario.titulo = Usuário

#-- GRUPO -- #
grupo = Nome
grupo.titulo = Grupo

#-- MODULO -- #
modulo.nome = Nome
modulo.titulo = Módulo

#-- PAGINA -- #
pagina.modulo = Módulo
pagina.nome = Nome
pagina.titulo = Página
pagina.url = URL

#-- FUNCAO -- #
funcao.nome = Nome
funcao.titulo = Função

#-- GRUPO_MODULO -- #
grupoModulo.grupo = Grupo
grupoModulo.modulo = Módulo
grupoModulo.titulo = Grupo / Módulo

#-- PAGINA_FUNCAO -- #
paginaFuncao.funcao = Função
paginaFuncao.grupo = Grupo
paginaFuncao.modulo = Módulo
paginaFuncao.pagina = Página
paginaFuncao.titulo = Página / Função
labels.properties
Criado 2 de julho de 2007
Respostas 0
Participantes 1