Boa tarde!
Estou com o seguinte problema:
Tenho a classe Funcionario e Motorista, (Motorista extends Funcionario)
Quero exibir o nome do motorista em um rich:ComboBox
Tenho a seguinte classe bean:
[code]public class CheckupBackingBean extends FacesUtil {
public List<SelectItem> getMotoristas() throws ErroGeralException
{//Inicio do método getMotoristas
// try{
Session session = HibernateSupport.getSession().getSessionFactory().openSession();
session.beginTransaction();
IDao motoristaDao = new DaoImpl(Motorista.class, session);
List motoristas = motoristaDao.findAll();
session.getTransaction().commit();
List<SelectItem> selectMotorista = new ArrayList<SelectItem>();
for(Motorista motorista: motoristas){
selectMotorista.add(new SelectItem(motorista.getIdFuncionario().toString(), motorista.getNome()));
}
return selectMotorista;
// }
// catch(ErroGeralException ex){
// addMessage(ex.getMessage(), ex.getCause().toString());
//}
// catch(Exception ex){
// ErroGeralException exc = new ErroGeralException(ex);
// addMessage(exc.getMessage(), exc.getCause().getMessage());
//}
}//Fim do método getMotoristas
}[/code]
O try catch está comentado pois com os mesmo ativos, ocorre um erro dizendo que não há retorno.;.
Quando não tenho motorista cadastrados ele “abre” a tela de checkup normalmente, porém quando cadastro algum motorista
acorre um erro: diz que #{checup.motorista} tem incompatibilidade de tipo.;.
alguém pode me ajudar?
desde já acradeço.;.
ibispo
Agosto 9, 2010, 12:14pm
#2
posta ae pra gente ver a tela de checkup onde vc faz referencia ao combo de motoristas.
Segue:
<?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">
<ui:composition 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"
xmlns:ajax="https://ajax4jsf.dev.java.net/ajax"
xmlns:richfaces="http://richfaces.ajax4jsf.org/rich">
<ui:composition template="/view/comum/template/areaRestrita/template.xhtml">
<ui:define name="conteudo">
<rich:tabPanel styleClass="tabPanelCheckup">
<rich:tab label="Checkup">
<h:form>
<h:panelGrid columns="2" styleClass="panelGridCheckup" dir="LTR" cellspacing="10">
<h:outputText value="Checkup:" style="font-weight:bold;"/>
<h:selectOneRadio value="" layout="pageDirection" styleClass="radioCheckup" style="float:left">
<f:selectItem itemValue="" itemLabel="Inicial"/>
<f:selectItem itemValue="" itemLabel="Final"/>
</h:selectOneRadio>
</h:panelGrid>
<h:panelGrid columns="2" styleClass="panelGridCheckup" dir="LTR" cellspacing="10">
<h:outputText value="Motorista:" style="font-weight:bold;" />
<rich:comboBox>
[color=red]<f:selectItems value="#{checkupBackingBean.motoristas}"/>[/color]
</rich:comboBox>
<h:outputText value="Placa:" style="font-weight:bold;" />
<h:inputText value="" size="10"/>
<h:outputText value="Km:" style="font-weight:bold;" />
<h:inputText value="" size="10"/>
</h:panelGrid>
<h:panelGrid columns="2" styleClass="panelGridCheckup" dir="LTR" cellspacing="10">
<h:outputText value="Veículo ok?" style="font-weight:bold;" />
<h:selectOneRadio value="" layout="lineDirection" styleClass="radioCheckup">
<f:selectItem itemValue="" itemLabel="Sim"/>
<f:selectItem itemValue="" itemLabel="Não"/>
</h:selectOneRadio>
</h:panelGrid>
<h:panelGrid columns="2" styleClass="panelGridCheckup" dir="LTR" cellspacing="10">
<h:outputText value="Observação: " style="font-weight:bold;" />
<h:inputTextarea rows="5" cols="30"/>
</h:panelGrid>
<rich:spacer height="10"/>
<h:panelGrid columns="2" style="float:right;">
<h:commandButton value="Confirmar" styleClass="btn" style="margin-right:7px;"/>
<h:commandButton value="Limpar" styleClass="btn" style="margin-right:20px" type="reset"/>
</h:panelGrid>
</h:form>
</rich:tab>
</rich:tabPanel>
</ui:define>
</ui:composition>
</ui:composition>