Array
(
)

Passar dados de uma varial do formulário para uma Lista RichFaces JSF

Victor Lima
   - 23 nov 2009


 Bom dia Galera,

 Estou aki quebrando a cabeça com um campo de volume, que tenho em um formulário web com jsf e RichFaces.

Vaja o que estou tentando fazer na tela abaixo:



 O Usuario entra na tela modal para inserir em uma lista as notas que digita e ao sair do campo, mando adicionar em uma lista para mostrar na tela e em um map para guardar no banco posteriormente.

O problema que tenho é que  o usuario digita o volume e não seta na lista, existe uma variavel Integer vol, na classe de controlle e mesmo assim nao vai.

veja o codigo controller  e a pagina.

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.protracking.controller;

import br.com.protracking.mapa.ItemMapa;
import br.com.protracking.mapa.ItemProtocoloBean;
import br.com.protracking.mapa.ProtocoloBean;
import br.com.protracking.util.FacesUtils;
import br.com.webtracking.dao.DaoGenerico;
import br.com.webtracking.entity.Area;
import br.com.webtracking.entity.Cliente;
import br.com.webtracking.entity.Empresa;
import br.com.webtracking.entity.ItensProtocoloMapa;
import br.com.webtracking.entity.NotaFiscal;
import br.com.webtracking.entity.ProtocoloMapa;
import br.com.webtracking.entity.ResponsavelEmpresa;
import br.com.webtracking.entity.Usuario;
import java.io.InputStream;
import com.lowagie.text.pdf.codec.postscript.ParseException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.JasperRunManager;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.util.JRLoader;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

/**
 *
 * @author victor
 */
@Controller("protocolomapaController")
@Scope("session")
public class ProtocoloMapaController {

    private ProtocoloMapa protocoloMapa;
    private ItensProtocoloMapa itensMapa;
    private ItemMapa itemMapa;
    private HashMap<Long, ItensProtocoloMapa> impt = new HashMap<Long, ItensProtocoloMapa>();
    private HashMap<Integer, ProtocoloMapa> mapaTranspMap = new HashMap<Integer, ProtocoloMapa>();
    private HashMap<Integer, ItemMapa> itensMapaMap = new HashMap<Integer, ItemMapa>();
    private List<ItemMapa> itemList = new ArrayList<ItemMapa>();
    private List<ItemProtocoloBean> itemsProtocoloBean = new ArrayList<ItemProtocoloBean>();
    private Date dataProtocolo;
    private Integer notaF;
    private Date data1;
    private Date data2;
    //atributos de paginação de resultados
    private int maxPorPagina = 40;
    private int paginaAtual = 0;
    @Resource
    private DaoGenerico<ProtocoloMapa, Integer> protocolomapaDao;
    @Resource
    private DaoGenerico<ItensProtocoloMapa, Integer> itensprotocolomapaDao;
    @Resource
    private DaoGenerico<NotaFiscal, Integer> notafiscalDao;
    @Resource
    private DaoGenerico<Empresa, Integer> empresaDao;
    @Resource
    private DaoGenerico<Cliente, Integer> clienteDao;
    @Resource
    private DaoGenerico<Area, Integer> areaDao;
    @Resource
    private DaoGenerico<ResponsavelEmpresa, Integer> responsavelempresaDao;
    private Map<String, Object> empresaItem = null;
    private Map<String, Object> responsavelItem = null;
    private Map<String, Object> areaItem = null;
    private Integer qtdMapeo = null;
    private DataModel model;
    private Double subTotal;
    private Integer qtdTotal;
    private Integer vol;
    FacesContext fc = FacesContext.getCurrentInstance();
    HttpSession session = (HttpSession) fc.getExternalContext().getSession(false);

    public String novoProtocoloMapa() {
        this.protocoloMapa = new ProtocoloMapa();
        this.protocoloMapa.setCodempr(new Empresa());
        this.protocoloMapa.setResponsavel(new ResponsavelEmpresa());
        this.getEmpresa();
        this.getResponsavel();



        return "goToformprotocolomapa";

    }

    public String consultaProt() {
        this.protocoloMapa = new ProtocoloMapa();
        this.protocoloMapa.setCodempr(new Empresa());
        this.getEmpresa();
        return "goToimprimeProtocolo";

    }

    public Map<String, Object> getEmpresa() {
        empresaItem = new LinkedHashMap<String, Object>();
        for (Iterator<?> iter = empresaDao.todos().iterator(); iter.hasNext();) {
            Empresa e = (Empresa) iter.next();
            empresaItem.put(e.getDesc_nome(), e.getCodempr());// label,value
        }
        return empresaItem;
    }

