Source Code Cross Referenced for FeedbackMessagesModel.java in  » J2EE » wicket » wicket » feedback » 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 » wicket » wicket.feedback 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: FeedbackMessagesModel.java 5101 2006-03-23 22:58:59 -0800 (Thu, 23 Mar
003:         * 2006) ivaynberg $ $Revision: 460431 $ $Date: 2006-03-23 22:58:59 -0800 (Thu, 23
004:         * Mar 2006) $
005:         * 
006:         * ==============================================================================
007:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
008:         * use this file except in compliance with the License. You may obtain a copy of
009:         * the License at
010:         * 
011:         * http://www.apache.org/licenses/LICENSE-2.0
012:         * 
013:         * Unless required by applicable law or agreed to in writing, software
014:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
015:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
016:         * License for the specific language governing permissions and limitations under
017:         * the License.
018:         */
019:        package wicket.feedback;
020:
021:        import java.util.ArrayList;
022:        import java.util.Collections;
023:        import java.util.Comparator;
024:        import java.util.List;
025:
026:        import wicket.Component;
027:        import wicket.model.AbstractDetachableModel;
028:        import wicket.model.IModel;
029:
030:        /**
031:         * Model for extracting feedback messages.
032:         * 
033:         * @author Eelco Hillenius
034:         */
035:        public class FeedbackMessagesModel extends AbstractDetachableModel {
036:            private static final long serialVersionUID = 1L;
037:
038:            /** Message filter */
039:            private IFeedbackMessageFilter filter;
040:
041:            /** Lazy loaded, temporary list. */
042:            private transient List messages;
043:
044:            /** Comparator used for sorting the messages. */
045:            private Comparator sortingComparator;
046:
047:            /**
048:             * Constructor. Creates a model for all feedback messages on the page.
049:             */
050:            public FeedbackMessagesModel() {
051:            }
052:
053:            /**
054:             * Constructor. Creates a model for all feedback messags accepted by the
055:             * given filter.
056:             * 
057:             * @param filter
058:             *            The filter to apply
059:             */
060:            public FeedbackMessagesModel(IFeedbackMessageFilter filter) {
061:                setFilter(filter);
062:            }
063:
064:            /**
065:             * @return The current message filter
066:             */
067:            public final IFeedbackMessageFilter getFilter() {
068:                return filter;
069:            }
070:
071:            /**
072:             * @see wicket.model.IModel#getNestedModel()
073:             */
074:            public final IModel getNestedModel() {
075:                return null;
076:            }
077:
078:            /**
079:             * @return The current sorting comparator
080:             */
081:            public final Comparator getSortingComparator() {
082:                return sortingComparator;
083:            }
084:
085:            /**
086:             * @see wicket.model.AbstractDetachableModel#onGetObject(wicket.Component)
087:             */
088:            public final Object onGetObject(final Component component) {
089:                if (messages == null) {
090:                    // Get filtered messages from page where component lives
091:                    List pageMessages = component.getPage()
092:                            .getFeedbackMessages().messages(filter);
093:
094:                    List sessionMessages = component.getSession()
095:                            .getFeedbackMessages().messages(filter);
096:
097:                    messages = new ArrayList(pageMessages.size()
098:                            + sessionMessages.size());
099:                    messages.addAll(pageMessages);
100:                    messages.addAll(sessionMessages);
101:
102:                    // Sort the list before returning it
103:                    if (sortingComparator != null) {
104:                        Collections.sort(messages, sortingComparator);
105:                    }
106:
107:                    // Let subclass do any extra processing it wants to on the messages.
108:                    // It may want to do something special, such as removing a given
109:                    // message under some special condition or perhaps eliminate
110:                    // duplicate messages. It could even add a message under certain
111:                    // conditions.
112:                    messages = processMessages(messages);
113:                }
114:                return messages;
115:            }
116:
117:            /**
118:             * @param filter
119:             *            Filter to apply to model
120:             */
121:            public final void setFilter(IFeedbackMessageFilter filter) {
122:                this .filter = filter;
123:            }
124:
125:            /**
126:             * Sets the comparator used for sorting the messages.
127:             * 
128:             * @param sortingComparator
129:             *            comparator used for sorting the messages
130:             */
131:            public final void setSortingComparator(Comparator sortingComparator) {
132:                this .sortingComparator = sortingComparator;
133:            }
134:
135:            /**
136:             * @see wicket.model.AbstractDetachableModel#onAttach()
137:             */
138:            protected void onAttach() {
139:            }
140:
141:            /**
142:             * @see wicket.model.AbstractDetachableModel#onDetach()
143:             */
144:            protected void onDetach() {
145:                messages = null;
146:            }
147:
148:            /**
149:             * @see wicket.model.AbstractDetachableModel#onSetObject(wicket.Component,
150:             *      java.lang.Object)
151:             */
152:            protected void onSetObject(Component component, Object object) {
153:            }
154:
155:            /**
156:             * Override this method to post process to the FeedbackMessage list.
157:             * 
158:             * @param messages
159:             *            List of sorted and filtered FeedbackMessages for further
160:             *            processing
161:             * @return The processed FeedbackMessage list
162:             */
163:            protected List processMessages(final List messages) {
164:                return messages;
165:            }
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.