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.