I don’t know if it’s what you need, but I did something about it:
<p:commandButton value="Reserva" action="#{locadoraBean.reservarVeiculo}" oncomplete="PF('reserva').show();" />
<p:dialog id="mod" modal="true" widgetVar="reserva"
header="Confirmação da Reserva" draggable="false" closable="true" autoUpdate="true">
<h:form id="rent-car-dialog">
<div class="modal-content">
<p:panelGrid columns="2">
<f:facet name="header">
<p:graphicImage url="/RESOURCES/images/background/toyota_etios.png" />
</f:facet>
<h:outputText value="Veículo:" style="font-weight:bold;"/>
<h:outputText value="Toyota Etios" />
<h:outputText value="Ano/Modelo:" style="font-weight:bold;"/>
<h:outputText value="2018/2019" />
<h:outputText value="Cor:" style="font-weight:bold;"/>
<h:outputText value="Prata" />
<h:outputText value="Placa:" style="font-weight:bold;"/>
<h:outputText value="XXX-0000" />
<h:outputText value="Combustível:" style="font-weight:bold;"/>
<h:outputText value="Flex" />
<h:outputText value="Reservado em nome:" style="font-weight:bold;"/>
<h:outputText value="Fulano de Tal" />
<h:outputText value="Retirada prevista:" style="font-weight:bold;"/>
<h:outputText value="14/06/2019 12:15:00" />
<h:outputText value="Devolução prevista:" style="font-weight:bold;"/>
<h:outputText value="18/06/2019 12:15:00" />
</p:panelGrid>
</div>
</h:form>
</p:dialog>
In the above example, the method reservarVeiculo not doing anything, just exemplifying, because I created a dialog with data static. From what I understand you want to perform the action of a button, right after calling a screen, so when you choose the reservation information and click on Book, the reservation should be made and then a screen should appear with the information of the reservation made.
I hope I’ve helped, anything just ask again.
Thank you very much for your reply. I managed to make the method work without javascript, in case within the method in Java reservarEtios I put a Return with the name of the other page, then it does the redirecting. Now, would you like to tell me if in java there’s any way I can capture the id of that button that calls the method? Thanks again
– Guilherme Miguel
I believe so, but what purpose would it serve?
– Well Silva
Because I need a method that passes to DAO class the ID of the car, each boot is equivalent to a car so each one has an ID, I would like to pass this ID.
– Guilherme Miguel