JSF localization and Primefaces resources

UI Components for JSF
Post Reply
Houdre
Posts: 12
Joined: 29 Apr 2013, 12:22

30 Oct 2014, 13:04

Greetings!

I ran into issues when trying to localize our application. I added the correct localization postfix and other stuff as described here: http://technology-for-human.blogspot.co ... -of-3.html

The issue is that the ResourceHandler doesn't find the PF resources when the javax.faces.resource.localePrefix is set in the resources_en.properties ('en' in our case).
I've found a closed issue regarding this on the Mojarra's JIRA but is marked as 'Working as designed': https://java.net/jira/browse/JAVASERVERFACES-3109

I'm using JSF 2.2.8, Mojarra implementation with PF 5.1 on Tomcat 7.0.54.

Does anyone have any clues how to use JSF localization functionality with PF (or any other 3rd party libraries for that matter)?

Regards.

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

30 Oct 2014, 18:31

As far as I know PF does not need to be localised nor localisable with at least 1 notable exception.
For the calendar there are clear instructions on how to create localized versions otherwise all localization needs are catered for using in JSF.
Use google to search for JSF resource bundles.
Use NetBeans to generate a simple JSF sample application for you: the code normally has resources bundles in the generated code.
In your case the javax.faces.resource.localePrefix property is breaking things so don't use it.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

Houdre
Posts: 12
Joined: 29 Apr 2013, 12:22

03 Nov 2014, 12:34

The issue here is not with the localizing various labels and messages (this works as intended and described in the tutorial link) but static resources (CSS files, images). And if you wish to also localize those (e.g. you want a red background and Comic Sans font for en locale and blue background with Times Roman font for de locale) JSF doesn't know how to load PF resources since they're not found in en or de subfolder in resources folder since they don't exist in PF JAR.

If you check the bug description you'll see that the "problem" is in the FaceletWebappResourceHelper class in JSF 2.2.x.

Anyway, resource bundle localization is, for my knowledge, not possible if you're using PF or any other 3rd party library with JSF 2.2.x.

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

03 Nov 2014, 14:49

Houdre wrote:The issue here is not with the localizing various labels and messages (this works as intended and described in the tutorial link) but static resources (CSS files, images). And if you wish to also localize those (e.g. you want a red background and Comic Sans font for en locale and blue background with Times Roman font for de locale) JSF doesn't know how to load PF resources since they're not found in en or de subfolder in resources folder since they don't exist in PF JAR.

If you check the bug description you'll see that the "problem" is in the FaceletWebappResourceHelper class in JSF 2.2.x.

Anyway, resource bundle localization is, for my knowledge, not possible if you're using PF or any other 3rd party library with JSF 2.2.x.
We use resource bundle localization using PF and JSF 2.2 without difficulty.
Having checked out our Project history I see we ran into this problem ourselves but the workaround was easy, simply use the current user locale as part of the library name.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 30 guests