I can not display anything in a JSF view

1

I'm working on a web application to develop a module, but I can not display anything in the view, not even a simple message.

The view loads the template, but does not display anything I put in the view. The only thing that is being displayed is the title in the browser tab, through the <ui:define> tag. Here is the code:

View

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:p="http://primefaces.org/ui"
            xmlns:jsp="http://java.sun.com/JSP/Page"
            template="template.xhtml">

    <ui:define name="titulo">
        Ver Livros de Ordem
    </ui:define>

    <h:outputText value="#{verLivrosOrdemController.msg}" />

</ui:composition>

Managed Bean

package br.org.aplicacao.servicosOnline.controller;

import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

@ManagedBean
@ViewScoped
public class VerLivrosOrdemController implements Serializable {
    String msg;

    public String getMsg() {
        return msg;
    }

    public void setMsg() {
        this.msg = "Em breve!";
    }
}
    
asked by anonymous 09.11.2018 / 13:56

1 answer

0

You have not placed your template code.

If you have not defined it, you must define a body of your template to be able to display it.

The same thing you did with your title. Example:

<ui:composition ... template="template.xhtml">

    <ui:define name="titulo">
        Ver Livros de Ordem
    </ui:define>

    <ui:define name="conteudo">
        <h:outputText value="#{verLivrosOrdemController.msg}" />
    </ui:define>

</ui:composition>

Your template should look something like this:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets">

  <h:head>
    <title>JSF 2.0 - Exemplo de template</title>
  </h:head>

  <h:body>

    <ui:insert name="titulo">
        <h1>Título da minha pagina</h1>
    </ui:insert>

    <ui:insert name="conteudo">
        Informações do conteúdo
    </ui:insert>

    <ui:insert name="rodape">
        Informações do rodapé
    </ui:insert>

  </h:body>

</html>

Reference:

09.11.2018 / 14:33