Source Code Cross Referenced for UpdateOrderController.java in  » J2EE » JOnAS-4.8.6 » olstore » controller » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » JOnAS 4.8.6 » olstore.controller 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (c) 2006 Red Hat, Inc. All rights reserved.
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2.1 of the License, or any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
017:         * USA
018:         *
019:         * Component of: Red Hat Application Server
020:         * 
021:         * Initial Developers: Greg Lapouchnian
022:         *                     Patrick Smith
023:         *
024:         */package olstore.controller;
025:
026:        import java.util.Iterator;
027:        import java.util.Map;
028:
029:        import javax.servlet.http.HttpServletRequest;
030:        import javax.servlet.http.HttpServletResponse;
031:
032:        import olstore.domain.logic.OlstoreFacade;
033:        import olstore.dto.OrderEntry;
034:
035:        import org.springframework.validation.BindException;
036:        import org.springframework.web.servlet.ModelAndView;
037:        import org.springframework.web.servlet.mvc.SimpleFormController;
038:
039:        /**
040:         * A controller to handle the update order action.
041:         */
042:        public class UpdateOrderController extends SimpleFormController {
043:
044:            // The olstore bean instance provided via Spring.
045:            private OlstoreFacade olstore;
046:
047:            /**
048:             * Create a new form controller and set the form views as well as the
049:             * backing object class.
050:             */
051:            public UpdateOrderController() {
052:                setSessionForm(true);
053:                setValidateOnBinding(false);
054:                setCommandClass(OrderFormHelper.class);
055:                setFormView("updateOrder");
056:                setSuccessView("updateOrder");
057:            }
058:
059:            /**
060:             * Spring injection setter method.
061:             * @param olstore the bean instance that is injected via Spring.
062:             */
063:            public void setOlstore(OlstoreFacade olstore) {
064:                this .olstore = olstore;
065:            }
066:
067:            /**
068:             * Return a new helper object that will be used as this form's backing object.
069:             * @param request the HttpServletRequest.
070:             * @return a backing object for this form.
071:             */
072:            protected Object formBackingObject(HttpServletRequest request)
073:                    throws Exception {
074:                return new OrderFormHelper(olstore.findOrdersForUpdate());
075:            }
076:
077:            /**
078:             * This form's validation method to handle the backing object's fields.
079:             * @param request the HttpServletRequest.
080:             * @param command the form's backing object.
081:             * @param errors the reported from the validation.
082:             */
083:            protected void onBindAndValidate(HttpServletRequest request,
084:                    Object command, BindException errors) throws Exception {
085:                // ValidationUtils.rejectIfEmptyOrWhitespace(errors, "fname", "FNAME_REQUIRED", "First name is required.");
086:                //  ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lname", "LNAME_REQUIRED", "Last name is required.");
087:                // TODO 
088:            }
089:
090:            /**
091:             * The map used in this form's view.
092:             * @param request the HttpServletRequest.
093:             * @return a map representing the data for this form's view.
094:             */
095:            protected Map referenceData(HttpServletRequest request)
096:                    throws Exception {
097:                Map model = ControllerHelper.initModel(request, olstore);
098:                model.put("page_title", "Edit Order Status - Olstore");
099:                return model;
100:            }
101:
102:            /**
103:             * Handles the submission of this form.
104:             * 
105:             * @param request the HttpServletRequest.
106:             * @param response the HttpServletResponse.
107:             * @param command this forms backing object.
108:             * @param errors this form's errors as reported via validation.
109:             * @return a new model and view to represent this form.
110:             */
111:            protected ModelAndView onSubmit(HttpServletRequest request,
112:                    HttpServletResponse response, Object command,
113:                    BindException errors) throws Exception {
114:                // supply the errors to the view inside the model map
115:                Map model = errors.getModel();
116:                // add the reference data once again so it will continue to be displayed
117:                model.putAll(referenceData(request));
118:
119:                OrderFormHelper orders = (OrderFormHelper) command;
120:                try {
121:                    Iterator orderIt = orders.getOrdersList().iterator();
122:                    while (orderIt.hasNext()) {
123:                        OrderEntry order = (OrderEntry) orderIt.next();
124:                        olstore.setStatus(order.getOrderId(), order
125:                                .getOrderStatus());
126:                    }
127:                } catch (Exception ex) {
128:                    model
129:                            .put("error",
130:                                    "There was an error trying to update order status.");
131:                    return showForm(request, response, errors, model);
132:                }
133:
134:                model.put("message",
135:                        "Your changes have been successfully recorded.");
136:                model.put("command", formBackingObject(request));
137:                return new ModelAndView("updateOrder", model);
138:            }
139:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.