Bom dia, pessoal !
dei uma olhada na solução deste problema no forum, mas infelizmente não consegui resolver:
erro: javax.el.PropertyNotFoundException: /LancamentoForm.xhtml @22,69 value="#{lancamentoMB.lancamento.frota.id}": Target Unreachable, ‘frota’ returned null
xhtml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<f:view>
<ui:composition template="/template1.xhtml">
<ui:define name="dados">
<rich:panel>
<f:facet name="header">
<h:outputText value="Lançamentos de combustível" />
</f:facet>
<a4j:form>
<h:panelGrid columns="2">
<h:column>
<h:outputText value="Nº Frota: " />
</h:column>
<h:column>
<h:selectOneMenu value="#{lancamentoMB.lancamento.frota.id}">
<f:selectItems value="#{lancamentoMB.lancamentosfrota}" />
</h:selectOneMenu>
</h:column>
<h:column>
<h:outputText value="Motorista: " />
</h:column>
<h:column>
<h:selectOneMenu value="#{lancamentoMB.lancamento.motorista.id}">
<f:selectItems value="#{lancamentoMB.lancamentosmotorista}" />
</h:selectOneMenu>
</h:column>
<h:column>
<h:outputText value="Posto: " />
</h:column>
<h:column>
<h:selectOneMenu value="#{lancamentoMB.lancamento.posto.id}">
<f:selectItems value="#{lancamentoMB.lancamentosposto}" />
</h:selectOneMenu>
</h:column>
<h:column>
<h:outputText value="Responsável: " />
</h:column>
<h:column>
<h:inputText value="#{lancamentoMB.lancamento.resplan}"
style="width: 300px" />
</h:column>
<h:column>
<h:outputText value="Data atual: " />
</h:column>
<h:column>
<rich:calendar value="#{lancamentoMB.lancamento.datalan}" />
</h:column>
<h:column>
<h:outputText value="Hora: " />
</h:column>
<h:column>
<h:inputText value="#{lancamentoMB.lancamento.horalan}"
style="width: 200px" />
</h:column>
<h:column>
<h:outputText value="Km Anterior:: " />
</h:column>
<h:column>
<h:inputText value="#{lancamentoMB.lancamento.kmantlan}"
style="width: 200px" />
</h:column>
<h:column>
<h:outputText value="Km Atual: " />
</h:column>
<h:column>
<h:inputText value="#{lancamentoMB.lancamento.kmatuallan}"
style="width: 200px" />
</h:column>
<h:column>
<h:outputText value="Km Rodado: " />
</h:column>
<h:column>
<h:inputText value="#{lancamentoMB.lancamento.kmrodadolan}"
style="width: 200px" />
</h:column>
<h:column>
<h:outputText value="Qtde Abastecida: " />
</h:column>
<h:column>
<h:inputText value="#{lancamentoMB.lancamento.litrolan}"
style="width: 200px" />
</h:column>
<h:column>
<h:commandButton action="${lancamentoMB.salvar}" value="Salvar" />
</h:column>
</h:panelGrid>
</a4j:form>
</rich:panel>
</ui:define>
</ui:composition>
</f:view>
</html>
Bean
package controlador;
import java.util.ArrayList;
import java.util.List;
import javax.faces.model.SelectItem;
import modelo.Frota;
import modelo.Lancamento;
import modelo.Motorista;
import modelo.Posto;
import DAO.FrotaDAO;
import DAO.LancamentoDAO;
import DAO.MotoristaDAO;
import DAO.PostoDAO;
public class LancamentoMB {
private Lancamento lancamento = new Lancamento();
private List<SelectItem> lancamentosposto;
private List<SelectItem> lancamentosfrota;
private List<SelectItem> lancamentosmotorista;
public LancamentoMB() {
super();
}
public void salvar() {
LancamentoDAO.getInstance().salvar(lancamento);
}
public Lancamento getLancamento() {
if (lancamento == null) {
lancamento = new Lancamento();
lancamento.setFrota(new Frota());
lancamento.setMotorista(new Motorista());
lancamento.setPosto(new Posto());
}
return lancamento;
}
public void setLancamento(Lancamento lancamento) {
this.lancamento = lancamento;
}
public List<SelectItem> getLancamentosfrota() {
if (this.lancamentosfrota == null) {
this.lancamentosfrota = new ArrayList<SelectItem>();
List<Frota> fro = FrotaDAO.getInstance().getAll();
for (Frota frota : fro) {
SelectItem item = new SelectItem(frota.getId(), frota
.getPlacafrota());
this.lancamentosfrota.add(item);
}
}
return lancamentosfrota;
}
public void setLancamentosfrota(List<SelectItem> lancamentosfrota) {
this.lancamentosfrota = lancamentosfrota;
}
public List<SelectItem> getLancamentosposto() {
if (this.lancamentosposto == null) {
this.lancamentosposto = new ArrayList<SelectItem>();
List<Posto> pos = PostoDAO.getInstance().getAll();
for (Posto posto : pos) {
SelectItem item = new SelectItem(posto.getId(), posto
.getDescpos());
this.lancamentosposto.add(item);
}
}
return lancamentosposto;
}
public void setLancamentosposto(List<SelectItem> lancamentosposto) {
this.lancamentosposto = lancamentosposto;
}
public List<SelectItem> getLancamentosmotorista() {
if (this.lancamentosmotorista == null) {
this.lancamentosmotorista = new ArrayList<SelectItem>();
List<Motorista> mot = MotoristaDAO.getInstance().getAll();
for (Motorista motorista : mot) {
SelectItem item = new SelectItem(motorista.getId(), motorista
.getNommot());
this.lancamentosmotorista.add(item);
}
}
return lancamentosmotorista;
}
public void setLancamentosmotorista(List<SelectItem> lancamentosmotorista) {
this.lancamentosmotorista = lancamentosmotorista;
}
}
Será que alguem poderia me ajudar ?
Grato