Witam,
Mam problem z wrzuceniem do controllera wartości przechowywanej we flash. O ile mogę korzystać z obiektu który jest w nim przechowywany to jak chcę
przerzucić wartość przez command link to nie działa. Wydaje mi się że próbowałem już wszystkiego ale nadal nic. Z góry dzięki za odp.
orderController jest @named i bean jest @RequestScoped
<!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://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Order Creator</title>
</h:head>
<h:body>
ORDER CREATOR - choose car
<h:form>
Chosen Customer: <h:outputText id ="customerId" value="#{flash.customerChosen.id}" />
<h:outputText value="#{flash.customerChosen.name}" />
<h:outputText value="#{flash.customerChosen.surname}" />
<h:dataTable value="#{carController.carList}" var="car" border="1">
<h:column>
<f:facet name="header">
<h:outputText value="Id" />
</f:facet>
<h:outputText value="#{car.id}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Brand" />
</f:facet>
<h:outputText value="#{car.brand}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Model" />
</f:facet>
<h:outputText value="#{car.model}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Price" />
</f:facet>
<h:outputText value="#{car.price}" />
</h:column>
<h:column>
<f:facet name="header">Option</f:facet>
<!-- <h:commandLink
action="#{orderController.createOrder(customerId, car)}"
onclick="return confirm('Are you sure?')" value="Choose" />
-->
<h:commandLink value="Click here"
action="#{orderController.createOrder}">
<f:setPropertyActionListener
target="#{orderController.chosenCustomerId}"
value="#{flash.customerChosen.id}" />
<f:setPropertyActionListener target="#{orderController.chosenCar}"
value="#{car.id}" />
</h:commandLink>
</h:column>
</h:dataTable>
</h:form>
<br />
<h:form>
<h:link outcome="ordersMenu.xhtml" value="Back to Order menu" />
<br />
<br />
<h:link outcome="index.xhtml" value="Back to Main menu" />
</h:form>
</h:body>
</html>