How to Call Other Class Values

3

I am creating a vehicle control, and in it I have a Fuel register that has description and value, and another cadastre of Supplies. In my supply register has a autoComplete of Fuel. The problem starts here, when I select the fuel I need to call the cost value that is entered in this fuel.

Example: I selected Diesel.

TOTAL = Valor * LitrosAbastecidos.

However, the Valor variable is within the Fuel class. Would anyone have a simple way to solve this?

Note: System made in Java, Hibernate, JSF

Call 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);
}
    
asked by anonymous 16.11.2016 / 13:39

1 answer

2

Leandro, when you call the fuel you apparently arrow the fuel attribute of the supply object which is an attribute of the supply objectControl:

value="#{abastecimentoControle.abastecimento.combustivel}"

So I would do so within the supplying class Control:

Double total = this.getAbastecimento().getCombustivel().getValor() * litrosAbastecidos
    
16.11.2016 / 17:21