Monday, May 20, 2013

ADF Essentials talk and Packt Giveaway

Hello all. Next Saturday (25-May-2013) I'll be speaking about ADF Essentials at the Cali (CLO) Java User Group in Colombia. It's a great opportunity to meet the framework and watch it in action.

I'll be running a giveaway that day. Packt Publishing is sponsoring 3 e-copies of the Oracle ADF 11gR2 Development Beginner's Guide. This is a great resource and a must if you are starting in the ADF world. 

Here is what you need to do in order to enter the giveaway:

  1. Follow me on twitter: @aa_lopez
  2. Write a comment on this post explaining why you want to win a copy.
  3. Attend, in person, to my talk at CLOJUG on May 25th 2013 (RSVP required).

I'll be announcing the 3 winners during the session. Meeting the steps above is mandatory and originality in the comment is a plus.

For more information about the e-book: 

For more information about the Cali (CLO) Java User Group:

For more information about my talk:


see ya!

Monday, May 6, 2013

ADF Essentials: Logger level

Hello all.  Here is a small tip that can help you when debugging your ADF Essentials applications. Turns out that when you run your ViewController project, you get some messages on the console panel as shown in the following picture:



However, some times you need more information about what the framework is doing in order to solve bugs, improve performance or just debugging. In order to get detailed information, follow these steps:

1. Go to the ViewController project Project properties option:



2. A dialog pops up, select, on the left, the category Run/Debug/Profile, select the Default configuration (or the configuration you use to run the application) and click on the Edit button:



3. Another dialog pops up, pay attention to the Java Options text box, the options you enter here are going to be used by the JVM once the application is running:



4. Enter the following options in the Java Options text box:

-Djbo.debugoutput=console -Djbo.adflogger.level=FINE


5. At the end, you should end with something like this:



Press the OK button and the next time you run your application, the console panel will show a lot more information,  you can even see the queries that are being executed:



OK, that's it for this post, hopefully, with this configuration you will find more information that will let you fix your bugs or improve the performance of your application.

see ya!

Sunday, April 28, 2013

CLOJUG - April 2013

Hello all! This is a small update about what we did at the Cali (CLO) Java User Group - CLOJUG during April 2013.

This month we had two meetings instead of one. The reason? Arun Gupta shared with us the new Java EE 7 libraries through a google+ hangout. We met on April 15th 2013 at one of our sponsor's facilities, Universidad Icesi, and hanged out with Arun. Questions were asked and had a great time with all the new APIs. Arun showed us some code and pointed out several ways to get involved. Here are some pictures of this event:



On our second meeting, April 27th 2013, at Universidad del Valle, we had Guido Granobles speaking about "Developing a High-Availability distributed system with Java EE 6 and JBoss AS 7". He showed us a step by step tutorial about how you can develop such systems. Really impressive! well done Guido!

Stay tuned for our events and if you live in Cali-Colombia, come to our meetings and become a member of our great community! http://www.clojug.org/

see ya

Thursday, March 28, 2013

Glassfish plugin for JDeveloper 11gR2

Hello, all. As some of you already know, ADF Essentials is a great framework for building web applications using java and it is free to develop and free to deploy. You deploy ADF Essentials applications on Glassfish (3.1+) server. Nevertheless, JDeveloper does not come with an embedded Glassfish server but with an embedded Weblogic server.

In this post, we are going to talk about when to use the integrated Weblogic server and when you should use an external Glassfish server during your ADF Essentials application development.

What you need

Once you have installed the above software, you may start creating your ADF Essentials applications. There are tons of documentation online: books, tutorials and videos to help you. My recommendation is try to use the integrated Weblogic server during development so you can debug and run your applications right from JDeveloper. When you finish developing some functionality, test your development on Glassfish server, at the end, if you are developing an ADF Essentials applications this is the application server you are most likely to use in a production environment. Make sure you have configured your Glassfish server for ADF Essentials applications as described here:


