01: /**
02: * Copyright (c) 2006 Red Hat, Inc. All rights reserved.
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17: * USA
18: *
19: * Component of: Red Hat Application Server
20: *
21: * Initial Developers: Greg Lapouchnian
22: * Patrick Smith
23: *
24: */package olstore.controller;
25:
26: import java.util.Map;
27:
28: import javax.servlet.http.HttpServletRequest;
29: import javax.servlet.http.HttpServletResponse;
30:
31: import olstore.domain.logic.OlstoreFacade;
32:
33: import org.springframework.web.servlet.ModelAndView;
34: import org.springframework.web.servlet.mvc.Controller;
35:
36: /**
37: * A controller used for viewing the 'my items' page.
38: */
39: public class ViewMyItemsController implements Controller {
40:
41: // The olstore bean instance injected via Spring.
42: private OlstoreFacade olstore;
43:
44: /**
45: * The injection setter method for the olstore bean.
46: * @param olstore the bean instance.
47: */
48: public void setOlstore(OlstoreFacade olstore) {
49: this .olstore = olstore;
50: }
51:
52: /**
53: * When spring intercepts a request to the specified path (in olstore-servlet.xml) the
54: * request is handled here.
55: *
56: * @param request the HttpServletRequest object.
57: * @param response The HttpServletResponse object.
58: * @throws Exception
59: */
60: public ModelAndView handleRequest(HttpServletRequest request,
61: HttpServletResponse response) throws Exception {
62: Map model = ControllerHelper.initModel(request, olstore);
63: model.put("user", olstore.getUser(request.getRemoteUser()));
64: model.put("purchased", olstore.getUserPurchased(request
65: .getRemoteUser()));
66:
67: model.put("page_title", "RHAPS Olstore Demo");
68: return new ModelAndView("myItems", model);
69: }
70:
71: }
|