<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"> <h:head> <title>#{msgs.title}</title> </h:head> <h:body> <h:form> <h3>#{msgs.heading}</h3> <p> <h:outputFormat value="#{msgs.currentScore}"> <f:param value="#{quizBean.score}"/> </h:outputFormat> </p> <p>#{msgs.guessNext}</p> <p>#{quizBean.current.sequence}</p> <p> #{msgs.answer} <h:inputText value="#{quizBean.answer}"/> </p> <p><h:commandButton value="#{msgs.next}"/></p> </h:form> </h:body> </html>
This file illustrates
The most interesting bean reference in this file is the following line:
<p>#{quizBean.current.sequence}</p>
This line illustrates direct access to the quizBean JSF-managed bean and indirect access to a ProblemBean ordinary Java bean. The sequence property of a ProblemBean is accessed indirectly through the quizBean current property.
A string in a message bundle can be referenced with the notation #{bundle-name.string-name}, where
The most interesting use in index.xhtml is the following:
<h:outputFormat value="#{msgs.currentScore}"> <f:param value="#{quizBean.score}"/> </h:outputFormat>
The string currentScore is defined with a parameter. The actual value of that parameter is supplied in the f:param tag. Use of this tag requires declaration of the "f:" namespace:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">