The best place to *find* answers to programming/development questions, imo, however it's the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but again, a great reference for *finding* answers.

My Music (Nickleus)

20111108

f:loadBundle not working in jboss 7, can't see properties label text [SOLVED]

i made a simple jsf page to test using a properties file labels_no.properties.
here was the code i had:

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
template="/WEB-INF/templates/default.xhtml">
<f:loadBundle basename="com.mycompany.labels_no" var="label"/>
<ui:define name="content">
<h:form id="reg">
           <h:panelGroup id="messagePanel" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            <h:form>
                <h:panelGrid columns="2">
                    <h:outputLabel value="#{label.userFirstName}" for="userFirstName" />
...
 and in the eclipes preview window i could see the label and it's value, but in a browser the label was missing. i figured out that the f:loadBundle tag was just in the wrong place, so i moved it inside the ui:define tag (the next line under it) and the label appeared! =)

see also:
http://download.oracle.com/javaee/5/javaserverfaces/1.2/docs/tlddocs/f/loadBundle.html
http://www.roseindia.net/jsf/jsf1.2/jsf-properties.shtml

No comments:

Post a Comment