Source Code Cross Referenced for WPage.java in  » Database-ORM » SimpleORM » simpleorm » simplewebapp » core » 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 » Database ORM » SimpleORM » simpleorm.simplewebapp.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package simpleorm.simplewebapp.core;
002:
003:        import simpleorm.simplewebapp.context.WPageContext;
004:        import simpleorm.simplewebapp.core.WMenuParentGlobal;
005:        import simpleorm.simplewebapp.core.WMenuItemGlobal;
006:
007:        import java.util.ArrayList;
008:        import java.util.Collection;
009:        import java.util.Map;
010:
011:        /**
012:         * The JSP Bean that contains the state for the current page, ie. menus, buttons and fields.
013:         * Normally extended by application specific beans for specific page.
014:         * Normally created by the WPageTag tag, but can be instantiated directly for unit tests.<p>
015:         *
016:         * The wPage JSP instance variable
017:         * should be Page JSP beanName scope as forwarded pages will have their own beanName
018:         * But must be Request scope so that idiot JSP Tablibs can still see them.
019:         * Note that the WPageTag always clobers any exiting RequestBean,
020:         * so they essentially do have page scope even though they are store on the request.<p>
021:         *
022:         * (Was called WPageBean (but not page scope) then WRequestBean (but really per page) and finally WPage.)<p>
023:         *
024:         * Most of the processing is done by WPageStructure which is one-to-one with this.
025:         * This class mainly contains the JSP visible methods.
026:         *
027:         */
028:        public class WPage {
029:
030:            WPageStructure pageStructure = new WPageStructure(this );
031:
032:            /**
033:             * Set by WWebeanTag to wrap the PageContext.
034:             * Remains null for unit tests outside the Web framework.
035:             */
036:            WPageContext pageContext;
037:
038:            WPageSecurity pageSecurity = new WPageSecurity(this );
039:
040:            /**
041:             * The button in the button bar that was pressed to submit the form.
042:             * Normally set by retrieveParameters but can be manually set for unit tests.
043:             */
044:            WButton submitButton = null;
045:
046:            /**
047:             * List of any errors to be displayed to the user, normally empty.
048:             */
049:            ArrayList<WValidationException> errors = new ArrayList<WValidationException>(
050:                    0);
051:
052:            final WLog logger = new WLog(); // Here so that we get a timestamp.
053:
054:            WI18n i18n = new WI18n(this );
055:
056:            /**
057:             * Used mainly to open DB connections.
058:             * Needs to be on Page, not Pagelet, so that all pagelets share the same connection, eg. in listCrud.
059:             */
060:            protected void onInitialize() throws Exception {
061:            }
062:
063:            protected void onFinalize() throws Exception {
064:            }
065:
066:            /**
067:             * The name of the page, as stored in its WMenuItemGlobal.
068:             */
069:            public String getPageName() {
070:                WMenuItemGlobal it = getPageItem();
071:                if (it != null)
072:                    return it.getName();
073:                else
074:                    return this .getClass().getSimpleName();
075:            }
076:
077:            public boolean isErroneous() {
078:                return getErrors().size() > 0;
079:            }
080:
081:            void onFinalizeInternal() throws Exception {
082:                if (pageStructure != null)
083:                    pageStructure.onFinalizeInternal();
084:                pageContext = null;
085:                submitButton = null;
086:                errors = null;
087:            }
088:
089:            /**
090:             * Utility to dump page state to the debug log.
091:             */
092:            public void logPage() {
093:                if (logger.isDebug()) {
094:                    logger.debug(">>>>>>>>>>>>>> " + this  + " " + submitButton);
095:                    for (WValidationException ex : errors)
096:                        logger.debug("    ??? Exception " + ex);
097:                    for (WPagelet plet : pageStructure.pagelets.values()) {
098:                        logger.debug("    Pagelet " + plet);
099:                        for (WFieldGroup fgroup : plet.getFieldGroups()
100:                                .values()) {
101:                            logger.debug("      Field Group " + fgroup);
102:                            for (WField field : fgroup.getFields().values())
103:                                logger.debug("          Field " + field);
104:                        }
105:                    }
106:                    logger
107:                            .debug("<<<<<<<<<<<<<< " + this  + " "
108:                                    + logger.time());
109:                }
110:            }
111:
112:            public String toString() {
113:                return "{" + this .getClass().getSimpleName() + " "
114:                        + getPageName() + "}";
115:            }
116:
117:            /** Exception if null */
118:            public WPageContext getPageContext() {
119:                if (pageContext == null)
120:                    throw new WException("WPageContext not set");
121:                return pageContext;
122:            }
123:
124:            ///////////////  Page Field Delegates, needed from JSP, do not remove (All JSP calls from here) ///////////////
125:
126:            public Map<String, WFieldGroup> getFieldGroups() {
127:                return getPagelet().getFieldGroups();
128:            }
129:
130:            /**
131:             * This must be a one step method to work arround bugs in JSP/EL
132:             */
133:            public Collection<WFieldGroup> getFieldGroupsValues() {
134:                return getPagelet().getFieldGroupsValues();
135:            }
136:
137:            /**
138:             * Used in jsp as ${wPage.fields.id.text}
139:             * Finds the given field in the current (or only) WPagelet.
140:             * Exception if not found (otherwise JSPs ignore!)
141:             */
142:            public Map<String, WField> getFields() {
143:                return getPagelet().getAllFieldsStrict();
144:            }
145:
146:            /**
147:             * Convienience for unit tests
148:             */
149:            public WField getField(String fullName) {
150:                return getPagelet().getFieldStrict(fullName);
151:            }
152:
153:            public Collection<WField> getSearchFieldValues() {
154:                return getPageStructure().getCurrentPageletList()
155:                        .getSearchFieldValues();
156:            }
157:
158:            /**
159:             * These are needed ${webBean.crudFields.options} does not work!
160:             */
161:            public @Deprecated
162:            Collection<WField> getListFieldValues() {
163:                return getPageStructure().getCurrentPageletList()
164:                        .getFieldGroup("list").getValues();
165:            }
166:
167:            /**
168:             * Row nr of the current row.  Used to shade every other row in lists.  First is 0.
169:             */
170:            public int getRowIndex() throws Exception {
171:                return getPageStructure().getCurrentPageletList().rowIndex;
172:            }
173:
174:            public boolean isMultipart() {
175:                return getPageStructure().isMultipart;
176:            }
177:
178:            public String translate(String key) {
179:                return i18n.translate(key);
180:            }
181:
182:            ////////////// Convenient delegators //////////////////
183:
184:            /**
185:             * getPageStructure().getCurrentPagelet()
186:             */
187:            public WPagelet getPagelet() {
188:                return getPageStructure().getCurrentPagelet();
189:            }
190:
191:            public WPagelet getListPagelet() {
192:                return getPageStructure().getCurrentPageletList();
193:            }
194:
195:            public WMenuParentGlobal getMenu() {
196:                return getPageStructure().getPageItem().getParent();
197:            }
198:
199:            //////////////// Generated  (Might be referenced from .jsp) /////////////////////
200:
201:            public WPageStructure getPageStructure() {
202:                return pageStructure;
203:            }
204:
205:            public WPageSecurity getPageSecurity() {
206:                return pageSecurity;
207:            }
208:
209:            public void setPageContext(WPageContext pageContext) {
210:                this .pageContext = pageContext;
211:            }
212:
213:            public WButtonBar getButtonBar() {
214:                return pageStructure.buttonBar;
215:            }
216:
217:            public WButton getSubmitButton() {
218:                return submitButton;
219:            }
220:
221:            public void setSubmitButton(WButton submitButton) {
222:                this .submitButton = submitButton;
223:            }
224:
225:            public WMenuItemGlobal getPageItem() {
226:                return pageStructure.pageItem;
227:            }
228:
229:            public ArrayList<WValidationException> getErrors() {
230:                return errors;
231:            }
232:
233:            public WLog getLogger() {
234:                return logger;
235:            }
236:
237:            public WI18n getI18n() {
238:                return i18n;
239:            }
240:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.