Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF Validation not finding custom ResourceBundle class

I have a custom ResourceBundle class org.example.web.UILabels.java which works well in running code but the JSF editor in Eclipse is not finding it, I assume the editor/validator is only looking for properties files by the name. This also means I no longer get type ahead find on the resources which was very nice to have.

Any ideas how this could be rectified?

<f:loadBundle basename="org.example.web.UILabels" var="uiLabels"/>
...
<h:outputText value="#{uiLabels.someTextValue}" />
...

I am getting the error message (in the problems error list)

Resource bundle org.example.web.UILabels cannot be found on classpath

Type=JSF Problem

Eclipse3.4.0 with WebStandardTools Versions

  • Version:1.4.0.v200802280619-13-7w311917141518
  • Version:1.5.1.v200802280619-1407w311917141519
  • Version:3.0.0.v200806092130-7A-8Y8QqN2lf4VSWrI2ek5Pf4k7s

For more about why I am using a ResourceBundle class instead of just a properties file see Question 653682 how-to-override-some-resources-from-a-propertyresourcebundle

Thanks for your time, David Waters

like image 397
David Waters Avatar asked Mar 20 '09 12:03

David Waters


2 Answers

The resource-bundle element is more efficient than the f:loadBundle action since the bundle can be created once for teh entire application. However its a JSF 1.2 feature and if u want to be compatible with JSF 1.1 you must use JSF 1.1. Heres an example if your using JSF 1.2: Define it in your faces-config.xml like this:

<application>
<resource-bundle>
<base-name>org.example.web.UILabels</basename>
<var>uiLabels</var>
</resource-bundle>
</application>

Sorry for not answering your question, but I dont have first hand experience with Eclipse. I also misunderstood your question first, therefor Ive edited my original answer.

like image 170
Chris Dale Avatar answered Sep 25 '22 15:09

Chris Dale


I had the same problem, I finally find this sollution : Eclipse search only the default properties, your project has to have a properties with no locale, for example, with :

<f:loadBundle basename="i18n.messages" var="msg" />

Eclipse will only search "i18n/messages.properties".

like image 42
Christophe Rebeschini Avatar answered Sep 24 '22 15:09

Christophe Rebeschini