    public Map<String, Object> getResponsavel() {
        responsavelItem = new LinkedHashMap<String, Object>();
        for (Iterator<?> iter = responsavelempresaDao.todos().iterator(); iter.hasNext();) {
            ResponsavelEmpresa r = (ResponsavelEmpresa) iter.next();
            responsavelItem.put(r.getFirst_name() + " " + r.getLast_name(), r.getId());// label,value
        }
        return responsavelItem;
    }

    // Pesquisa a Nota Fiscal
    private NotaFiscal verificaNF(Integer nf) {
        String query = "SELECT n from NotaFiscal n WHERE n.notafiscal = :nota";
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("nota", nf);
        return notafiscalDao.pesqParam(query, params);
    }

    // Verificar a Existencia do Cliente
    private Cliente verificaCliente(Integer cli) {
        String query = "SELECT c FROM Cliente c WHERE c.codCli = :codCli";
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("codCli", cli);
        return clienteDao.pesqParam(query, params);
    }

    // Verificar a Existencia do Cliente
    private Integer verificaItensMapa(Long it) {
        String query = "SELECT i FROM ItensProtocoloMapa i WHERE i.cod_nf = :cod";
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("cod", it);
        params = (Map<String, Object>) itensprotocolomapaDao.pesqParam(query, params);
        return qtdMapeo = params.size();

    }

     // Verificar a Existencia do Cliente
    private List buscaritensProtocolo(Integer it) {

      String query = " SELECT n.notafiscal,n.data_cria,n.valor" +
                " FROM ProtocoloMapa p " +
                " JOIN p.itensProtocoloMapa i" +
                " JOIN i.nota n" +
                " WHERE p.id_protmapa = :idprotocolo";
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("idprotocolo", it);
      //  params = (Map<String, Object>) itensprotocolomapaDao.pesqParam(query, params);
        return itemsProtocoloBean;

    }



    // testes
    public void adicionarNotaAoProtocoloMapa() {



        ItemMapa item = new ItemMapa();


        Iterator<?> i = itensMapaMap.values().iterator();
        boolean v = false;
        while (i.hasNext()) {
            ItemMapa im = (ItemMapa) i.next();
            if (im.getNf() == notaF) {
                v = true;
            }
        }
        if (v == true) {

            FacesUtils.mensErro("Nota Fiscal já foi adicionada ao Mapa");
            System.out.println("Nota Fiscal já Adicionada: " + notaF);
            String msg = "Nota Fiscal já foi adicionada ao Mapa";
            FacesMessage message = new FacesMessage(msg);
            FacesContext context = FacesContext.getCurrentInstance();
            context.addMessage("protocolo", message);

        } else {
            NotaFiscal nota = verificaNF(notaF);

            Cliente cli = verificaCliente(nota.getCodCli().getCodCli());
            //    Integer count = verificaItensMapa(n.getCod_nf());

            //   Integer quantMapeo = 0;
            //  quantMapeo = verificaNfQuant(notaF);

          

            item.setCodNf(nota.getCod_nf());
            item.setNf(nota.getNotafiscal());
            //    itens.setQuantMapeada(count);
            item.setValor(nota.getValor());
            item.setCliente(cli.getNomeCli());
            item.setVolume(vol);


          

            itensMapaMap.put(item.getCodNf(), item);
            itemList.add(item);
            atualizarQtd();
            atualizarValor();

            System.out.println(itensMapaMap.size());
            System.out.println(itemList.size());
           System.out.println(itemList);
           System.out.println(item.getVolume());

        }



    }

    public void gravarProtocoloMapa() {

        if (listarItensMapa().size() > 0) {

            Empresa e = empresaDao.pesquisarPorId(protocoloMapa.getCodempr().getCodempr());
            ResponsavelEmpresa resp = responsavelempresaDao.pesquisarPorId(protocoloMapa.getResponsavel().getId());

            protocoloMapa.setCodempr(e);
            protocoloMapa.setResponsavel(resp);

            // pegar o usuario

            protocoloMapa.setUser((Usuario) session.getAttribute("userlogged"));

            protocoloMapa.setData_prot(new Timestamp((new Date()).getTime()));

            protocoloMapa.setData_cad(new Timestamp((new Date()).getTime()));
            protocoloMapa.setValor(protocoloMapa.getSubTotal());
            protocolomapaDao.salvar(protocoloMapa);
            Long mapaid = protocoloMapa.getId_protmapa();

            // varre os itens do Mapa para guardar no Banco.

            Iterator<?> item = listarItensMapa().iterator();

            while (item.hasNext()) {

                ItemMapa itemProtocoloMapa = (ItemMapa) item.next();

                // salva os itens no mapa

                itensprotocolomapaDao.salvar(new ItensProtocoloMapa(
                        mapaid,
                        itemProtocoloMapa.getCodNf(),
                        itemProtocoloMapa.getVolume()));
            }

            String msg = "Gravado com Sucesso";
            FacesMessage message = new FacesMessage(msg);
            FacesContext context = FacesContext.getCurrentInstance();
            context.addMessage("protocolo", message);
        }
        limpar();
       
    }

