ZK Framework in Navis TOS Edwin Yu Senior Software Engineer, Navis Framework Team
[email protected] ZK U.S. User Group Nov 7, 2011, Cypress, CA Copyright © 2011 Navis, LLC. All Rights Reserved.
Agenda •
Background
•
• • •
Why ZK Framework? Product Demo ZK Framework Integration
•
•
2
Macro Component, Template
ZK Server+Client Fusion
•
• •
Navis
OpenLayers Map
Unit + Integration Testing Debugging Tips
Copyright © 2011 Navis, LLC. All Rights Reserved.
Navis • •
Oakland, CA Proven TOS functionality for State of The Art Automated Terminals
• •
•
3
Equipment automation Gate operation automation
Help Terminal Operators increase capacity and optimize operations to lower costs
Copyright © 2011 Navis, LLC. All Rights Reserved.
Navis TOS Client Locations
Terminals (in TEU) Up to 300,000
61
300,001 – 500,000 41 500,001 – 1 Mil 54 > 1Mil – 1.5 Mil 17 > 1.5 Mil
25
New Site TEU Data NA 11
209
4
Copyright © 2011 Navis, LLC. All Rights Reserved.
Product Demo •
5
[demo]
Copyright © 2011 Navis, LLC. All Rights Reserved.
Choosing a Web Technology ULC Client (Swing)
HTML
ULC
(Strut) Native Strut Programming
Native ULC Programming
Presentation Tier Business Tier
Persistence Tier 6
Copyright © 2011 Navis, LLC. All Rights Reserved.
Choosing a Web Technology •
Business Requirements
• •
•
Open Source Ajax Low Learning Curve - Productivity Component-based MVC (as opposed to request-based) Integration Friendly
2 Months Evaluation in 2009
• •
7
Engineers’ Skill Set
Technical Requirements
• • • •
•
Investment Protection
Prototyping Architecture Reviews
Copyright © 2011 Navis, LLC. All Rights Reserved.
Web Technology Evaluation
8
Copyright © 2011 Navis, LLC. All Rights Reserved.
Choosing ZK Framework • •
Check References Load Testing, Performance Comparison
•
•
9
Table with 150 Rows
Prototype
Copyright © 2011 Navis, LLC. All Rights Reserved.
ZK Framework Integration
ZK Client engine in browser
ULC Client (Swing)
Navis Framework ZK
ULC
Custom ZK widgets
Custom ULC widgets
Shared UI Logic
Presentation Tier Business Tier
Persistence Tier 10
Copyright © 2011 Navis, LLC. All Rights Reserved.
ZK Framework Integration
ZK Client engine in browser
ULC Client (Swing)
Navis Framework ZK
ULC
Custom ZK widgets
Custom ULC widgets
Shared UI Logic
Presentation Tier Business Tier
Navis App
Persistence Tier 11
Copyright © 2011 Navis, LLC. All Rights Reserved.
ZK Framework Integration •
To overcome our challenges, ZK Framework offers
• • • •
12
Swing-like Java API to build a UI tree
Desktop programming paradigm Macro components ZUL as templates
Copyright © 2011 Navis, LLC. All Rights Reserved.
Macro Component •
•
“Implement a new component by use of other components” – ZK reference documentation
Encapsulate a set of related functionality into a new reusable component
•
For an example in our app, every tab shows a table
• • • •
13
Backed by a hibernate entity
UI for Query Filters Context menu Pagination
Copyright © 2011 Navis, LLC. All Rights Reserved.
Macro Component Reusable in any zul or in code
lang-addon.xml
zTable listbox com.navis.framework.zk.view.ZTable
a composite ui of the following
ZPopupMenuButton
Button
Paging
filter.zul
Listbox 14
Copyright © 2011 Navis, LLC. All Rights Reserved.
Zul as Template • •
Build skeleton UI structure quickly Dynamically Bind, via VariableResolver
• • •
•
Controller Data Model Custom Attributes
Reusable, Executions.createComponents(“template.zul”, args) ?
?
Presentation Tier
Business Tier Persistence Tier
Generic form.zul
15
… …
Copyright © 2011 Navis, LLC. All Rights Reserved.
Dynamic Layout •
• •
Dynamically populated view means we can’t hard-code the width and height in our views (in code or in zul)
How is the width calculated? Outside-in layout
• •
•
16
We want our components embedded on the page to maximize the width and height the container allows
Inside-out layout
• •
•
The UI resizes based on the size of the browser
Our floating form dialogs resize based on its content
We want our form dialog to minimize its width and height to show its content fully.
ZK offers ways for us to achieve without hard-coding width and height Copyright © 2011 Navis, LLC. All Rights Reserved.
Inside-Out Calculations •
•
17
hflex=“min” means it depends on the width of the inner container
To show a floating form dialog with minimal width without specifying a fixed width in our code:
….
….
Copyright © 2011 Navis, LLC. All Rights Reserved.
public class ZKComposer { doAfterCompose() { _map = new Map(); } onXXX() { // server-side zk event // can invoke map api } }
Copyright © 2011 Navis, LLC. All Rights Reserved.
Integration Test Add custom Javascript plugins Access ZK components in the client-side context, using ZK client API
Copyright © 2011 Navis, LLC. All Rights Reserved.
Help identify the problems Generate ZK zul which can be copied and pasted out Debug in an Eclipse project
Copyright © 2011 Navis, LLC. All Rights Reserved.
Copyright © 2011 Navis, LLC. All Rights Reserved.