The version of JDeveloper you installed, comes with a built in functionality to deploy your applications to Glassfish server. However, you have to start the server before you can deploy your applications. One way to do it is to use the Glassfish server controls (they are installed once you install Glassfish) outside of JDeveloper.
My recommended way is to use the Glassfish plugin for JDeveloper so you can start/stop Glassfish server right from the IDE! The plugin was created by Shay Shmeltzer and the version 1.3 has been modified to run on Linux (thx to me, @aa_lopez) and to run on Mac (thx to David Aroca).

The plugin can be found at help->check for updates. More information here:
https://blogs.oracle.com/shay/entry/glassfish_extension_for_oracle_jdeveloper

If you want to make contributions to the source code, you can find the project at java.net:
http://java.net/projects/jdev-3rd-party-ext/sources/svn-repository/show

Once you have installed the plugin, your JDeveloper presents four new buttons:



From left to right:
  • The first one lets you start the Glassfish server.
  • The second one lets you stop Glassfish server.
  • The third one starts Glassfish server in debug mode.
  • The fourth one starts the Glassfish server web console app.

Before you can start using these new buttons, you have to configure the paths to the Glassfish server. To do this, go to Tools->Preferences and select the Glassfish Preferences:



The plugin comes with Windows OS paths by default. So if you are using Linux or Mac, you have to change these paths in order to have the plugin buttons working. In my case, I'm using Linux, so I changed the paths to match the paths where I installed my Glassfish server.
Note: I had to add the --verbose option to the start command, otherwise, Glassfish starts and stops immediately.

Glassfish Home Directory: /home/aalopez/development/glassfish-3.1.2.2/

Start Glassfish Command: /home/aalopez/development/glassfish-3.1.2.2/glassfish/bin/asadmin start-domain --verbose domain1

Stop Glassfish Command: /home/aalopez/development/glassfish-3.1.2.2/glassfish/bin/asadmin stop-domain domain1

Start Glassfish in Debug Mode Command: /home/aalopez/development/glassfish-3.1.2.2/glassfish/bin/asadmin start-domain --debug=true

Glassfish Admin URL: http://localhost:4848

Once you finish the configuration, you are ready to start using Glassfish server from JDeveloper, just don't close the window that pops up when you hit the "Start Glassfish" button.


How to deal with data sources between Weblogic and Glassfish servers?
When you are working with the integrated Weblogic server, JDeveloper creates a data source to access the database. This data source has the following structure:

java:comp/env/jdbc/DATASOURCE_NAME

Where DATASOURCE_NAME is the name you gave to the data source when configuring the connection to the data base. The problem is that Glassfish server uses another structure. When you define a data source in the Glassfish server web console app, you define it like this:

jdbc/DATASOURCE_NAME

If you keep running your application using Weblogic and Glassfish servers, I recommend the following configuration, so you don't have to manually change the data source structure every time you change the application server:

Define the resource at Web Content/WEB­INF/web.xml

<resource-ref>
   <res-ref-name>jdbc/DATASOURCE_NAME</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <res-auth>Container</res-auth>
   <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

As stated by the Java EE web-app deployment descriptor version 2.5:

The res-ref-name element specifies the name of a
resource manager connection factory reference.  The name
is a JNDI name relative to the java:comp/env context.
The name must be unique within a web application.

So we are not defining what to do with jdbc/DATASOURCE_NAME but we are actually defining   java:comp/env/jdbc/DATASOURCE_NAME which matches exactly the data source structure configured in the application and used by Weblogic server.

This is actually a good practice, since at development time you don't have to worry about what is going to be the structure or name of the data source at deployment time. You just define, in the web.xml deployment descriptor, the structure or name of the data source and the deployer (yes, the person who makes the deployment) can map that structure or name to something else. This is done in a container-specific configuration file, as we shall see next.

Create the glassfish-web.xml configuration file. Right click on the Web Content/WEB-INF folder and select the New... option:




A window pops up, select the General category and then choose the File option:



Enter the name of the file as glassfish-web.xml and make sure the path to this new file is inside the WEB-INF folder:



Once the file is created, open it and enter the following code:

