home | create | search | help
  1. package hhsystem.landlord;
  2.  
  3. import hhsystem.holidayhome.HolidayHome;
  4.  
  5. import java.util.HashMap;
  6. import java.util.Map;
  7.  
  8. import javax.servlet.http.HttpServletRequest;
  9. import javax.servlet.http.HttpServletResponse;
  10.  
  11. import org.apache.struts.action.ActionForm;
  12. import org.apache.struts.action.ActionForward;
  13. import org.apache.struts.action.ActionMapping;
  14. import org.apache.struts.action.ActionMessage;
  15. import org.apache.struts.action.ActionMessages;
  16.  
  17. import web.data.stdforms.actions.SingleTableAction;
  18.  
  19. public class MyBookingsAction extends SingleTableAction {
  20.  
  21.     @SuppressWarnings(\"unchecked\")
  22.     protected Map getKeyMethodMap() {
  23.         Map map = new HashMap();
  24.         map.put(\"hhsystem.landlord.mybookings.view\", \"show\");
  25.        
  26.         return map;
  27.     }
  28.    
  29.     /**
  30.      * Simple \"go-back\" Action
  31.      *
  32.      * @param mapping   ActionMapping
  33.      * @param form   the MyBookingsForm
  34.      * @param request   HttpServletRequest
  35.      * @param response  HttpServletResponse
  36.      * @return    will forward to Landlords overview
  37.      */
  38.    
  39.     public ActionForward cancelled(ActionMapping mapping,
  40.             ActionForm form,
  41.             HttpServletRequest request,
  42.             HttpServletResponse response) {
  43.        
  44.             return mapping.findForward(\"exit\");
  45.     }
  46.    
  47.     /**
  48.      * After picking an item of the {@link web.data.stdforms.SingleTableForm}, you will be
  49.      * forwarded to the selected {@link Booking}. If no booking is selected, it\'ll forward to
  50.      * the landlords overview page.
  51.      *
  52.      * @param mapping   ActionMapping
  53.      * @param form   the MyBookingsForm
  54.      * @param request   HttpServletRequest
  55.      * @param response  HttpServletResponse
  56.      * @return    will forward to {@link EditBookingForm}
  57.      * @see             HolidayHome
  58.      */
  59.    
  60.     public ActionForward show(ActionMapping mapping, ActionForm form,
  61.             HttpServletRequest request, HttpServletResponse response) {
  62.         MyBookingsForm mbf = (MyBookingsForm) form;
  63.        
  64.         if(mbf.getSelectedRecord() != null) {
  65.             request.getSession().setAttribute(\"selectedBooking\", mbf.getSelectedRecord());
  66.            
  67.             return mapping.findForward(\"editBooking\");
  68.            
  69.         } else {
  70.            
  71.             ActionMessages messages = new ActionMessages();
  72.             messages.add(\"message\", new ActionMessage(\"hhsystem.landlord.noentry\"));
  73.             saveErrors(request,messages);
  74.            
  75.             return mapping.findForward(\"exit\");
  76.         }
  77.     }
  78. }
Subscribe to this code! Get Firefox! Valid XHTML Valid CSS Powered By GeSHi 665 pieces of code saved