    // limpar itens de mapa
    public void limpar() {

        itemList.clear();
        itensMapaMap.clear();
        atualizarQtd();
        atualizarValor();
        this.getTodos();

    }

    public DataModel getTodos() {

        return model = new ListDataModel(itemList);

    }

    // lista os pedidos do arquivo importado Itens
    @SuppressWarnings("unchecked")
    public List listarItensMapa() {
        // retorna um ArrayList
        return new ArrayList(itensMapaMap.values());
    }

    // Atualizar Quantidade e Valor
    public Integer atualizarQtd() {

        Integer quant = 0;

        Iterator<?> itensMapaNF = listarItensMapa().iterator();
        while (itensMapaNF.hasNext()) {
            ItemMapa item = (ItemMapa) itensMapaNF.next();

            quant += 1;
        }
        protocoloMapa.setQtdTotal(quant);

        return null;
    }

    // Atualizar e Valor
    public Double atualizarValor() {

        Double totalGeral = 0.0;

        Iterator<?> itensMapaNF = listarItensMapa().iterator();
        while (itensMapaNF.hasNext()) {
            ItemMapa item = (ItemMapa) itensMapaNF.next();

            totalGeral += item.getValor();
        }
        protocoloMapa.setSubTotal(totalGeral);
        return null;
    }

    public String remoreItens() {
        ItemMapa i = getItemMapaParaExcluir();
        itemList.remove(i);
        itensMapaMap.remove(i.getCodNf());
        return null;
    }

    public ItemMapa getItemMapaParaExcluir() {
        ItemMapa i = (ItemMapa) model.getRowData();
        return i;
    }

    public String removerItensMapa() {


        ItemMapa i = getItemMapaParaExcluir();
        itemList.remove(i);
        itensMapaMap.remove(i.getCodNf());

        Integer quant = listarItensMapa().size();

        Double total = protocoloMapa.getSubTotal() - i.getValor();
        System.out.println(itemList);
        System.out.println(itensMapaMap);

        // recalcula  Quantidade
        protocoloMapa.setQtdTotal(quant);
        protocoloMapa.setSubTotal(total);
        this.getTodos();

        return null;


    }

    public ProtocoloMapa getItemProtocoloParaImprimir() {
        ProtocoloMapa pm = (ProtocoloMapa) model.getRowData();
        return pm;
    }

    public String editarImprime() {
        setProtocoloMapa(getItemProtocoloParaImprimir());

        return "sucesso";
    }


    // mostra todos os Pedidos a serem impressos em um dataTable
    // mostra todos os produtos em um DataTable
    //comprados com os respectivos clientes
    //limitados pela paginação
    @SuppressWarnings("unchecked")
    public DataModel getConsultaNotasProtocolo() {

     String query = " SELECT p "+
                " FROM ProtocoloMapa p " +
                " WHERE p.data_prot BETWEEN :data1 AND :data2 " +
                " AND p.codempr = :cod_empr";
       
        /*   String query = " SELECT p.id_protmapa, p.data_prot,p.obs,p.data_cad, e.desc_nome," +
                " u.username,r.first_name,r.last_name" +
                " FROM ProtocoloMapa p " +
                " JOIN p.user u " +
                " JOIN p.codempr e " +
                " JOIN p.responsavel r" +
                " WHERE p.data_prot BETWEEN :data1 AND :data2 " +
                " AND p.codempr = :cod_empr";  */

        Empresa empr = empresaDao.pesquisarPorId(protocoloMapa.getCodempr().getCodempr());


        Map<String, Object> params = new HashMap<String, Object>();
        params.put("data1", new Timestamp(data1.getTime()));
        params.put("data2", new Timestamp(dataConvertida()));
        params.put("cod_empr", empr);


        //    return new ListDataModel(pedidoDao.listPesq(query));

       return model = new  ListDataModel(protocolomapaDao.listPesqParam(query, params, maxPorPagina, paginaAtual));

    }