<?xml version="1.0" encoding="UTF-8" ?>
<glassfish-web-app>
    <context-root>YOUR_APP_NAME</context-root>
    <property name="useBundledJsf" value="true"/>
    <class-loader delegate="false"/>
    <resource-ref>
        <res-ref-name>java:comp/env/jdbc/DATASOURCE_NAME</res-ref-name>
        <jndi-name>jdbc/DATASOURCE_NAME_AT_GLASSFISH</jndi-name>
    </resource-ref>
</glassfish-web-app>

Here I copied the configuration that JDeveloper adds to the glassfish-web.xml file at deployment time. I also added the configuration that let us map the data sources. The resource-ref element is what we are going to focus on this post.
Change DATASOURCE_NAME for the name you defined for your data source in the web.xml deployment descriptor and DATASOURCE_NAME_AT_GLASSFISH for the name you defined in the Glassfish Web console app.

How it works:
  1. We defined the data source as a resource in the web.xml deployment descriptor. Remember that we are using the structure jdbc/DATASOURCE_NAME but what it really means is that we are using java:comp/env/jdbc/DATASOURCE_NAME
  2. We created the glassfish-web.xml deployment descriptor. This is a container-specific configuration file and is created automatically by JDeveloper when you deploy to a Glassfish server. However, if the file already exists it is not overridden  Here we mapped the data sources definitions so we are telling Glassfish that when we are looking for java:comp/env/jdbc/DATASOURCE_NAME in our application, what we really mean is that we are looking for jdbc/DATASOURCE_NAME in the Glassfish server.

That's it. With this configuration you don't have to worry about the data source configuration differences between Weblogic and Glassfish servers. Happy ADF Essentials coding.

see ya!


References:

Oracle ADF Essentials. Oracle [online].
Available on Internet: http://www.oracle.com/technetwork/developer-tools/adf/overview/adfessentials-1719844.html
[accessed on March 24 2013].

Deploying ADF Applications to GlassFish. Oracle [online].
Available on Internet: http://docs.oracle.com/cd/E35521_01/web.111230/e16182/appendix_glassfish.htm#CEGDIGEE
[accessed on March 28 2013].

Java EE: XML Schemas for Java EE Deployment Descriptors. Oracle [online].
Available on Internet: http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/index.html#5
[accessed on March 28 2013].

What is resource-ref in web.xml used for?. Oracle [online].
Available on Internet: http://stackoverflow.com/questions/2887967/what-is-resource-ref-in-web-xml-used-for/2888169#2888169
[accessed on March 28 2013].

Friday, March 22, 2013

CLOJUG - March 2013

Hello all! This is a small update about what we are working on at the Cali (CLO) Java User Group - CLOJUG. As I've mentioned before, we started a web site using the meetup.com platform, so all our events are scheduled using this platform and members are encourage to make their RSVPs. Visit www.clojug.org for more information.

During this month (March 2013) we had our first meeting with new members, where we introduced them to the Java User Group's proposal and presented them three conferences: Java 6<7<8 by @aa_lopez, i18n in JSF 2 and Log4J2 by @daviaroc and Service distributed applications using JavaEE 6 and JBoss AS 7 by @guidogranobles

On the left you can see how the group looked like two months ago. On the right, you can see how it looks now :)





We even have a logo now! It is inspired by one of the iconic monument of our city called "statue of Sebastián de Belalcázar", founder of our city: Santiago de Cali (CLO).





What do you think about our logo? cool, right? 

We are now preparing our meeting for the next month (April 2013), but before, we are going to have an extraordinary meeting where we''ll be hanging out with Arun Gupta about Java EE 7:



So, stay tuned for our events and if you live in Cali-Colombia, come to our meetings and become a member of our great community!

see ya

Thursday, March 7, 2013

JDeveloper 11gR2 - Integrated Weblogic Server Password Reset

Hello everyone. After months of working with ADF Essentials, I needed to log in to the Console application of the integrated Weblogic Server that comes with JDeveloper 11.1.2.3 (Weblogic Server 10.3.5) and then I realized that I have forgotten the password of the weblogic user... So I started looking and found two solutions:
  1. Solution 1: Remove the default domain folder created by the Integrated Weblogic Server.
  2. Solution 2: Generate a new password for the weblogic user. 
