yet more polishing

This commit is contained in:
Keith Donald
2007-08-21 05:39:08 +00:00
parent b5f03191bb
commit dc38c83292
5 changed files with 16 additions and 8 deletions

View File

@@ -10,4 +10,5 @@ public interface BookingService {
public Hotel findHotelById(Long id);
public void cancelBooking(Long id);
}

View File

@@ -41,4 +41,12 @@ public class JpaBookingService implements BookingService {
public Hotel findHotelById(Long id) {
return em.find(Hotel.class, id);
}
@Transactional
public void cancelBooking(Long id) {
Booking booking = em.find(Booking.class, id);
if (booking != null) {
em.remove(booking);
}
}
}

View File

@@ -17,7 +17,7 @@ public class BookingActions extends MultiAction {
public Event createBooking(RequestContext context) {
Hotel hotel = (Hotel) context.getFlowScope().get("hotel");
User user = (User) context.getFlowScope().get("user");
User user = (User) context.getConversationScope().get("user");
Booking booking = new Booking(hotel, user);
EntityManager em = (EntityManager) context.getFlowScope().get("entityManager");
em.persist(booking);

View File

@@ -39,9 +39,4 @@ public class MainActions extends MultiAction {
context.getFlowScope().put("hotels", new SerializableListDataModel(hotels));
return success();
}
public Event removeBooking(RequestContext context) {
return success();
}
}

View File

@@ -34,8 +34,12 @@
<transition on="cancel" to="displayMain" />
</subflow-state>
<action-state id="removeBooking">
<action method="removeBooking" bean="mainActions" />
<action-state id="cancelBooking">
<bean-action method="cancelBooking" bean="bookingService">
<method-arguments>
<argument expression="param.bookingId" parameter-type="long"/>
</method-arguments>
</bean-action>
<transition on="success" to="reloadCurrentUserBookings" />
</action-state>