    @SuppressWarnings("unchecked")
    public DataModel getConsultaItensProtocolo() {



      String query = " SELECT n.notafiscal,n.data_cria,n.valor" +
                " FROM ProtocoloMapa p " +
                " JOIN p.itensProtocoloMapa i" +
                " JOIN i.nota n" +
                " WHERE p.id_protmapa = :idprotocolo";


        ProtocoloMapa pm = protocolomapaDao.pesquisarPorId(protocoloMapa.getId_protmapa().intValue());


        Map<String, Object> params = new HashMap<String, Object>();
        params.put("idprotocolo", pm);


        return new ListDataModel(protocolomapaDao.listPesqParam(query, params, maxPorPagina, paginaAtual));

    }

    //método para a consulta a ser utilizada
    private String consultaNotas() {
        String query = " SELECT p "+
                " FROM ProtocoloMapa p " +
                " WHERE p.data_prot BETWEEN :data1 AND :data2 " +
                " AND p.codempr = :cod_empr";
        return query;
    }

    //método para a consulta a ser utilizada
    private String consultaItensProtocolo() {

        String query = " SELECT n.notafiscal,n.data_cria,n.valor" +
                " FROM ProtocoloMapa p " +
                " JOIN p.itensProtocoloMapa i" +
                " JOIN i.nota n" +
                " WHERE p.id_protmapa = :idprotocolo";

     /*   String query = " SELECT p.id_protmapa, p.data_prot,p.obs,p.data_cad, e.desc_nome," +
                " u.username,r.first_name,r.last_name,i.nota,n.notafiscal,n.data_cria,n.valor" +
                " FROM ProtocoloMapa p " +
                " JOIN p.user u " +
                " JOIN p.codempr e " +
                " JOIN p.responsavel r" +
                " JOIN p.itensProtocoloMapa i" +
                " JOIN i.nota n" +
                " WHERE p.id_protmapa = :idprotocolo";  */

        return query;
    }

    //separa a pesquisa do total encontrado
//possibilitando a utilização também no relatório
    public List<?> todosResultsPesq() {


        Empresa empr = empresaDao.pesquisarPorId(protocoloMapa.getCodempr().getCodempr());


        Map<String, Object> params = new HashMap<String, Object>();
        params.put("data1", new Timestamp(data1.getTime()));
        params.put("data2", new Timestamp(dataConvertida()));
        params.put("cod_empr", empr);

        return protocolomapaDao.listPesqParam(consultaNotas(), params);


    }

    //separa a pesquisa do total encontrado
//possibilitando a utilização também no relatório
    public List<?> todosResultsPesqItens() {

        Map<String, Object> params = new HashMap<String, Object>();
        params.put("idprotocolo", protocoloMapa.getId_protmapa());

        return protocolomapaDao.listPesqParam(consultaItensProtocolo(), params);


    }

    //converte adicionando hora, minuto e segundo
    private long dataConvertida() {
        //adiciona a hora que não foi colocada no
        //intervalo de pesquisa
        GregorianCalendar gc1 = new GregorianCalendar();
        gc1.setTime(data2);
        gc1.add(GregorianCalendar.HOUR_OF_DAY, 23);
        gc1.add(GregorianCalendar.MINUTE, 59);
        gc1.add(GregorianCalendar.SECOND, 59);

        return gc1.getTimeInMillis();
    }


    //navega para a primeira página
    public String primeiraPagina() {
        paginaAtual = 0;
        return null;
    }

    //navega para a última página
    public String ultimaPagina() {
        int rest = getTotal() % maxPorPagina;

        if (rest != 0) {
            paginaAtual = getTotal() - rest;
        } else {
            paginaAtual = getTotal() - maxPorPagina;
        }

        return null;
    }

    //total de resultados encontrados na consulta
    @SuppressWarnings("unchecked")
    public int getTotal() {

        int total = todosResultsPesq().size();
        return total;

    }

    //acessor da página atual
    public int getPaginaAtual() {
        return paginaAtual;
    }

