Table of Content
Preface
Chapter 1: Getting Started with OFBiz
Getting the OFBiz Code
Downloading and Installing SVN
Downloading TortoiseSVN
Using SVN to Get OFBiz
Our OFBiz Workspace—First Look
Installing the Java Development Kit (JDK)
Downloading JDK 5.0
Installing JDK 5.0
Downloading OFBiz Ready to Launch
Setting Up an Eclipse Project
Using Derby—the OFBiz Stock Database
Compiling OFBiz and Loading the Data
Verifying the Installation Process
The Compilation Portion
The Data Loading Portion
Some Pre-Ignition Processes we won't do Twice
Backing Up the Derby Data Files
Running OFBiz
Allocating Memory for OFBiz
Starting OFBiz and Verifying the Start-Up Process
Seeing the Logs in Real Time
Possible Problems with Start-Up
Switching Off OFBiz
Our First Tour of OFBiz
Accessing OFBiz
Exploring the Webapp "ecommerce"
Let's Buy Something
Exploring the Webapp "order"
1
9
9
10
10
11
13
14
14
15
16
16
19
20
20
20
21
21
22
22
22
24
25
25
25
26
26
28
28
32
Table of Contents
Receiving Payment
Fulfilling the Order
Invoice Automatically Generated with Payment Applied
End-to-End Tour Completed
Summary
Chapter 2: Working with OFBiz
Adding Our First Field
Changing the Data
Editing the Entity Definition
Updating the Database
Changing the Looks
Editing the User-Interface
Checking Our Changes
Changing the Flow
Rewiring the "Save" (Update Postal Address) Button
Creating the New Widget Screen
Creating the FTL File
More to the Flow
Some Changes Possible with Engines Running
Resetting Our Play Area Quickly
Skipping Some Pre-Ignition Processes
Restoring Derby Data Files
Removing the Web Server (Catalina) Work Files
Updating the Database with Our Data Entity Changes
Showing Off Our Spanking New OFBiz Installation
Tripping Up Our Plan
Storing a Save-Point to Dramatically Ease Testing
Archiving Derby Data Files and Web Server Work Files
Restoring a Save-Point
Restoring the Derby Data Files
Restoring the Web Server Work Files
Computer, Run Scenario A from Last Save-Point
The Structure of OFBiz in General
Components in OFBiz
Referencing Components in OFBiz
Creating Our Own OFBiz Component
Creating the Component
Using Our Component
Cleaning Up Our Mess in the "party" Component
Converting the BeanShell to a Java Event
Clean Extension Strategies Employed
Checking that Our Move was Successful
A Bit More Mess Remains
Webapps in OFBiz
Creating Our First Webapp
[ ii ]
32
34
34
34
35
37
37
39
39
40
40
41
41
42
42
43
44
45
47
48
49
49
49
49
50
50
50
51
52
52
52
52
53
53
54
55
55
55
56
57
59
60
60
60
61
The Model-View-Controller Architectural Pattern
Webapp URIs in this Book
Testing Our First Webapp
The MVC in Plain English
The Model in OFBiz
The View in OFBiz
The Controller in OFBiz
Other Files in an OFBiz Component
Summary
Chapter 3: Screen Widgets
Equipping Our Webapp with a Screen Widget View Handler
Using the Screen Widget View Handler
Files and Locations
Creating Our First Screen Widget
Defining a Screen Widget
Informing the Control Servlet about the Screen Widget
Referencing Screen Widgets
Uniform Pattern of Flow in OFBiz
Seeing Our First Screen Widget
The Anatomy of the
Element
Our First Conditional Screen Widget
Element Order in the controller.xml
Inform the Control Servlet about the Screen Widget
If-Then-Else Structure
The Element
The Then— and Elements
The Else— Element
The Minimum
Sending Parameters with Requests
Seeing Our Conditional Screen Widget
Screen Widget Context and Variables
Utility Objects in Context
Nested Sections for Nested Conditions
Organizing a Large Screen into Smaller Screens
The Global Context Revisited
Outer Contexts Visible to Nested Ones
Screen Widget's Integration with FreeMarker
Cleaning Up in the "party" Component
Commenting Changes to the Core Code
Screen Widgets as Templates
A Candidate for Templating
Creating the Header
Creating the Footer
[ iii ]
Table of Contents
62
63
63
63
64
64
65
66
67
69
69
71
71
71
71
72
73
73
74
74
74
75
75
75
76
76
78
78
79
79
79
80
85
88
90
92
93
94
96
97
97
98
98
Table of Contents
Using Our Header and Footer
Seeing Our First Well-Formed XHTML Document
Using Decorator Screen Widgets for Templating
Creating a XHTML Decorator Screen
Using the XHTML Decorator Screen
Seeing Our First Decorator in Action
Multiple Content Slots
Creating the First Half of the Header
Creating the Second Half of the Header
Adding a Content Slot to a Decorator
Using Our Multi-Slot Decorator
Seeing Our First Multi-Slot Decorator
Nesting Decorators
Top-Down Approach (delegation)
The Bottom-Up Approach (Vertical Stack)
Using Both Approaches
Summary
Chapter 4: Form Widgets
Files and Locations
Creating Our First Form Widget
Creating the Containing Screen Widget
Referencing Form Widgets
Create the Form Widget
Seeing Our First Form
Understanding the Form Attributes
Minimum Requirements to Use Form Widgets
Including the Minimal Requirements
Form Processing via Request Event
Java Events
Submitting and Processing Our First Form
The "list" Type Form Widget
Creating the Containing Screen
Adding Form Processing Code
Publishing the Form
Seeing Our First "list" Type Form
The "multi" Type Form Widget
Creating the Containing Screen
Loading Data for the Form
Publishing the Form
Creating the Form-Processing Logic
Seeing Our First "multi" Type Form
Alternative Targets in Two-Target Forms
Creating the Form
[ iv ]
99
99
100
100
100
101
102
102
102
103
103
104
104
104
106
107
109
111
112
112
112
113
113
114
114
115
116
116
117
118
119
119
120
121
122
122
122
123
124
125
125
126
126
Creating the Containing Screen
Publishing the Two-Target Form
Seeing Our First Two-Target Form
Row-Level Actions
Creating the Form
Creating the Containing Screen
Publishing the Form
Seeing the Form in Action
Summary
Chapter 5: Other View Element Types in Screen Widgets
Menu Widgets
Creating Our First Menu Widget
Including Our Menu Widget in Our Screen Widgets
Understanding the Menu Item Attributes
Including the Menu Widget via a Decorator Screen Widget
Add Screen Widget "ConditionalScreen" to the Menu
Sub-Menus and Conditional-Menu Items
Pre-processing Actions for Menu Widgets
FreeMarker
As Decorator Templates
Displaying Dynamically Created List Variables
Iterating Through the List
Bringing it All Together
The User-Interface Labels
Adding the appheader
Summary
Chapter 6: The Controller
How OFBiz Hears Our Requests—The Control Servlet
Defining a Control Servlet for a Webapp
Using the Control Servlet
Funnelling All Requests to the Single Control Servlet
Defining Needed Utility Objects for the Control Servlet
GenericDelegator Object
The GenericDispatcher Object
Some Background on Servlets
Programming a Control Servlet
Logging into Our Learning Application
Specifying Handlers
Request Maps
Knocking on the Right Doors
Security—Before Answering the Door
The https Attribute
[ v ]
Table of Contents
127
127
128
128
129
129
130
130
131
133
134
134
135
135
135
136
137
139
142
142
143
144
145
146
148
150
151
151
152
153
153
154
154
155
156
156
156
159
160
160
160
160
Table of Contents
The auth Attribute
The direct-request Attribute
Event—Determining a Response
Java Events
Response—Defining Various Responses
View Maps
Summary
Chapter 7: Entities, View Entities, and Extended Entities
Entities
The Structure of the Data Model
Referencing Fields of an Entity
OFBiz Uses Relational Database Management Systems
Curious Trivia about the Relational Model
Entity Engine Concepts
Datasources
Entity Delegators
Entity Groups
Defining Our First Entity
Assigning Our Entity to an Entity Group
Loading Our Entity into the Entity Engine
Seeing Our First Entity
Using Our First Entity
Creating a Drop-Down
Populating the Drop-Down
Expiring a Value
Un-Expiring a Value
Anatomy of an
Element
The Element
The Element
The Element
The Element
Relation Types
One-to-One Relations
One-to-Many Relations
One-to-One Relations with No Foreign Keys
View Entities
Anatomy of a
The Element
The and Elements
The Element
The Element
Applying Functions on Fields
Counting the Number of Records
Counting Distinct Records
[ vi ]
162
163
165
165
166
172
173
175
176
176
176
176
177
177
177
178
179
179
180
180
181
183
184
186
187
187
187
188
189
189
194
196
196
196
199
200
201
201
202
206
209
209
209
210
Arithmetic Aggregate Functions
Uppercase and Lowercase Functions
Grouping for Summary Views
Complex Aliases
Nested Elements
Extending Entities
Summary
Chapter 8: Accessing the Entities and View Entities
Setting-Up Our Playground
The Script Processor
The Generic Screen
Creating the Screen Widget
Creating the Form Widget
Creating the FreeMarker File
Publishing Our Generic Screen
Testing Our Playground
GenericValue Objects
Creating a Database Record
Why a Map is Used?
Updating Database Records
Deleting Database Records
Retrieving Database Records
Find Records by Conditions
Conditions
Comparison Operators (EntityComparisonOperator)
Condition Lists
Condition Joiners (EntityJoinOperator)
Tools for Common Styles of Conditions
Conditions Joined by AND
Conditions Joined by OR
Counting the Number of Records Retrieved
OFBiz Date Condition
Getting Related Records
One-to-One Relations
One-to-Many Relations
Utilities for Post-Query processing
Post-Query Ordering
Post-Query Filtering by Conditions
Post-Query Filtering by Date
Other Post-Query Filtering Methods
Using the Entity Engine Cache
Dynamic View Entities
Left Outer Joins with the Dynamic View Entity
Performing the Lookup
[ vii ]
Table of Contents
210
210
211
211
212
213
214
217
218
218
219
219
220
220
222
222
223
224
224
225
226
226
227
228
228
231
232
238
238
239
240
241
243
243
244
245
246
247
248
250
251
252
256
257