What's the difference between solution 1 and 2?
In solution 1, you will lose any configuration you have made to your integrated weblogic server, this includes: data sources, security configuration, etc.
In solution 2, you will lose only security configurations you have made. For example, if you have created more users, or groups, or configured access to an external LDAP service, but will keep everything else. I have to say that this solution is more difficult than solution 1.

If you have not made any configurations to your integrated Weblogic server, I suggest you to go with solution 1. 

Before we continue with the solutions, we first need to find the IDE system directory. In order to do that, open JDeveloper, go to the Help menu and select the About option. A popup shows up, select the Properties tab and scroll down until you find any of  these: ide.pref.dir or ide.system.dir or ide.user.dir 

In a Linux environment, you may find something like this:



In a windows environment, you may find something like this:



Actually, the dir we are looking for is the ide.system.dir so lets write it down so we can use it later:

Linux (my case, yours may be different)
SYS_DIR=/home/aalopez/.jdeveloper/system.11.1.2.3.39.62.76.1

Windows (my case, yours may be different)
SYS_DIR=C:\Users\CVDESA\AppData\Roaming\JDeveloper\system11.1.2.3.39.62.76.1

Make sure Weblogic server is shut down before you continue.


Solution 1: Removing the DefaultDomain folder
The first and easiest solution is to Remove the following folder (DefaultDomain):
SYS_DIR/DefaultDomain

The folder will get re-created for you the next time you start the Weblogic server. The problem is that you will lose any configuration you may have done including: users, passwords, datasources, etc. All of it.
Once you remove the folder, open JDeveloper go to the Run menu, and select the Start Server Instance (IntegratedWeblogicServer) option. A popup shows up asking you to set the weblogic user credentials. That's it!

Solution 2: Reset the weblogic user password
Please follow the next steps in order reset the password in a Linux system (Ubuntu 12.1), steps for Windows system are also presented:

Linux
  1. Go to this path: SYS_DIR/DefaultDomain/bin, where SYS_DIR is the path we defined above.
  2. Execute the setDomainEnvironment.sh
  3. Go to this path: SYS_DIR/DefaultDomain/security
  4. Rename the DefaultAuthenticatorInit.ldift file to something like oldDefaultAuthenticatorInit.ldift
  5. Export the weblogic.jar file to the classpath, so we can create a new password for the weblogic user (in my case, the installation directory of JDeveloper is /home/aalopez/Oracle):
  6. export CLASSPATH=$CLASSPATH:/home/aalopez/Oracle/Middleware/wlserver_10.3/server/lib/weblogic.jar
  7. Execute the following command in order to create the new password. Notice that the command has a dot at the end, this is necessary so the new password is created in the current directory. Change NEW_PASSSWORD for the new password of the weblogic user:
  8. java weblogic.security.utils.AdminAccount weblogic NEW_PASSWORD .
  9. Go to this path: SYS_DIR/DefaultDomain/servers/DefaultServer
  10. Rename the data directory to something like data_old
  11. Go to this path: SYS_DIR/DefaultDomain/servers/DefaultServer/security
  12. Rename the boot.properties file to something like oldboot.properties
  13. Create a new boot.properties file in the same directory. This is necessary if you want autologin when launching the Weblogic server from within JDeveloper. The content of the file should be something like the following (change NEW_PASSWORD for the password you defined in previous steps):
  14. username=weblogic
    password=NEW_PASSWORD
  15. It's time to test our changes. Go to this path: SYS_DIR/DefaultDomain/bin
  16. Execute the startWeblogic.sh file and verify that Weblogic server starts without exceptions.
  17. Open a new browser and enter the following URL (the port may be different for you):
  18. http://localhost:7101/console
  19. The Weblogic server console application should display and you can login with your new credentials.
  20. When you are ready to stop the Weblogic server, go to this path: SYS_DIR/DefaultDomain/bin
  21. Execute the stopWeblogic.sh file in order to stop the server.

