[RESOLVIDO]ListDataModel.getWrappedData NullPointerException

2 respostas
w1l14n

Bom tarde Galera,

Estou tendo um problema ao capturar o ListDataModel da minha página através do comando: getWrappedData.

É lançado NullPointerException quando vou iterar o meu list construído a partir do método getWrappedData.

Lembrando que os dados estão corretamente preenchidos no meu ListDataModel da página.

Minha página está assim:

<t:dataTable id="lstParticipantes" var="lstParticipantes" value="#{cadParticipanteBean.listaParticipantes}" styleClass="tabela_cadastro" headerClass="cabecalho" width="780px">
                     <t:column width="8%">
                        <center>
                           <f:facet name="header">
                              <h:outputText value="Convidar"/>
                           </f:facet>
                           <h:selectBooleanCheckbox id="selecionado" value="#{lstParticipantes.selecionado}"/>
                        </center>
                     </t:column>

                     <t:column width="37%">
                        <center>
                           <f:facet name="header">
                              <h:outputText value="Nome Completo"/>
                           </f:facet>
                        </center>
                        <h:outputText id="nomeCompleto" value="#{lstParticipantes.nomeCompleto}"/>
                     </t:column>

                     <t:column width="25%">
                        <center>
                           <f:facet name="header">
                              <h:outputText value="Cargo"/>
                           </f:facet>
                        </center>
                        <h:outputText id="dscCargo" value="#{lstParticipantes.dscCargo}"/>
                     </t:column>

                     <t:column width="25%">
                        <center>
                           <f:facet name="header">
                              <h:outputText value="E-mail"/>
                           </f:facet>
                        </center>
                        <h:outputText id="email" value="#{lstParticipantes.email}"/>
                     </t:column>

                  </t:dataTable>

Aqui o código do botão salvar:

<h:commandButton id="btnSalvar" value="Salvar" styleClass="cmdBotao" action="#{cadParticipanteBean.cadastrar}"/>

Que chama este método abaixo no meu Bean:

public String cadastrar()
   {
      try {
         List<ListaParticipanteBean> _listaParticipantes = (List<ListaParticipanteBean>) getListaParticipantes().getWrappedData();
         for (ListaParticipanteBean participante : _listaParticipantes) {
            if ((participante.getSelecionado() != null) &&
                    participante.getSelecionado() &&
                    (participante.getIdParticipante().equals(0)) &&
                    (participante.getIdCargo().equals(this.getCargo().getIdCargo()) || (this.getCargo().getIdCargo().equals(0)))) {
               participante.setIdReuniao(this.getReuniao().getIdReuniao());
               new ParticipanteDao(this.getReuniao().getIdReuniao()).salvar(participante);
            }
            else if ((participante.getSelecionado() != null) &&
                    (!participante.getSelecionado()) &&
                    (participante.getIdParticipante() > 0) &&
                    (participante.getIdCargo().equals(this.getCargo().getIdCargo()) || (this.getCargo().getIdCargo().equals(0)))) {
               new ParticipanteDao(this.getReuniao().getIdReuniao()).excluir(participante);
            }
         }
         this.populaTabela();
         FacesContext.getCurrentInstance().addMessage(null,new FacesMessage(FacesMessage.SEVERITY_INFO,"Participantes salvos com sucesso.",null));
      }
      catch (SQLException e) {
         FacesContext.getCurrentInstance().addMessage(null,new FacesMessage(FacesMessage.SEVERITY_ERROR,e.getMessage(),null));
      }
      catch (Exception e) {
         FacesContext.getCurrentInstance().addMessage(null,new FacesMessage(FacesMessage.SEVERITY_ERROR,e.getMessage(),null));
      }
      return null;
   }

2 Respostas

w1l14n

Alguém para ajudar?

w1l14n

Consegui resolver.

Caso alguém queira a solução é só avisar via MP!

Criado 25 de agosto de 2009
Ultima resposta 27 de ago. de 2009
Respostas 2
Participantes 1