Erro chato: Base is null

Galera,

Eu tenho o codigo abaixo para cadastro :


  <h:form id="form1">
                    <h:panelGrid columns="1">
                        <h:outputText value="" />
                        <h:inputText size="15" id="nome" 
                                     value="#{nw.cliente.nome['teste']}" />
                        <h:message for="nome"/>
                        <h:outputText value="" />
                        <h:inputText size="15" id="email"
                                     value="#{nw.cliente.email}" />
                        <h:message for="email"/>
                    </h:panelGrid>
                    <div class="news"
                         <h:commandButton image="images/salvarz3.gif"
                                          value="Salvar"
                                          action="#{nw.salvar}" />
                </div>
            </div>
        </h:form>

…E…

..
public class cadC2010 {

        private Cliente cliente;

    public Cliente getCliente() {
        return cliente;
    }

    public void setCliente(Cliente cliente) {
        this.cliente = cliente;
    }
    
    public String novo(){ 
        this.cliente = new Cliente();
        return "novo";
    }
    public String salvar() throws Exception{
                DAO dao = new ClienteDAOImp();
                dao.salvar(cliente);
            return "salvar";
        }   
}


..


faces-config

..
..
<managed-bean>
                  <managed-bean-name>nw</managed-bean-name>
        <managed-bean-class>br.com.Controler.cadC2010</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>

<navigation-rule>
        <from-view-id>/news/menu.jsp</from-view-id>
        <navigation-case>
            <from-outcome>novo</from-outcome>
            <to-view-id>/news/form.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <navigation-rule>
        <from-view-id>/news/form.jsp</from-view-id>
        <navigation-case>
            <from-outcome>cancelar</from-outcome>
            <to-view-id>/news/cancelado.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>salvar</from-outcome>
            <to-view-id>/news/cancelado.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
..

Quando clico em salvar, esta ocorrendo o erro abaixo:

…Erro

..

javax.faces.el.PropertyNotFoundException: Base is null: .cliente
	at org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:477)
	at org.apache.myfaces.el.ValueBindingImpl.getType(ValueBindingImpl.java:175)
	at org.apache.myfaces.shared_impl.renderkit._SharedRendererUtils.findUIOutputConverter(_SharedRendererUtils.java:58)
	at org.apache.myfaces.shared_impl.renderkit.RendererUtils.findUIOutputConverter(RendererUtils.java:310)
	at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getConvertedUIOutputValue(RendererUtils.java:604)
	at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.getConvertedValue(HtmlTextRendererBase.java:191)
	at javax.faces.component.UIInput.getConvertedValue(UIInput.java:396)
	at javax.faces.component.UIInput.validate(UIInput.java:350)
..

Nao sei se porque o arquivo form.jsp esta fora da pasta /news (esta na raiz)

Voces sabem o que pode ser?

Certifique-se que:

1- você declarou o teu mbean de forma correta e o está referenciando conforme declarado

2- caso esteja unsando algum POJO para representar os dados na tela, o objeto foi instanciado!!

[quote=fabio.aurelio]Galera,

Eu tenho o codigo abaixo para cadastro :


  <h:form id="form1">
                    <h:panelGrid columns="1">
                        <h:outputText value="" />
                        <h:inputText size="15" id="nome" 
                                     value="#{nw.cliente.nome['teste']}" />
                        <h:message for="nome"/>
                        <h:outputText value="" />
                        <h:inputText size="15" id="email"
                                     value="#{nw.cliente.email}" />
                        <h:message for="email"/>
                    </h:panelGrid>
                    <div class="news"
                         <h:commandButton image="images/salvarz3.gif"
                                          value="Salvar"
                                          action="#{nw.salvar}" />
                </div>
            </div>
        </h:form>

…E…

..
public class cadC2010 {

        private Cliente cliente;

    public Cliente getCliente() {
        return cliente;
    }

    public void setCliente(Cliente cliente) {
        this.cliente = cliente;
    }
    
    public String novo(){ 
        this.cliente = new Cliente();
        return "novo";
    }
    public String salvar() throws Exception{
                DAO dao = new ClienteDAOImp();
                dao.salvar(cliente);
            return "salvar";
        }   
}


..


faces-config

..
..
<managed-bean>
                  <managed-bean-name>nw</managed-bean-name>
        <managed-bean-class>br.com.Controler.CliController</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>

<navigation-rule>
        <from-view-id>/news/menu.jsp</from-view-id>
        <navigation-case>
            <from-outcome>novo</from-outcome>
            <to-view-id>/news/form.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <navigation-rule>
        <from-view-id>/news/form.jsp</from-view-id>
        <navigation-case>
            <from-outcome>cancelar</from-outcome>
            <to-view-id>/news/cancelado.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>salvar</from-outcome>
            <to-view-id>/news/cancelado.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
..

Quando clico em salvar, esta ocorrendo o erro abaixo:

…Erro

..

javax.faces.el.PropertyNotFoundException: Base is null: .cliente
	at org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:477)
	at org.apache.myfaces.el.ValueBindingImpl.getType(ValueBindingImpl.java:175)
	at org.apache.myfaces.shared_impl.renderkit._SharedRendererUtils.findUIOutputConverter(_SharedRendererUtils.java:58)
	at org.apache.myfaces.shared_impl.renderkit.RendererUtils.findUIOutputConverter(RendererUtils.java:310)
	at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getConvertedUIOutputValue(RendererUtils.java:604)
	at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.getConvertedValue(HtmlTextRendererBase.java:191)
	at javax.faces.component.UIInput.getConvertedValue(UIInput.java:396)
	at javax.faces.component.UIInput.validate(UIInput.java:350)
..

Nao sei se porque o arquivo form.jsp esta fora da pasta /news (esta na raiz)

Voces sabem o que pode ser?[/quote]

Opa… tudo bem?

No mapeamento do teu managed bean tu passou a classe CliController e pela tua implementação na jsp seria a classe “cadC2010” que inclusive poderias alterar esse nome…

<managed-bean>
         <managed-bean-name>nw</managed-bean-name>
        <managed-bean-class>br.com.Controler.CliController</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>

Abs… espero ter ajudado

sorry …

O mapeamento esta correto, eu que errei na hora de digitar aqui.

Conferi a instancia e esta tudo correto, mas ainda nao achei o que causa este erro …