1
This is my class:
package com.algaworks.pedidovenda.controller;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
@ManagedBean
@ViewScoped
public class PesquisaProdutosBean implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private List<Integer> produtosFiltrados;
public PesquisaProdutosBean() {
produtosFiltrados = new ArrayList<>();
for (int i = 0; i < 50; i++) {
produtosFiltrados.add(i);
}
}
public List<Integer> getProdutosFiltrados() {
return produtosFiltrados;
}
}
This is the page:
<ui:composition template="/WEB-INF/template/LayoutPadrao.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">
<ui:define name="titulo">Novo Produto</ui:define>
<ui:define name="corpo">
<h:form id="frm">
<h1>Pesquisa Produtos</h1>
<p:toolbar style="margin-top:20px">
<p:toolbarGroup>
<p:commandButton value="Pesquisa" />
</p:toolbarGroup>
<p:toolbarGroup align="right">
<p:button value="Novo" outcome="/produtos/CadastroProduto" />
</p:toolbarGroup>
</p:toolbar>
<p:panelGrid columns="2" id="painel"
style="width:100%; margin-top:20px" columnClasses="rotulo, campo">
<p:outputLabel value="SKU" for="sku" />
<p:inputText id="sku" size="20" maxlength="20" />
<p:outputLabel value="Nome" for="nome" />
<p:inputText id="nome" size="60" maxlength="80" />
</p:panelGrid>
<p:dataTable id="produtosTable"
value="#{pesquisaProdutosBean.produtosFiltrados}" var="produto">
<p:column headerText="SKU" style="text-align: center; width: 100px">
<h:outputText value="123" />
</p:column>
</p:dataTable>
</h:form>
</ui:define>
</ui:composition>
Is any error shown or just isn’t displayed? You confirmed if
getProdutosFiltrados
is called when rendering the page?– Bruno César
Try to change
@ViewScoped
for@RequestScoped
.– ptkato
no error message appears on consoles, simply did not display, and I have tried to change the annotations in the Bean class and it did not work.
– wladyband
Is it because of the version of Primefaces and JSF?
– wladyband