Skip to content

14. Version 9: Implementing the web layer with PrimeFaces

Prerequisites: Read "Introduction to Primefaces" in [ref3].


Question 1: Create a new Maven project of type [Web Application] where the XHTML pages from the previous example are built using Primefaces components. Do not make any changes to the beans.


The home page uses the <p:panel>, <p:inputText>, <p:selectOneMenu>, and <p:message> components:

 

An incorrect entry:

 

A simulation:

 

The list of simulations uses the <p:dataTable> and <p:commandLink> components:

The AJAX methods will update the area with id='formulaire', which includes the entire page (see line 11 below):


<h:commandLink id="cmdTerminerSession" immediate="true" value="#{msg['form.menu.terminerSession']}" action="#{form.terminerSession}" rendered="#{sessionData.menuTerminerSessionIsRendered}"/>

Once your application is working, replace the [entete.xhtml] page with the following page:


<?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:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
 
  <f:view locale="#{sessionData.locale}">
    ...
    <h:body style="background-image: url('${request.contextPath}/resources/images/standard.jpg');">
      <h:form id="formulaire">
        <!-- entete -->
        <ui:include src="entete.xhtml" />
        <!-- content -->
        <ui:insert name="part1" >
          Gestion des assistantes maternelles
        </ui:insert>
        <ui:insert name="part2"/>
      </h:form>
    </h:body>
  </f:view>
</html>
  • line 15: a PrimeFaces menu bar,
  • line 16: a menu option in this bar,
  • line 17: an item in this menu option.

The model is not affected by this change. The new view is as follows:

Image