3
I am creating a vehicle control, and in it I have a register of Fuel that has description and value, and another record of Supplies. My supply record has a autoComplete of Fuel. The problem starts here, when I select the fuel I need to call the cost value that is registered in this fuel.
Example: I selected Diesel.
TOTAL = Valor * LitrosAbastecidos.
But the variable Valor is in the Fuel class.
Would someone have some simple way to solve this?
Note: System made in Java, Hibernate, JSF
Calls to the Combustible
<p:autoComplete id="combustivel" value="#{abastecimentoControle.abastecimento.combustivel}" completeMethod="#{combustivelControle.listaFiltrando}"
                                       converter="#{combustivelControle.combustivelConverter}"
                                       var="c"
                                       disabled="true"
                                       itemValue="#{c}"
                                       itemLabel="#{c.descricao}"/>
My Filtering List
public List<Combustivel> listaFiltrando(String parte){
    System.out.println("Parte: "+parte);
    return combustivelFacade.listaFiltrando(parte);
}
How are you doing this? select in the database ? in a java list? try to edit your question in more detail.
– Marco Souza
I edited it, man, if you need any more details
– Leandro Santos
I found your question somewhat confusing. I couldn’t understand exactly what it is you’re asking or what it is you’re trying to do. Maybe if you give more details about the class
Combustivel, get better at understanding.– Victor Stafusa
My fuel class has: Id, description and value. In my supply I will have to select the fuel take the value of this selected fuel and do the bill. My difficulty is how to get the value of the selected fuel.
– Leandro Santos
You could implement a call via ajax in the "onChange" method of your field and fetch fuel from the selected object...
– Dante
How would you do that ?
– Leandro Santos