Inv3r53
Inv3r53

Reputation: 2969

Configuring resource bundle in jsf2.1

I have problem referring to resource values from .properties file in xhtml file

I get following message :

Jul 23, 2012 8:33:27 PM com.sun.faces.context.ExternalContextImpl getMimeType
WARNING: JSF1091: No mime type could be found for file hello.  To resolve this,
add a mime-type mapping to the applications web.xml.

Here is my faces-config.xml

<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd"
    version="2.1">
    <application>
        <resource-bundle>
            <base-name>resources.resources</base-name>
            <var>resource</var>
        </resource-bundle>
        <locale-config>
            <default-locale>en</default-locale>
        </locale-config>
    </application>
</faces-config>

Here is my test page

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">
<f:view>
    <h:head>
        <h:outputText value="Header" />
    </h:head>

    <h:body>
        <h:form>
        <h:outputText value="#{resource.hello}" />
            <h:outputText value="Body" />
            <br />
            <p:spinner />
        </h:form>
    </h:body>
</f:view>
</html>

What could be wrong ?

EDIT:

Not sure if it matters , i use Primefaces-3.3.1

Thanks!

Upvotes: 0

Views: 2865

Answers (1)

BalusC
BalusC

Reputation: 1109570

The EL variable #{resource} is a reserved variable name which refers to the resource files in /resources folder which are used by <h:outputStylesheet>, <h:outputScript> and <h:graphicImage>. The EL variable #{resource} is usually only used in CSS files like so

.someClass {
    background-image: url("#{resource['someLibrary:image/some.png']}");
}

Give it a different name.

<var>res</var>

<var>msg</var>

<var>text</var>

<var>i18n</var>

etc...

See also:

Upvotes: 3

Related Questions