There's one extra step that we'll cover after we check the Windows steps:


Windows

  1. Go to this path: SYS_DIR\DefaultDomain\bin, where SYS_DIR is the path we defined above.
  2. Execute the setDomainEnvironment.cmd
  3. Go to this path: SYS_DIR\DefaultDomain\security
  4. Rename the DefaultAuthenticatorInit.ldift file to something like oldDefaultAuthenticatorInit.ldift
  5. Execute the following command in order to create the new password. Notice that the command has a dot at the end, this is necessary so the new password is created in the current directory. Change NEW_PASSSWORD for the new password of the weblogic user:
  6. java weblogic.security.utils.AdminAccount weblogic NEW_PASSWORD .
  7. Go to this path: SYS_DIR\DefaultDomain\servers\DefaultServer
  8. Rename the data directory to something like data_old
  9. Go to this path: SYS_DIR\DefaultDomain\servers\DefaultServer\security
  10. Rename the boot.properties file to something like oldboot.properties
  11. Create a new boot.properties file in the same directory. This is necessary if you want autologin when launching the Weblogic server from within JDeveloper. The content of the file should be something like the following (change NEW_PASSWORD for the password you defined in previous steps):
  12. username=weblogic
    password=NEW_PASSWORD
  13. It's time to test our changes. Go to this path: SYS_DIR\DefaultDomain\bin
  14. Execute the startWeblogic.cmd file and verify that Weblogic server starts without exceptions.
  15. Open a new browser and enter the following URL (the port may be different for you):
  16. http://localhost:7101/console
  17. The Weblogic server console application should display and you can login with your new credentials.
  18. When you are ready to stop the Weblogic server, go to this path: SYS_DIR\DefaultDomain\bin
  19. Execute the stopWeblogic.cmd file in order to stop the server.


Once you have changed and tested the new password for the weblogic user, is time to update the information in JDeveloper. Open JDeveloper and go to the Resource Palette, if you can't find it, go to the View menu and select the Resource Palette option:




There, select the Application Server category and the IntegratedWebLogicServer. Right click and select the Properties option. A new popup shows up, select the Authentication tab:



There you can set the new weblogic user password that you just defined steps above. Apply changes and that's it!


see ya,


References:

Reset lost weblogic admin password | Beyond Oracle. João Oliveira [online].
Available on Internet: http://www.beyondoracle.com/2010/08/30/reset-lost-weblogic-admin-password/
[accessed on March 02 2013].

Enabling Auto Login by Using the Boot Identity File. Oracle [online].
Available on Internet: http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/wls/10g/r3/installconfig/enable...
[accessed on March 02 2013].

Changing DefaultServer's Password running in JDeveloper. Brenda [online].
Available on Internet: http://newsoalife.blogspot.com/2011/07/changing-defaultservers-password.html
[accessed on March 04 2013].

OTN Discussion Forums. Oracle [online].
Available on Internet: https://forums.oracle.com/forums/thread.jspa?threadID=2285290
[accessed on March 07 2013].

Tuesday, February 26, 2013

CLOJUG - Second Meeting

Hello all. CLOJUG is moving forward, we have created the project in java.net and we are now  requesting to move the project from private to public. We also have our group created in the meetup.com platform so we can leverage in all the features that this platform has to offer. 

You can join our group at www.clojug.com to stay tuned for our upcoming meetings. Join us if you live in Cali-Colombia and want to share your knowledge and learn from other Java Lovers.


FAQ
What is CLOJUG?
CLO is our city code and JUG stands for Java Users Group. We are a group of enthusiasts who are passionate about Java technology seeking to share our experience/knowledge with others.

How can I join?
It's simple, just go to www.clojug.com, click on the button join us and attend our monthly meetings. Both professionals and students can join as we have content for both profiles.

Does it cost?
Most presentations and meetings are free, however, the big event we do each year may have a minimal cost used for logistics and snacks.

