Sat. Dec 4th, 2021

Requirement: I have a demo.jsf page. In that page I have two links to change the language (English or French). I have two buttons on demo.jsf page. The buttons are Search button and Cancel button. Initially when demo.jsf page loads, only one link will be rendered, say French. The text on the link should be French and the text on the buttons should be Search and Cancel. When I click on the link French, the link with text as English should be rendered, and the text in the Search button should change to recherche, and the text in the Cancel button should change to annuler. If we again click on the link, it should change the language again that is the text of the buttons and render the link with French text.

Information: Internationalization is the process of designing and developing products for easy adaptation to specific local languages and cultures. Localization is the process of adapting a product for a specific local language or culture by translating text and adding locale-specific components. A successfully localized application will appear to have been developed within the local culture. JDeveloper supports easy localization of ADF Faces components using the abstract class java.util.ResourceBundle to provide locale-specific resources.

Solution: For solution of the above requirement follow the below steps:

Step 1: Create an Oracle ADF Fusion Web Application.

Step 2: Create a demo.jsf page in the ViewController project of our application created in Step 1.

Step 3: Drag and drop two af:link, two af:button from the component palette in the demo.jsf page created in Step 2.

Step 4: Create two resource bundles named as resourceBundle.properties and resourceBundle_fr.properties.

Step 5: Register the resourceBundle.properties in the faces-config.xml file. Open the faces-config.xml file > Overview > Application > Click the green (+) icon of the resource bundle. Give the Base Name as resourceBundle.properties and Var Name as res. Give Default Locale as en. Give Supported Locale as en, fr as shown below:

Step 6: Go to the demo.jsf page. Give the text for the af:links and af:buttons. The text should be picked from the resourceBundles that is from resourceBundle.properties and resourceBundle_fr.properties.

Thus the text in the resourceBundle.properties and resourceBundle_fr.properties are as below:

Text in resourceBundle.properties is shown below:

Text in resourceBundle_fr.properties is shown below:

Step 7: Set the rendered properties and actionListener of both the af:link. Thus, the complete demo.jsf code is shown below:

Step 8: Inside the LangaugeBean.java write the codes for each of the actionListener. Thus, the complete LanguageBean.java code is as below:

Step 9: Save and Run the application. The, ran application is shown below:

On Click of French link the text the link changes to English, the text on the Search button changes to recherche and the text on the Cancel button changes to annuler as shown below:

Again, on Click of English link the text gets changed.

Hence, the solution to our requirement.

If you like the post please comment, share, and do join me on Facebook. Please subscribe to my YouTube Channel for video tutorials.

Thanks & Regards,
Susanto Paul

 482 total views,  3 views today

By Susanto Paul

Susanto is an Oracle ACE, a qualified MCA, MBA, and a highly-skilled Senior Oracle Specialist. He is an enthusiastic Blogger and YouTuber who helps learners to solve their complex problems more efficiently. He has 9+ years of experience in multiple technologies like AWS, Oracle ADF, Oracle APEX, Oracle JET, Oracle VBCS, Oracle IDCS, Oracle PL/SQL, Oracle Integration Cloud, Java, JDBC, Servlets, JSP, Spring, Hibernate, HTML5, CSS3, JavaScript, TypeScript, NodesJS, Angular, MySQL, Oracle WebLogic Server, JUnit, JMeter, Selenium Web Driver, etc. He is a certified: Oracle Certified Professional Java SE 6 Programmer, Oracle ADF 11g Certified Implementation Specialist, Oracle Cloud Platform Application Integration 2020 Certified Specialist, Oracle Cloud Infrastructure Foundations 2020 Certified Associate, and Oracle Cloud Infrastructure Developer 2020 Certified Associate

Leave a Reply

Your email address will not be published. Required fields are marked *

satta king chart