1 37 38 package com.sun.j2ee.blueprints.consumerwebsite.actions; 39 40 import java.io.*; 41 import java.util.*; 42 43 import javax.servlet.http.*; 45 46 import com.sun.j2ee.blueprints.waf.controller.*; 48 import com.sun.j2ee.blueprints.waf.controller.web.html.*; 49 50 import com.sun.j2ee.blueprints.consumerwebsite.*; 52 53 import com.sun.j2ee.blueprints.catalog.*; 55 import com.sun.j2ee.blueprints.catalog.dao.*; 56 57 61 62 public final class TransportSearchHTMLAction extends HTMLActionSupport { 63 64 public Event perform(HttpServletRequest request) 65 throws HTMLActionException { 66 67 HttpSession session = request.getSession(); 68 AdventureComponentManager acm = 70 (AdventureComponentManager)session.getAttribute(AdventureKeys.COMPONENT_MANAGER); 71 Cart cart = acm.getCart(session); 72 String origin = request.getParameter("origin"); 73 if (origin == null) { 75 origin = cart.getOrigin(); 76 } else { 77 cart.setOrigin(origin); 78 } 79 80 ArrayList transpDepartureBeans = null; 81 ArrayList transpReturnBeans = null; 82 83 String noTransport = request.getParameter("no_transport"); 84 String showTransport = request.getParameter("show_flights"); 85 Locale locale = new Locale("en","us"); 86 String destination = cart.getDestination(); 87 transpDepartureBeans = searchTransportation(origin, destination, locale); 89 transpReturnBeans = searchTransportation(destination, origin, locale); 90 91 request.setAttribute("departure_result", transpDepartureBeans ); 93 request.setAttribute("return_result", transpReturnBeans ); 94 request.setAttribute("search_target","transportation"); 95 return null; 96 } 97 98 101 public ArrayList searchTransportation(String origin, String destination ,Locale locale) throws HTMLActionException { 102 ArrayList transportation = null; 103 ArrayList transportationBean = new ArrayList(); 104 105 try { 107 CatalogFacade catalogFacade = new CatalogFacade(); 108 transportation = catalogFacade.getTransportations(origin, destination, locale); 109 110 } catch (Exception e) { 113 throw new HTMLActionException("Transportation Search Exception:: Catalog Exception accessing catalog component: " + e); 114 } 115 for(int i=0;i<transportation.size() ;++i){ 116 transportationBean.add(new TransportationBean(((com.sun.j2ee.blueprints.catalog.Transportation)transportation.get(i)).getTransportationId(), 117 ((com.sun.j2ee.blueprints.catalog.Transportation)transportation.get(i)).getName(), 118 ((com.sun.j2ee.blueprints.catalog.Transportation)transportation.get(i)).getDescription(), 119 ((com.sun.j2ee.blueprints.catalog.Transportation)transportation.get(i)).getImageURI(), 120 ((com.sun.j2ee.blueprints.catalog.Transportation)transportation.get(i)).getPrice(), 121 ((com.sun.j2ee.blueprints.catalog.Transportation)transportation.get(i)).getOrigin(), 122 ((com.sun.j2ee.blueprints.catalog.Transportation)transportation.get(i)).getDestination(), 123 ((com.sun.j2ee.blueprints.catalog.Transportation)transportation.get(i)).getCarrier(), 124 ((com.sun.j2ee.blueprints.catalog.Transportation)transportation.get(i)).getDepartureTime(), 125 ((com.sun.j2ee.blueprints.catalog.Transportation)transportation.get(i)).getArrivalTime(), 126 ((com.sun.j2ee.blueprints.catalog.Transportation)transportation.get(i)).getTravelClass())); 127 } 128 return transportationBean ; 129 } 130 } 131 132 | Popular Tags |