When and where are the meetings?
Generally we meet on the fourth Saturday of each month except on December and the place is confirmed before the meeting. Since the Colombian calendar has many holidays, if the fourth Saturday of the month coincides with a holiday then the meeting is moved to the prior Saturday. Meetings are scheduled through the meetup platform and attendees are expected to do their RSVPs to ensure its entry to the place of the meeting.

Do I have to attend to all the meetings in order to be a member of the group?
Of course not! Each member decides which meetings to attend. Our meetings have different content for different profiles.

How can I participate?
You can participate in many ways. The most basics are commenting on our forums or attending some of our meetings. Actually there are many ways to participate in the Java community: 



see ya!

Saturday, February 16, 2013

ADF Essentials: adfBundle and JSTL core tag library

Hello all.
If you are using ADF Essentials (JDeveloper 11.1.2.3 or above) and your Web application needs to localize Strings in different languages, you've probably configured your project as described in my previous post: Oracle ADF: ViewController Strings l10n Part 1 Then, you have tested your application using the integrated Weblogic server that comes with JDeveloper and everything works OK, but when deploying the application to the Glassfish server you notice an error similar to this one in the Glassfish log:

[#|2013-02-13T16:31:44.607-0500|INFO|glassfish3.1.2|oracle.j2ee.jsp|_ThreadID=101;_ThreadName=Thread-2;|invalid taglib uri: http://java.sun.com/jsp/jstl/core, unless non taglib namespace was intended in a JSP document.|#]

Or this one:

[#|2013-02-13T16:31:44.614-0500|INFO|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=101;_ThreadName=Thread-2;|PWC1412: WebModule[null] ServletContext.log():JspServlet error: Servlet unable to dispatch to the following requested page: The following exception occurred:oracle.jsp.parse.JspParseException:
/fragments/adminReports.jsff: Line # 5, <c:set var="reportviewcontrollerBundle" value="#{adfBundle['com.rhla.rhsuite.report.view.resources.ApplicationBundle']}" xmlns:c="http://java.sun.com/jsp/jstl/core"/>
Error: Encountered deferred syntax #{ in template text. If intended as a literal, escape it or set directive deferredSyntaxAllowedAsLiteral|#]

If this is your case and you don't know why it is happening, I can tell is because when deploying to Glassfish you are missing one of the JSTL libraries, specifically you are missing library JSTL 1.2 (glassfish.jstl_1.2.0.1.jar). In order to deploy your project including this library, do the following:

Select project properties of your ViewController project:



On the opening dialog, go to the category Deployment and edit the default deployment profile:



Then, on the left panel select the category WEB-INF/lib Contributors and on the right panel select JSTL 1.2



After doing this, you can redeploy your application and the error should be gone.

see ya,



References:

OTN Discussion Forums. Oracle [online].
Available on Internet: https://forums.oracle.com/forums/thread.jspa?messageID=10725960
[accessed on February 14 2012].

Friday, February 15, 2013

Oracle ADF: ViewController Strings l10n Part 1

Hello all. For those of you who are using Oracle ADF or ADF Essentials and want to add language support to your applications, this post will give you an idea of the features that JDeveloper offers in order to accomplish this requirement and some best practices I have discovered when working with localization (i10n) (only the text translation part) on the ViewController  project of a Fusion Web application (ADF). It is important to note that this post is about the ViewController side of the application, the Model side works quiet different and will be addressed in another post.

What you need
JDeveloper 11gR2 (11.1.2.3.0) or superior.
Glassfish 3.1 or superior.


Configuration
After creating a Fusion Web Application (New->Applications->Fusion Web Application ADF), JDeveloper generates two projects: one for the model and another  for the view controller. Do the following in order to configure your ViewController project:

Right click on the project and select Project Properties:



A dialog opens with different properties for the project. At the left you can see the categories of the properties, select the one called ReIf you want to let the user select the language he/she wants, then you have to create a session managed bean with a language property and your source Bundle:



From the above image we can note the following:
  • Select One Bundle Per Project radio button. This is a common configuration in most projects. It allows you to have one file for the whole project.
  • According to your company standard you may have a long package structure like the one showed in the image.
  • You can select Properties Bundle from the combo box Resource Bundle Type. This is the classic plain text file with keys and values where we'll store labels, descriptions and text in general.
Once you change the location of the bundle file, JDeveloper shows a warning message telling you that prior resource bundle will not be moved to the new location and instead you should do it yourself. But if you are configuring i18n for a new project, this is not an issue. Now, you just have to create the bundle file:

Right click on the ViewController project and select the New... option:



 From the opening dialog,  select General on the left and on the right select File:



Then, use the same name for the bundle file you configured in previous steps (ApplicationBundle) but as you are configuring a Properties Bundle file, you have to use the suffix .properties. Also, put the file in the correct folder, again, this should be the same folder you configured in the project properties:



Finally, the following configuration is needed in order to allow the bundle to be accessed by your managed beans. Open the faces-config.xml file located in your ViewController project under the Web Content/WEB_INF folder and select the Application tab.

On the right, in the Message Bundle field, insert the full path of your bundle file. You configured this path in previous steps. 

In the same screen, under Locale Config, you can establish your Default Locale and any other locales you need in your project (using the green cross button). Notice that you don't have to insert anything under Resource Bundle because we are going to use the ADF features for resource bundles.


The following image shows the previous configuration:




Updating the bundle file
Next we can find the bundle file we created previously with some messages added:



We can add or update any of the messages in the resource bundle file directly. Double click on the file and JDeveloper opens it in the right panel. If you are going to update this file directly, please note that you need to insert unicode text. There is another way to update this file and is by using one of the features that JDeveloper offers. Select the Application menu and then the Edit Resource Bundles... option:



Using this option we can modify or add new messages to the bundle file of the current application. Once selected, a dialog opens presenting you the messages found in the bundle file and buttons to create or delete messages. It is important to notice that using this option we can't modify the key part of the messages only their values:



Using the resource bundle file in web pages
Once our resource bundle file is configured, we can use it in our web pages/fragments. In order to do so, we need to open the properties of the component that we want to set its message (text, description, etc...). The following image shows the properties for a button component and the option we need to select in order to obtain a message for it:



Once we click on  Select Text Resource, we are asking JDeveloper to show us the different messages configured in the ResourceBundle of the project, so we can assign one message to the component property (text, description, etc...). On the same dialog, we have the chance to define a new message and use it:



Once we start using the features that JDeveloper offers when translating our texts, you may notice the insertion of the following code in your pages/fragments:



This way we can have all of our components texts in one file and then we only need to translate each file to the languages we want for the application.


Translating a resource bundle
When you finish your app and have decided the languages in which your application needs to display texts and messages, all you need to do is create another file, using the same location as the bundle file you have already created and name it with the same name plus underscore plus the language code. For instance, for spanish translation, if our bundle file is ApplicationBundle.properties then, the new file for spanish language should be called ApplicationBundle_es.properties, for french language you should use ApplicationBundle_fr.properties, and so on... Finally, just translate each file and ADF will do the rest.


By using this approach our application is ready to display texts and messages in the browser's language. In a future post, we will cover how we can let the user select the appropriate language. 


see ya!


References:

JDeveloper 11.1.2.3 - Internationalizing and Localizing Pages. Oracle [online].
Available on Internet: http://docs.oracle.com/cd/E35521_01/web.111230/e16181/af_global.htm
[accessed on February 11 2012].

Sten E. Vesterli (2011). Oracle ADF Enterprise Application Development Made Simple. United Kingdom: Packt Publishing Ltd.

Sunday, January 27, 2013

CLOJUG - First meeting

Hello all. Last Saturday, we had the first meeting of the Cali (CLO) Java Users Group. A new JUG located in the city Cali (Colombia) which focus in Java and Java-related technologies, networking with other communities in our city or country, sharing information and making friends. This initiative starts with three (3) members who are java lovers and experienced java developers. We're looking forward for the participation of students from local schools and universities as well as experienced java developers.




The project is still private on java.net, but, hopefully, it will be public on February. We are planning to have our JUG graduated during the first semester of 2013. Our meetings will be held on the last Saturday of each month (except on December). More information to come.


see ya!!