Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1721 #1889

Merged
merged 6 commits into from
Feb 14, 2024
Merged

1721 #1889

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions tck/faces23/localized-composite/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2022 Contributors to the Eclipse Foundation.
Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.

SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0

-->

<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>org.eclipse.ee4j.tck.faces.faces23</groupId>
<artifactId>pom</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>

<artifactId>localized-composite</artifactId>
<packaging>war</packaging>

<name>Jakarta Faces TCK ${project.version} - Test - Faces 2.3 - localized-composite</name>
<description>Composite .properties l10n files should reflect current locale when using resourceBundleMap.</description>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package ee.jakarta.tck.faces.test.composite;

import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.SessionScoped;
import jakarta.faces.component.UIViewRoot;
import jakarta.faces.context.FacesContext;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import jakarta.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.util.Locale;

@Named
@SessionScoped
public class LocaleBean implements Serializable {

@Inject
private HttpServletRequest request;

private Locale locale;

private String language;

@PostConstruct
public void init() {
Locale requestLocale = request.getLocale();
setLocale(requestLocale != null ? requestLocale.toString() : "en");
}

private void setLocale(String languageTag) {
String[] chunks = languageTag.split("(-|_)");
switch (chunks.length) {
case 1:
locale = new Locale(chunks[0]);
break;
case 2:
locale = new Locale(chunks[0], chunks[1]);
break;
default:
locale = new Locale(chunks[0], chunks[1], chunks[2]);
break;
}
language = locale.toString();
UIViewRoot root = FacesContext.getCurrentInstance().getViewRoot();
if (root != null) {
root.setLocale(locale);
}
}

public Locale getLocale() {
return locale;
}

public String getLanguage() {
return language;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
appheader=Application
buttonvalue=My precious button
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
appheader=Aplicaci\u00f3n
buttonvalue=Mi precioso bot\u00f3n
25 changes: 25 additions & 0 deletions tck/faces23/localized-composite/src/main/webapp/WEB-INF/beans.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2022 Contributors to the Eclipse Foundation.
Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.

SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0

-->

<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,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2022 Contributors to the Eclipse Foundation.
Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.

SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0

-->

<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>es</supported-locale>
<supported-locale>pt</supported-locale>
<supported-locale>pt_BR</supported-locale>
<supported-locale>pt_BR_PB</supported-locale>
</locale-config>
<resource-bundle>
<base-name>locale.messages</base-name>
<var>msgs</var>
</resource-bundle>
</application>
</faces-config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<!--
Copyright (c) 2022 Contributors to the Eclipse Foundation.
Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.

SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0

-->

<glassfish-web-app error-url="">
<context-root>/localized-composite</context-root>
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
</glassfish-web-app>
55 changes: 55 additions & 0 deletions tck/faces23/localized-composite/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2022 Contributors to the Eclipse Foundation.
Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.

SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0

-->

<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>jakarta.faces.PROJECT_STAGE</param-name>
<param-value>${webapp.projectStage}</param-value>
</context-param>
<context-param>
<param-name>jakarta.faces.PARTIAL_STATE_SAVING</param-name>
<param-value>${webapp.partialStateSaving}</param-value>
</context-param>
<context-param>
<param-name>jakarta.faces.STATE_SAVING_METHOD</param-name>
<param-value>${webapp.stateSavingMethod}</param-value>
</context-param>
<context-param>
<param-name>jakarta.faces.SERIALIZE_SERVER_STATE</param-name>
<param-value>${webapp.serializeServerState}</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>localized-composite.xhtml</welcome-file>
</welcome-file-list>
</web-app>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<!--
Copyright (c) 2022 Contributors to the Eclipse Foundation.
Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.

SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0

-->

<html xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:comp="http://xmlns.jcp.org/jsf/composite/comps">
<f:view locale="#{localeBean.language}">
<h:head id="head">
<title>JSF 2.3 Localized Composite</title>
</h:head>
<h:body>
<h1 id="header">#{msgs.appheader}</h1>
<h:form id="frm">
<h:commandButton id="btn" value="#{msgs.buttonvalue}"/>
<comp:button id="btn1"/>
</h:form>
</h:body>
</f:view>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
btnvalue=Button

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--
Copyright (c) 2022 Contributors to the Eclipse Foundation.
Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.

SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0

-->

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:cc="http://xmlns.jcp.org/jsf/composite"
xmlns:h="http://xmlns.jcp.org/jsf/html">

<cc:interface>
</cc:interface>

<cc:implementation>
<h:commandButton id="btn" value="#{cc.resourceBundleMap.btnvalue}"/>
</cc:implementation>

</ui:composition>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
btnvalue=Bot\u00f3n

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
btnvalue=Accionador

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
btnvalue=Bot\u00e3o

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
btnvalue=Pitoco

Loading