    @SuppressWarnings("unchecked")
    //executa o relatório através do actionListener
    public void executarRelatorio() throws ParseException, java.text.ParseException {

        FacesContext context = FacesContext.getCurrentInstance();
        HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();

  //      ProtocoloBean pb = new ProtocoloBean();

  //      pb.setId_protmapa(protocoloMapa.getId_protmapa().intValue());
  //      pb.setFirst_name("testee");
  //      pb.setLast_name("testes");
  //      pb.setData_prot(protocoloMapa.getData_prot());
   //     pb.setData_cad(protocoloMapa.getData_cad());
 //       pb.setObs(protocoloMapa.getObs());
 //       pb.setValor(protocoloMapa.getValor());
       
       

        Hashtable ht = new Hashtable();
        ht.put("first_name", "testes");
        ht.put("last_name", "testes");
        ht.put("id_protmapa",Integer.parseInt(protocoloMapa.getId_protmapa().toString()));
        ht.put("data_prot",this.convertTimestamp(protocoloMapa.getData_prot().toString()));
        ht.put("obs", protocoloMapa.getObs());
        ht.put("valor", Double.parseDouble(protocoloMapa.getValor().toString()));
        ht.put("data_cad", this.convertTimestamp(protocoloMapa.getData_cad().toString()));
        ht.put("desc_nome", "testes");




        ArrayList listanotas = new ArrayList(); //ArrayList com

        listanotas.add(itemsProtocoloBean);



        try {
            ServletOutputStream servletOutputStream = response.getOutputStream();
            JREmptyDataSource ED = new JREmptyDataSource();
            JRBeanCollectionDataSource BCD = new JRBeanCollectionDataSource(listanotas,false);
            ht.put("listanotas", BCD);
            InputStream reportStream = context.getExternalContext().getResourceAsStream("/reporter/mapa/Protocolos/controle_carga.jasper");
            JasperReport relatorio = (JasperReport) JRLoader.loadObject(reportStream);
            JasperPrint impressao = new JasperPrint();
            impressao = JasperFillManager.fillReport(relatorio, ht, ED);
            byte[] buffer = JasperExportManager.exportReportToPdf(impressao);
            if (buffer != null) {


                servletOutputStream.write(buffer, 0, buffer.length);
                servletOutputStream.flush();
                servletOutputStream.close();
            }



        } catch (JRException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            //evita erro do JSF após completar
            //a geração do relatório
            //avisando o FacesContext que a resposta está completa
            context.responseComplete();

        }
    }

    /*    private Connection getConnection() {

    Connection connection = null;

    try {
    // Cria a conexao com o banco de dados

    Class.forName("org.postgresql.Driver");
    String db = "jdbc:postgresql://localhost:5432/webtracking";
    connection = DriverManager.getConnection(db, "postgres", "viclima");

    } catch (SQLException ex) {
    ex.printStackTrace();
    } catch (ClassNotFoundException ex) {
    ex.printStackTrace();
    }

    return connection;
    }

    public void executarRelatorio() throws ParseException, SQLException, IOException {


    FacesContext context = FacesContext.getCurrentInstance();
    HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();

    //pega o caminho do arquivo .jasper da aplicação
    InputStream reportStream = context.getExternalContext().getResourceAsStream("/reporter/mapa/mapatransporte.jasper");

    try {

    Connection connection = getConnection();
    ServletOutputStream servletOutputStream = response.getOutputStream();

    HashMap<String, Integer> map = new HashMap<String, Integer>();
    map.put("PAR_CODMAPA", 18);

    //envia a resposta com o MIME Type PDF
    response.setContentType("application/pdf");
    //envia para o navegador o PDF gerado
    JasperRunManager.runReportToPdfStream(reportStream, servletOutputStream, map, connection);



    servletOutputStream.flush();
    servletOutputStream.close();

    connection.close();

    } catch (JRException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } finally {
    //evita erro do JSF após completar
    //a geração do relatório
    //avisando o FacesContext que a resposta está completa
    context.responseComplete();

    }

    } */
    //converte uma string para Timestamp
    private Timestamp convertTimestamp(String t) throws ParseException, java.text.ParseException {
        // trata nanoseconds "yyyy-mm-dd hh:mm:ss.nanoseconds"
        SimpleDateFormat sdfIn =
                new SimpleDateFormat("yyyy-MM-dd");
        return new Timestamp(sdfIn.parse(t).getTime());
    }

    public Integer getVol() {
        return vol;
    }

    public void setVol(Integer vol) {
        this.vol = vol;
    }

    public HashMap<Long, ItensProtocoloMapa> getImpt() {
        return impt;
    }

    public void setImpt(HashMap<Long, ItensProtocoloMapa> impt) {
        this.impt = impt;
    }

    public List<ItemMapa> getItemList() {
        return itemList;
    }

    public void setItemList(List<ItemMapa> itemList) {
        this.itemList = itemList;
    }

    public ItensProtocoloMapa getItensMapa() {
        return itensMapa;
    }

    public void setItensMapa(ItensProtocoloMapa itensMapa) {
        this.itensMapa = itensMapa;
    }

    public HashMap<Integer, ItemMapa> getItensMapaMap() {
        return itensMapaMap;
    }

    public void setItensMapaMap(HashMap<Integer, ItemMapa> itensMapaMap) {
        this.itensMapaMap = itensMapaMap;
    }

