Problema com PrimeFaces e JSF 2.0

Galera,

Tenho o seguinte codigo

   <p:dialog header="Detalhes do Comando" widgetVar="comandoDialog" resizable="false"
                      width="400"  height="400" showEffect="slide" >

                <h:panelGrid id="display" columns="2" cellpadding="4">

                    <h:outputText value="Nome:" />
                    <h:outputText value="#{comandoControle.comando.nome}" />

                    <h:outputText value="Comando:" />
                    <h:outputText value="#{comandoControle.comando.comando}" />

                    <h:outputText value="Descrição:" />
                    <h:outputText value="#{comandoControle.comando.descricao}" />
                </h:panelGrid>
            </p:dialog>

Desse jeito funciona beleza, sem problemas.]
mas quando eu faço isso:

 <p:dialog header="Detalhes do Comando" widgetVar="comandoDialog" resizable="false"
                      width="400"  height="400" showEffect="slide" >

                <h:panelGrid id="display" columns="2" cellpadding="4">

                    <h:outputText value="Nome:" />
                    <h:inputText value="#{comandoControle.comando.nome}" />

                    <h:outputText value="Comando:" />
                    <h:inputText value="#{comandoControle.comando.comando}" />

                    <h:outputText value="Descrição:" />
                    <h:inputText value="#{comandoControle.comando.descricao}" />
                </h:panelGrid>
            </p:dialog>

não funciona de jeito nenhum.
Da o seguinte erro:

Caused by: javax.el.PropertyNotFoundException: /paginas/crud/comando.xhtml @62,76 value="#{comandoControle.comando.nome}": Target Unreachable, 'comando' returned null

Por que com o h:outputText funciona blza e ja com o h:inputText da essa zica.

Abaixo o meu codigo completo

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../../templates/template2.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core">


    <ui:define name="content">
        <h:form prependId="false">
            <h:outputLabel value="#{comandoControle.titulo}" style="font-size: 24px; font-weight: bold"/>
            <p:spacer height="20" />
            <p:ajaxStatus style="height:24px;display:block;">
                <f:facet name="start">
                    <h:graphicImage value="./../../images/ajaxwait.gif" />
                </f:facet>
                <f:facet name="complete">
                    <h:outputText value="" />
                </f:facet>
            </p:ajaxStatus>
            <p:spacer height="10" />
            <p:dataTable var="comandos" value="#{comandoControle.listarComandos}" paginator="true" rows="10">

                <p:column>
                    <f:facet name="header">
                        <h:outputText value="Nome" />
                    </f:facet>
                    <h:outputText value="#{comandos.nome}" />
                </p:column>

                <p:column>
                    <f:facet name="header">
                        <h:outputText value="Comando" />
                    </f:facet>
                    <h:outputText value="#{comandos.comando}" />
                </p:column>

                <p:column>
                    <f:facet name="header">
                        <h:outputText value="Descrição" />
                    </f:facet>
                    <h:outputText value="#{comandos.descricao}" />
                </p:column>

                <p:column style="width:32px">
                    <p:commandButton update="display" oncomplete="comandoDialog.show()"
                                     image="ui-icon ui-icon-search">
                        <f:setPropertyActionListener value="#{comandos}"
                                                     target="#{comandoControle.comando}" />
                    </p:commandButton>
                </p:column>

            </p:dataTable>

            <p:dialog header="Detalhes do Comando" widgetVar="comandoDialog" resizable="false"
                      width="400"  height="400" showEffect="slide" >

                <h:panelGrid id="display" columns="2" cellpadding="4">

                    <h:outputText value="Nome:" />
                    <h:inputText value="#{comandoControle.comando.nome}" />

                    <h:outputText value="Comando:" />
                    <h:inputText value="#{comandoControle.comando.comando}" />

                    <h:outputText value="Descrição:" />
                    <h:inputText value="#{comandoControle.comando.descricao}" />
                </h:panelGrid>
            </p:dialog>
        </h:form>
    </ui:define>
</ui:composition>

O meu bean esta como Session e esta Serializado tambem.

Coloque o codigo da classe “ComandoControle” e tambem de “Comando”

Classe ComandoControle

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

import br.com.ces.svias.constante.Constantes;
import br.com.ces.svias.dao.impl.ComandoDAO;
import br.com.ces.svias.exception.SViasException;
import br.com.ces.svias.logger.SViasLogger;
import br.com.ces.svias.modelo.Comando;
import java.awt.event.ActionEvent;
import java.io.Serializable;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;


@ManagedBean(name = "comandoControle")
@SessionScoped
public class ComandoControle extends Controle implements Serializable {

    private Comando comando;
 
    public ComandoControle() {
        this.setTitulo("Gerenciador de Comandos");
        this.setNovoRegistro("Novo Comando");
    }

