Java Reference
In-Depth Information
<f:facet
name="header">Action</f:facet>
<h:commandButton id="book"
action="#{theatreBooker.bookSeat(_seat.id)}"
disabled="#{_seat.booked}"
value="#{_seat.booked ? 'Not
Available' : 'Book'}"/>
</h:column>
</rich:dataTable>
<h:outputText value="Booked seats on this page:
#{bookingRecord.bookedCount}" id="bookedCounter" />
</rich:panel>
</h:form>
</f:view>
</ui:define>
</ui:composition>
We have highlighted the core enhancements added to this page. At first, as we said, we
need to reference the RichFaces libraries at the top of the XHTML page.
Next, we added a rich Ajax component, a4j:poll , which does a simple but an effective job
of polling the server for updates, allowing the re-rendering of our components— grid
(which contains the main datatable), poller (to check whether it should still be run-
ning), and bookedCounter .
Additionally, this component references a CDI bean named Poller , which acts just as
an on/off flag for our poller. We expect to turn off polling as soon as all the seats are sold
out:
package com.packtpub.wflydevelopment.chapter4.controller;
import java.util.Optional;
import javax.enterprise.inject.Model;
import javax.inject.Inject;
import
com.packtpub.wflydevelopment.chapter4.boundary.TheatreBox;
Search WWH ::




Custom Search