    public DaoGenerico<ItensProtocoloMapa, Integer> getItensprotocolomapaDao() {
        return itensprotocolomapaDao;
    }

    public void setItensprotocolomapaDao(DaoGenerico<ItensProtocoloMapa, Integer> itensprotocolomapaDao) {
        this.itensprotocolomapaDao = itensprotocolomapaDao;
    }

    public ProtocoloMapa getProtocoloMapa() {
        return protocoloMapa;
    }

    public void setProtocoloMapa(ProtocoloMapa protocoloMapa) {
        this.protocoloMapa = protocoloMapa;
    }

    public HashMap<Integer, ProtocoloMapa> getMapaTranspMap() {
        return mapaTranspMap;
    }

    public void setMapaTranspMap(HashMap<Integer, ProtocoloMapa> mapaTranspMap) {
        this.mapaTranspMap = mapaTranspMap;
    }

    public DaoGenerico<ProtocoloMapa, Integer> getProtocolomapaDao() {
        return protocolomapaDao;
    }

    public void setProtocolomapaDao(DaoGenerico<ProtocoloMapa, Integer> protocolomapaDao) {
        this.protocolomapaDao = protocolomapaDao;
    }

    public Map<String, Object> getResponsavelItem() {
        return responsavelItem;
    }

    public void setResponsavelItem(Map<String, Object> responsavelItem) {
        this.responsavelItem = responsavelItem;
    }

    public DaoGenerico<ResponsavelEmpresa, Integer> getResponsavelempresaDao() {
        return responsavelempresaDao;
    }

    public void setResponsavelempresaDao(DaoGenerico<ResponsavelEmpresa, Integer> responsavelempresaDao) {
        this.responsavelempresaDao = responsavelempresaDao;
    }

    public DaoGenerico<NotaFiscal, Integer> getNotafiscalDao() {
        return notafiscalDao;
    }

    public void setNotafiscalDao(DaoGenerico<NotaFiscal, Integer> notafiscalDao) {
        this.notafiscalDao = notafiscalDao;
    }

    public DaoGenerico<Empresa, Integer> getEmpresaDao() {
        return empresaDao;
    }

    public void setEmpresaDao(DaoGenerico<Empresa, Integer> empresaDao) {
        this.empresaDao = empresaDao;
    }

    public Map<String, Object> getEmpresaItem() {
        return empresaItem;
    }

    public void setEmpresaItem(Map<String, Object> empresaItem) {
        this.empresaItem = empresaItem;
    }

    public Integer getNotaF() {
        return notaF;
    }

    public void setNotaF(Integer notaF) {
        this.notaF = notaF;
    }

    public DaoGenerico<Cliente, Integer> getClienteDao() {
        return clienteDao;
    }

    public void setClienteDao(DaoGenerico<Cliente, Integer> clienteDao) {
        this.clienteDao = clienteDao;
    }

    public Date getDataMapa() {
        return dataProtocolo;
    }

    public void setDataMapa(Date dataMapa) {
        this.dataProtocolo = dataMapa;
    }

    public DaoGenerico<Area, Integer> getAreaDao() {
        return areaDao;
    }

    public void setAreaDao(DaoGenerico<Area, Integer> areaDao) {
        this.areaDao = areaDao;
    }

    public Map<String, Object> getAreaItem() {
        return areaItem;
    }

    public void setAreaItem(Map<String, Object> areaItem) {
        this.areaItem = areaItem;
    }

    public Integer getQtdMapeo() {
        return qtdMapeo;
    }

    public void setQtdMapeo(Integer qtdMapeo) {
        this.qtdMapeo = qtdMapeo;
    }

    public Integer getQtdTotal() {
        return qtdTotal;
    }

    public void setQtdTotal(Integer qtdTotal) {
        this.qtdTotal = qtdTotal;
    }

    public Double getSubTotal() {
        return subTotal;
    }

    public void setSubTotal(Double subTotal) {
        this.subTotal = subTotal;
    }

    public Date getDataProtocolo() {
        return dataProtocolo;
    }

    public void setDataProtocolo(Date dataProtocolo) {
        this.dataProtocolo = dataProtocolo;
    }

    public ItemMapa getItemMapa() {
        return itemMapa;
    }

    public void setItemMapa(ItemMapa itemMapa) {
        this.itemMapa = itemMapa;
    }

    public Date getData1() {
        return data1;
    }

    public void setData1(Date data1) {
        this.data1 = data1;
    }

    public Date getData2() {
        return data2;
    }

    public void setData2(Date data2) {
        this.data2 = data2;
    }

    public int getMaxPorPagina() {
        return maxPorPagina;
    }