    public List<Comando> getListarComandos() {
        try {
           List<Comando> listaDeComandos = new ComandoDAO().buscarTodosOsRegistros();
            return listaDeComandos;
        } catch (SViasException ex) {
            SViasLogger.logError("ComandoControle-getListarComandos", ex);
            this.addError("Comando", ex.getMessage());
        }
        return null;
    }

    public void prepararAdicionarComando(ActionEvent actionEvent) {
        comando = new Comando();
    }

    public void excluirComando(ActionEvent actionEvent) {
        try {
            ComandoDAO dao = new ComandoDAO();
            dao.excluir(comando.getId());
            this.addInfo("Comando", Constantes.REGISTRO_EXCLUIDO_OK);
        } catch (SViasException ex) {
            SViasLogger.logError("ComandoControle-excluirComando", ex);
            this.addError("Comando", Constantes.REGISTRO_EXCLUIDO_ERRO + ex.getMessage());
        }
    }

    public void alterarComando(ActionEvent actionEvent) {
        try {
            if (!validarCampos()) {
                return;
            }
            ComandoDAO dao = new ComandoDAO();
            dao.editar(comando);
            this.addInfo("Comando", Constantes.REGISTRO_ALTERADO_OK);
        } catch (SViasException ex) {
            SViasLogger.logError("ComandoControle-alterarComando", ex);
            this.addError("Comando", Constantes.REGISTRO_ALTERADO_ERRO + ex.getMessage());
        }
    }

    public void adicionarComando(ActionEvent actionEvent) {
        try {
            if (!validarCampos()) {
                return;
            }
            ComandoDAO dao = new ComandoDAO();
            dao.salvar(comando);
            this.addInfo("Comando", Constantes.REGISTRO_ADICIONADO_OK);
        } catch (SViasException ex) {
            SViasLogger.logError("ClienteComando-adicionarComando", ex);
            this.addError("Comando", Constantes.REGISTRO_ADICIONADO_ERRO + ex.getMessage());
        }

    }

    private boolean validarCampos() {
        String camposObrigatorios = null;

        int cont = 0;
        if (comando.getNome() == null || comando.getNome().isEmpty()) {
            camposObrigatorios = camposObrigatorios + " Nome " + this.complementoCampoObrigatorio;
            cont++;
        }
        if (comando.getDescricao() == null || comando.getDescricao().isEmpty()) {
            camposObrigatorios = camposObrigatorios + " Descrição " + this.complementoCampoObrigatorio;
            cont++;
        }
        if (comando.getComando() == null || comando.getComando().isEmpty()) {
            camposObrigatorios = camposObrigatorios + " Comando " + this.complementoCampoObrigatorio;
            cont++;
        }

        if (cont > 0) {
            this.addError("Comando", camposObrigatorios);
            return false;
        }

        return true;
    }

    public Comando getComando() {
        return comando;
    }

    public void setComando(Comando comando) {
        this.comando = comando;
    }
}

Classe comando

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.ces.svias.modelo;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;


@Entity
@Table(name = "comando")
public class Comando implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idcomando")
    private Integer id;
    @Column(name = "nome")
    private String nome;
    @Column(name = "comando")
    private String comando;
    @Column(name = "descricao")
    private String descricao;
   

    public Comando() {
    }

    public Comando(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getComando() {
        return comando;
    }

    public void setComando(String comando) {
        this.comando = comando;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Comando)) {
            return false;
        }
        Comando other = (Comando) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.ces.svias.persistencia.Comando[id=" + id + "]";
    }

}

O problema e que o InputText esta tentando acessar a variavel NOME dentro de COMANDO… mas nao consegue porque COMANDO esta nulo…

da uma olhada no seu codigo e veja se COMANDO esta inicializado!!

private Comando comando = new Comando();

Funcinou desse jeito que vc falou.

Mas pq quando eu uso o outputText funciona e quando eu uso inputText tenho que iniciar a minha variavel?

Att

[quote=vcsmetallica]Funcinou desse jeito que vc falou.

Mas pq quando eu uso o outputText funciona e quando eu uso inputText tenho que iniciar a minha variavel?

Att[/quote]

E porque o Output text e uma tag de exibicao… nao precisa ser modificado… ou melhor… nao chama o metodo SET…

por isso ele retorna nulo para a tela sem problemas…

Pessoal, sei que o tópico já é bem velho, mas estou com uma dúvida relacionada a ele.

O que determina se o método chamado será o getXXX ou o setXXX é o componente jsf? No caso o componente:

&lt;h:outputText ... /&gt;  

só chama métodos getXXX e o componente:

&lt;h:inputText ... /&gt;

só chama métodos setXXX seria isso pra todos os componentes baseados em jsf e jstl?