Source Code Cross Referenced for CRUDInstance.java in  » Web-Framework » roma-webwizard » org » romaframework » module » crud » 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 » Web Framework » roma webwizard » org.romaframework.module.crud 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006 Luca Garulli (luca.garulli@assetdata.it)
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.romaframework.module.crud;
018:
019:        import org.romaframework.aspect.core.annotation.AnnotationConstants;
020:        import org.romaframework.aspect.core.annotation.CoreClass;
021:        import org.romaframework.aspect.persistence.PersistenceAspect;
022:        import org.romaframework.aspect.persistence.PersistenceConstants;
023:        import org.romaframework.aspect.persistence.annotation.Persistence;
024:        import org.romaframework.aspect.reporting.ReportingAspect;
025:        import org.romaframework.aspect.view.ViewAspect;
026:        import org.romaframework.aspect.view.ViewCallback;
027:        import org.romaframework.aspect.view.ViewHelper;
028:        import org.romaframework.aspect.view.annotation.ViewAction;
029:        import org.romaframework.aspect.view.annotation.ViewClass;
030:        import org.romaframework.aspect.view.annotation.ViewField;
031:        import org.romaframework.aspect.view.feature.ViewActionFeatures;
032:        import org.romaframework.aspect.view.feature.ViewElementFeatures;
033:        import org.romaframework.core.config.Refreshable;
034:        import org.romaframework.core.domain.reporting.ReportGenerator;
035:        import org.romaframework.core.flow.ObjectContext;
036:
037:        /**
038:         * Page to handle Create, Modify and View sides of CRUD.
039:         * 
040:         * @author Luca Garulli (luca.garulli@assetdata.it)
041:         * @param <T>
042:         *          Domain Object to handle
043:         */
044:        @CoreClass(orderActions="save back")
045:        @ViewClass(label="")
046:        public abstract class CRUDInstance<T> extends CRUDEntity<T> implements 
047:                ViewCallback, CRUDWorkingMode {
048:
049:            @ViewField(visible=AnnotationConstants.FALSE)
050:            private int mode;
051:
052:            public static final int MODE_CREATE = 0;
053:            public static final int MODE_READ = 1;
054:            public static final int MODE_UPDATE = 2;
055:
056:            public CRUDInstance() {
057:                super (null);
058:            }
059:
060:            public CRUDInstance(T iEntity, Object iBackObject) {
061:                super (iEntity);
062:                setBackObject(iBackObject);
063:            }
064:
065:            public void onShow() {
066:
067:                if (!ObjectContext.getInstance().existComponent(
068:                        ReportingAspect.class.getSimpleName()))
069:                    ObjectContext.getInstance().setActionFeature(this ,
070:                            ViewAspect.ASPECT_NAME, "report",
071:                            ViewActionFeatures.VISIBLE, Boolean.FALSE);
072:
073:                if (mode == MODE_READ) {
074:                    // DISABLE ALL FIELDS BY DEFAULT
075:                    ViewHelper.disableFields(this );
076:                }
077:
078:                // HIDE/SHOW THE SAVE BUTTON
079:                ObjectContext.getInstance().setActionFeature(this ,
080:                        ViewAspect.ASPECT_NAME, "save",
081:                        ViewElementFeatures.VISIBLE, mode != MODE_READ);
082:            }
083:
084:            public void onDispose() {
085:            }
086:
087:            /**
088:             * Overwrite this method to catch the event before to display a CRUD instance in CREATE mode.
089:             */
090:            public void onCreate() {
091:            }
092:
093:            /**
094:             * Overwrite this method to catch the event before to display a CRUD instance in READ mode.
095:             */
096:            public void onRead() {
097:            }
098:
099:            /**
100:             * Overwrite this method to catch the event before to display a CRUD instance in UPDATE mode.
101:             */
102:            public void onUpdate() {
103:            }
104:
105:            @ViewAction(validation=AnnotationConstants.TRUE)
106:            @Persistence(mode=PersistenceConstants.MODE_TX)
107:            public void save() {
108:                switch (mode) {
109:                case MODE_CREATE:
110:                    if (getSourceObject() == null)
111:                        ObjectContext.getInstance().getContextComponent(
112:                                PersistenceAspect.class).createObject(
113:                                getEntity());
114:                    break;
115:
116:                case MODE_UPDATE:
117:                    if (getSourceObject() == null)
118:                        ObjectContext.getInstance().getContextComponent(
119:                                PersistenceAspect.class).updateObject(
120:                                getEntity());
121:                    break;
122:
123:                default:
124:                    return;
125:                }
126:
127:                bindValue();
128:
129:                Object backForm = getBackObject();
130:                if (backForm != null) {
131:                    if (backForm instanceof  CRUDSelect) {
132:                        // CALLER FORM IS A CRUD SELECT: SELECT THE CREATED ELEMENT AND
133:                        // BIND INTO CALLER FORM (INVOKE SELECTION)
134:                        ((CRUDSelect) backForm)
135:                                .setSelection(new Object[] { getEntity() });
136:                        ((CRUDSelect) backForm).selectAndForceClosing(true);
137:                        return;
138:                    } else if (backForm instanceof  Refreshable) {
139:                        // RE-EXECUTE THE SEARCH
140:                        ((Refreshable) backForm).refresh();
141:                    }
142:                }
143:                close();
144:            }
145:
146:            public int getMode() {
147:                return mode;
148:            }
149:
150:            public void setMode(int mode) {
151:                this .mode = mode;
152:            }
153:
154:            /**
155:             * Generate a report for the current view using the ReportingAspect.
156:             */
157:            public void report() {
158:                ReportGenerator form = new ReportGenerator(this , this 
159:                        .getClass().getSimpleName());
160:                ObjectContext.getInstance().show(form);
161:            }
162:
163:            protected PersistenceAspect getPersistenceAspect() {
164:                return ObjectContext.getInstance().getContextComponent(
165:                        PersistenceAspect.class);
166:            }
167:
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.