Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!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:ui="http://java.sun.com/jsf/facelets"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core">
- <h:dataTable value="#{controleCliente.clientes}" var="cliente" border="1">
- <h:column>
- <f:facet name="header">ID</f:facet>
- #{cliente.id}
- </h:column>
- <h:column>
- <f:facet name="header">Name</f:facet>
- #{cliente.nome}
- </h:column>
- <h:column>
- <f:facet name="header">Idade</f:facet>
- #{cliente.idade}
- </h:column>
- </h:dataTable>
- </html>
- package com.exemplo.controle;
- import java.util.List;
- import javax.faces.bean.ManagedBean;
- import javax.faces.bean.SessionScoped;
- import com.exemplo.entidade.Cliente;
- import com.exemplo.repositorio.RepositorioCliente;
- @ManagedBean
- @SessionScoped
- public class ControleCliente {
- Cliente cliente;
- List<Cliente> clientes;
- RepositorioCliente repositorioCliente;
- public ControleCliente(){
- repositorioCliente = new RepositorioCliente();
- cliente = new Cliente();
- }
- public String salvar(){
- repositorioCliente.salvar(cliente);
- return "index";
- }
- public Cliente getCliente() {
- return cliente;
- }
- public void setCliente(Cliente cliente) {
- this.cliente = cliente;
- }
- public List<Cliente> getClientes() {
- clientes = repositorioCliente.listarTodos();
- return clientes;
- }
- public void setClientes(List<Cliente> clientes) {
- this.clientes = clientes;
- }
- }
- <!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:ui="http://java.sun.com/jsf/facelets"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core">
- <h:form>
- <h:outputText value="Nome: " />
- <h:inputText value="#{controleCliente.cliente.nome}"/><br />
- <h:outputText value="Idade: "/>
- <h:inputText value="#{controleCliente.cliente.idade}"/>
- <h:commandButton action="#{controleCliente.salvar}"/>
- </h:outputText>
- </h:form>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment