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


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