Tuesday, January 22, 2008

Boa Hamcock Nami Nico Robim



(Interceptor) Factories session to be recharged by events:

This will not reload the calls to the database:



@ Stateful @ Scope (SESSION)
@ Name ("bookingList)
@ Restrict (" # {identity.loggedIn} ") @ TransactionAttribute
(REQUIRES_NEW)
public class implements BookingListAction BookingList, Serializable {

.......


@ Factory @ Observer ("bookingConfirmed") public void
getBookings () {

em.createQuery bookings = ("select b from Booking b WHERE b.user.username = :username order by b.checkinDate")
.setParameter("username", user.getUsername())
.getResultList();
}
........
}
@Stateful
@Name("hotelBooking")
@Restrict("#{identity.loggedIn}")
public class HotelBookingAction implements HotelBooking
{
...

@End
public void confirm()
{
em.persist(booking);
facesMessages.add("#{messages.gracias}, #{user.name}, your confimation number for #{hotel.name} is #{booking.id}");
log.info("New booking: #{booking.id} for #{user.username}");
events.raiseTransactionSuccessEvent (bookingConfirmed ");}

...
}


0 comments:

Post a Comment