    public void setMaxPorPagina(int maxPorPagina) {
        this.maxPorPagina = maxPorPagina;
    }

    public List<ItemProtocoloBean> getItemsProtocoloBean() {
        return itemsProtocoloBean;
    }

    public void setItemsProtocoloBean(List<ItemProtocoloBean> itemsProtocoloBean) {
        this.itemsProtocoloBean = itemsProtocoloBean;
    }
   
}

Pagina  ---------------------------

<?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:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jstl/core"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:ajax="https://ajax4jsf.dev.java.net/ajax">

    <style>
        .scrolls{
            width:300px;
            height:200px;
            overflow:auto;
        }
    </style>
    <body>
        <ui:composition template="../layouts/template.xhtml">
            <ui:define name="content">
                <rich:tabPanel switchType="ajax" id="tabmapa">
                    <rich:tab label="Protocolo de Mapeamento de Transporte" id="mapatransporte">
                        <a4j:form ajaxSubmit="true" id="protocolo">
                            <rich:panel style="width:800px;height:150px">
                                <f:facet name="header">
                                    <h:outputText value="Dados para protocolo"/>
                                </f:facet>

                                <h:commandLink value="Imprimir" />
                                <h:panelGrid columns="2">
                                    <h:outputText  styleClass="rich-label"  rendered="false" value="Data do Protocolo" />
                                    <rich:calendar required="true" rendered="false"  value="#{protocolomapaController.protocoloMapa.data_prot}"
                                                   datePattern="dd/MM/yyyy"/>
                                    <h:outputText  styleClass="rich-label" value="Trasnportadora:" />
                                    <h:selectOneMenu  id="empresa"  required="true" default="Selecione Empresa"
                                                      value="#{protocolomapaController.protocoloMapa.codempr.codempr}"  >
                                        <f:selectItems length="30" value="#{protocolomapaController.empresa}"/>
                                    </h:selectOneMenu>
                                    <h:outputText  styleClass="rich-label" value="Responsável Transportadoura:" />
                                    <h:selectOneMenu  id="resp"  required="true"  value="#{protocolomapaController.protocoloMapa.responsavel.id}"  >
                                        <f:selectItems length="60" value="#{protocolomapaController.responsavel}"/>
                                    </h:selectOneMenu>
                                    <h:outputText  styleClass="rich-label" value="Obeservação:" />
                                    <h:inputText label="Observação"  id="obs" size="80"  value="#{protocolomapaController.protocoloMapa.obs}">
                                    </h:inputText>
                                    <h:panelGrid columns="1">
                                    </h:panelGrid>
                                </h:panelGrid>
                                <a4j:commandButton ajaxSingle="true" value="Inserir Notas"

                                                   oncomplete="#{rich:component('addnotas')}.show()" >

                                </a4j:commandButton>

                            </rich:panel>

                            <rich:messages style="color:red;"></rich:messages>


                            <rich:modalPanel id="addnotas" autosized="true" width="450">
                                <f:facet name="header">
                                    <h:outputText value="Adicionar Notas do Protocolo"/>
                                </f:facet>
                                <f:facet name="controls">
                                    <h:panelGroup>
                                        <h:graphicImage value="/img/close.png" id="hidelink"
                                                        styleClass="hidelink" />
                                        <rich:componentControl for="addnotas" attachTo="hidelink"
                                                               operation="hide" event="onclick" />
                                    </h:panelGroup>
                                </f:facet>
                                <rich:messages style="color:red;"></rich:messages>
                                <h:panelGrid columns="1">


                                    <h:panelGrid columns="3">
                                        <h:panelGrid columns="3">
                                            <h:outputText rendered="true"  styleClass="rich-label" value="Volume:" />
                                            <h:inputText  rendered="true" label="Volume"  id="volume" size="11" required="true"
                                            maxlength="11" value="#{protocolomapaController.vol}" >
                                                <f:validateLength minimum="1" maximum="11" />
                                             </h:inputText>
                                        </h:panelGrid>
                                        <h:panelGrid columns="3">
                                            <h:outputText  styleClass="rich-label" value="Nota Fiscal:" />
                                            <h:inputText label="Nota Fiscal" id="nfadd" size="6"  required="true" maxlength="6"
                                                         reRender="listnotas,valortotal,qtdtotal" value="#{protocolomapaController.notaF}">
                                                <a4j:support event="onchange"  action="#{protocolomapaController.adicionarNotaAoProtocoloMapa}"
                                                             ajaxSingle="true" focus="nfadd" reRender="listnotas,valortotal,qtdtotal" />
                                                <f:validateLength minimum="1" maximum="6" />
                                            </h:inputText>
                                        </h:panelGrid>
                                    </h:panelGrid>

                                </h:panelGrid>
                               
                            </rich:modalPanel>
                            <rich:panel style="width:800px;height:100px;backgroundColor=#F1F1F1" id="panelGrid"  >
                                <f:facet name="header">
                                    <h:outputText value="Informações adicionadas ao Protocolo"/>
                                </f:facet>

                                <h:panelGrid columns="2">

                                    <h:outputText  styleClass="rich-label" value="Valor Total Notas:" />
                                    <h:outputText styleClass="rich-label" id="valortotal"
                                                  value="#{protocolomapaController.protocoloMapa.subTotal}">
                                        <f:convertNumber type="currency" />
                                    </h:outputText>
                                </h:panelGrid>
                                <h:panelGrid columns="2">

                                    <h:outputText  styleClass="rich-label" value="Quantidade de Notas:" />
                                    <h:outputText styleClass="rich-label" id="qtdtotal"
                                                  value="#{protocolomapaController.protocoloMapa.qtdTotal}"/>
                                </h:panelGrid>
                                <h:panelGrid columns="2">
                                    <a4j:commandButton value="Gravar"   action="#{protocolomapaController.gravarProtocoloMapa}" ajaxSubmit="true"
                                                       reRender="listnotas,valortotal,qtdtotal"/>
                                </h:panelGrid>
                            </rich:panel>
                            <br/>
                            <a4j:region selfRendered="true">

                                <rich:dataTable  onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
                                                 onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                                                 cellpadding="0"  border="0" var="item" frozenColCount="1"
                                                 height="10px" width="800px" id="listnotas"  columnClasses="col"
                                                 value="#{protocolomapaController.todos}"   sortMode="single" >
                                    <rich:column id="numnf">
                                        <f:facet name="header"><h:outputText styleClass="headerText" value="Numero da Nota" /></f:facet>
                                        <h:outputText value="#{item.nf}"  />
                                    </rich:column>
                                    <rich:column id="cliente">
                                        <f:facet name="header"><h:outputText  styleClass="headerText" value="Cliente" /></f:facet>
                                        <h:outputText value="#{item.cliente}"  />
                                    </rich:column>
                                    <rich:column id="vol">
                                        <f:facet name="header"><h:outputText  styleClass="headerText" value="Volume" /></f:facet>
                                        <h:outputText value="#{item.volume}"   />
                                    </rich:column>
                                    <rich:column id="valor">
                                        <f:facet name="header"><h:outputText  styleClass="headerText" value="Valor da Nota" /></f:facet>
                                        <h:outputText value="#{item.valor}"   />
                                    </rich:column>
                                    <rich:column id="action">
                                        <f:facet name="header"><h:outputText  styleClass="headerText" value="Excluir" /></f:facet>
                                        <center><a4j:commandLink  reRender="listnotas,valortotal,qtdtotal"
                                                                      action="#{protocolomapaController.removerItensMapa}">
                                        <h:graphicImage value="/img/error.gif" border="0" /></a4j:commandLink></center>

                                    </rich:column>

                                </rich:dataTable>

                            </a4j:region>
                            <h:messages/>
                        </a4j:form>
                    </rich:tab>
                </rich:tabPanel>
            </ui:define>
        </ui:composition>

    </body>
