Java Reference
In-Depth Information
{
logger.log(Level.INFO, "PaymentHandler - Credit Handler:
{0}",
event.toString());
// call a specific Credit handler class...
}
public void debitPayment(@Observes @Debit PaymentEvent event) {
logger.log(Level.INFO, "PaymentHandler - Debit Handler:
{0}",
event.toString());
// call a specific Debit handler class...
}
}
Each observer method takes as an argument the event, annotated with @Observes and
with the qualifier for the type of payment. In a real application, the observer methods
would pass the event information on to another component that would perform business
logic on the payment.
The qualifiers are defined in the payment package, described in “ The billpayment
Facelets Pages and Managed Bean on page 281 .
Like PaymentEvent , the PaymentHandler bean is annotated @Logged , so that all
its methods can be intercepted.
The billpayment Facelets Pages and Managed Bean
The billpayment example contains two Facelets pages, index.xhtml and the very
simple response.xhtml . The body of index.xhtml looks like this:
Click here to view code image
<h:body>
<h3>Bill Payment Options</h3>
<p>Type an amount, select Debit Card or Credit Card,
then click Pay.</p>
<h:form>
<p>
<h:outputLabel value="Amount: $" for="amt"/>
<h:inputText id="amt" value="#{paymentBean.value}"
required="true"
requiredMessage="An amount is required."
maxlength="15" />
</p>
Search WWH ::




Custom Search