Skip to content

Commit

Permalink
Merge pull request jboss#3 from AnghelLeonard/master
Browse files Browse the repository at this point in the history
  • Loading branch information
arjantijms authored Aug 10, 2016
2 parents a47259a + 10f761d commit db370d0
Show file tree
Hide file tree
Showing 32 changed files with 439 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -590,6 +590,13 @@ ResourceInfo findResource(String resourceId) {
private String getLocalePrefix(FacesContext context) {

String localePrefix = null;

localePrefix = context.getExternalContext().getRequestParameterMap().get("loc");

if(localePrefix != null){
return localePrefix;
}

String appBundleName = context.getApplication().getMessageBundle();
if (null != appBundleName) {

Expand Down
67 changes: 67 additions & 0 deletions test/javaee8/localizedResources/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common Development
and Distribution License("CDDL") (collectively, the "License"). You
may not use this file except in compliance with the License. You can
obtain a copy of the License at
https://glassfish.java.net/public/CDDL+GPL_1_1.html
or packager/legal/LICENSE.txt. See the License for the specific
language governing permissions and limitations under the License.
When distributing the software, include this License Header Notice in each
file and include the License file at packager/legal/LICENSE.txt.
GPL Classpath Exception:
Oracle designates this particular file as subject to the "Classpath"
exception as provided by Oracle in the GPL Version 2 section of the License
file that accompanied this code.
Modifications:
If applicable, add the following below the License Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyright [year] [name of copyright owner]"
Contributor(s):
If you wish your version of this file to be governed by only the CDDL or
only the GPL Version 2, indicate your decision by adding "[Contributor]
elects to include this software in this distribution under the [CDDL or GPL
Version 2] license." If you don't indicate a single choice of license, a
recipient has the option to distribute your version of this file under
either the CDDL, the GPL Version 2 or to extend the choice of license to
its licensees as provided above. However, if you add GPL Version 2 code
and therefore, elected the GPL Version 2 license, then the option applies
only if the new code is made subject to such option by the copyright
holder.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.sun.faces.test.javaee8</groupId>
<artifactId>pom</artifactId>
<version>2.3.0-m07-SNAPSHOT</version>
</parent>

<artifactId>LocalizedResources</artifactId>
<packaging>war</packaging>

<name>Mojarra ${project.version} - Test - JavaEE 8 - localized resources</name>

<build>
<finalName>test-javaee8-localized-resources</finalName>
</build>

<properties>
<netbeans.hint.deploy.server>gfv3ee6</netbeans.hint.deploy.server>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package com.sun.faces.test.javaee8.localizedResources;

import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

@Named
@RequestScoped
public class LocalizedResourceBean {

private static final long serialVersionUID = 1544275452223321526L;

private String mylocale = "en";

public String getMylocale() {
return mylocale;
}

public void changeMyLocale(String mylocale) {
this.mylocale = mylocale;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
javax.faces.resource.localePrefix=au
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
javax.faces.resource.localePrefix=en
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
javax.faces.resource.localePrefix=fr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
javax.faces.resource.localePrefix=us
28 changes: 28 additions & 0 deletions test/javaee8/localizedResources/src/main/webapp/Issue4082.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?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">
<h:head>
<title>JSF 2.3 localized resources test</title>

<h:outputStylesheet library="default" name="css/rafa.css"/>
<h:outputScript library="default" name="rafa.js"/>
</h:head>
<h:body>
<f:view locale="#{localizedResourceBean.mylocale}">
<div style="width:100%; text-align:center">
<h:form id="atp">
<h:commandButton id="rg" value="Rafa at Roland Garros" action="#{localizedResourceBean.changeMyLocale('fr')}"/>
<h:commandButton id="wo" value="Rafa at Wimbledon" action="#{localizedResourceBean.changeMyLocale('en')}"/>
<h:commandButton id="us" value="Rafa at US Open" action="#{localizedResourceBean.changeMyLocale('us')}"/>
<h:commandButton id="au" value="Rafa at Australian Open" action="#{localizedResourceBean.changeMyLocale('au')}"/>
</h:form>
</div>
<div style="width:100%; text-align:center">
<h:graphicImage library="default" name="img/rafa.png"/>
</div>
</f:view>
</h:body>
</html>

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans 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/beans_1_1.xsd"
bean-discovery-mode="all"
version="1.1">
</beans>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version='1.0' encoding='UTF-8'?>

<faces-config 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-facesconfig_2_3.xsd"
version="2.3">

<application>
<locale-config>
<default-locale>en</default-locale>
<supported-locale>fr</supported-locale>
<supported-locale>en</supported-locale>
<supported-locale>au</supported-locale>
<supported-locale>us</supported-locale>
</locale-config>
<message-bundle>
<base-name>players.msgs.PlayerMessages</base-name>
</message-bundle>
</application>
</faces-config>
39 changes: 39 additions & 0 deletions test/javaee8/localizedResources/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?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>${webapp.projectStage}</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
<param-value>${webapp.partialStateSaving}</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>${webapp.stateSavingMethod}</param-value>
</context-param>
<context-param>
<param-name>javax.faces.SERIALIZE_SERVER_STATE</param-name>
<param-value>${webapp.serializeServerState}</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>
</web-app>
13 changes: 13 additions & 0 deletions test/javaee8/localizedResources/src/main/webapp/index.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?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">
<h:head>
<title>Localized resources tests</title>
</h:head>
<h:body>
<h1>Localized resources tests</h1>
<a id="4082" href="faces/Issue4082.xhtml">Issue4082</a> <br/>
</h:body>
</html>

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body {
background-image: url('#{resource["default:img/bk.png"]}');
background-repeat:repeat-y;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
alert("I won Australian Open ...(resources/au/1_0/css/js/rafa.js/1_0.js)");


Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body {
background-image: url('#{resource["default:img/bk.png"]}');
background-repeat:repeat-y;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
alert("I hope to win Wimbledon ...(resources/en/1_0/css/js/rafa.js/1_0.js)");


Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
alert("I won Wimbledon ...(resources/en/1_0/css/js/rafa.js/1_1.js)");


Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body {
background-image: url('#{resource["default:img/bk.png"]}');
background-repeat:repeat-y;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
alert("J'espère gagner Roland Garros ...(resources/fr/1_0/css/js/rafa.js/1_0.js)");


Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
alert("Je suis en finale Roland Garros ...(resources/fr/1_0/css/js/rafa.js/1_1.js)");


Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
alert("J'ai gagné Roland Garros ...(resources/fr/1_0/css/js/rafa.js/1_2.js)");


Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body {
background-image: url('#{resource["default:img/bk.png"]}');
background-repeat:repeat-y;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
alert("I won US Open ...(resources/us/1_0/css/js/rafa.js/1_0.js)");


Loading

0 comments on commit db370d0

Please sign in to comment.