</html>



 


Victor Lima
   - 24 nov 2009

 ???????

0
|
0

Dyego Carmo
   - 25 nov 2009

Opa , aqui estao exemplos:

http://marcgrabanski.com/pages/code/jquery-ui-datepicker


Outros exemplos :

http://www.queness.com/post/656/10-beautiful-jquery-and-mootool-calendar-plugins


0
|
0

Victor Lima
   - 02 dez 2009

Boa tarde Diego,

Esse link é para outro post correto ?

O que estou querendo fazer é atraves de um imput setar uma variavel, mas ela nao vai, so se eu colocar um botao de submit.


obrigado

0
|
0

Dyego Carmo
   - 11 dez 2009

Voce só consegue setar com botao submit mesmo , ou utilizando AJAX (que vai fazer a mesma coisa por debaixo dos panos)

Espero ter ajudado.

0
|
0

Leandro Muller
   - 14 jan 2010

Victor poderia me passar esses fontes para estudo ?

web2ajax@gmail.com

Obrigado

0
|
0

Victor Lima
   - 20 jan 2010


 Bom dia.

 Voce pode se basear pelo site http://livedemo.exadel.com/richfaces-demo/index.jsp ,  se nao for suficiente para atender suas regras de negocio, me diz sua duvida que tento na medida do possivel te ajudar.

 atenciosamente

 Victor Augusto

0
|
0