Anatomy of a UI Control - Extension Library Case Study

136
Anatomy of an XPages UI Control Cameron Gregor | Systems Developer Jord International www.jord.com.au Blog: camerongregor.com Twitter: @gregorbyte

Transcript of Anatomy of a UI Control - Extension Library Case Study

Page 1: Anatomy of a UI Control - Extension Library Case Study

Anatomy of an XPages UI Control

Cameron Gregor | Systems Developer Jord Internationalwww.jord.com.au

Blog: camerongregor.comTwitter: @gregorbyte

Page 2: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Page 3: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Goals of this Session

• Spark some curiosity in Control Development + ExtLib

• Provide a ‘Signpost’ for navigating Extension Library Code

• Demonstrate how to develop / debug / deploy controls

Page 4: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Understanding

• Recognising common patterns

• Gain Familiarity

• Diagnose own Problems

Modifying

• Bug fixes

• New Behaviour to Existing

• Finishing Incomplete features

Creating

• New Controls

• New Services

• New Utilities

• New Themes

Page 5: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Agenda

● Identify the ‘Elements’ of a UI Control from the Extension Library

● Getting set up to explore the Source Code of Extension Library

● Techniques on Exploring Source Code within Eclipse

● Demonstrate how we locate the Source Code of our ‘Elements’

● Some Examples of Extending / Modifying / Creating UI Controls

Page 6: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Terminology I might used Interchangeably

Component = Control = UI Control = UI Component

Plugin = Project

Control != Custom Control

Page 7: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Anatomy – Identifying the Moving Parts

• Design Time– Palette Entry

– Mark-up Tag Details

– Visualisation

– Component Metadata

• Class Name

• Properties

– Property Panels

– Drop Action

• Runtime– Component Behaviour

– Renderers

• Default Renderer

• Renderers for Other themes

– One UI 2

– One UI 3

– bootstrap

Page 8: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Design Time Properties

• MOSTLY specified in xsp-config

• SOME can be specified through Extension Points

Page 9: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Palette Entry

• Should Show in Palette?

• Category

• Description

• Icon

Page 10: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Markup Tag Details

Page 11: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Visualisation

• What should it look like in Design Tab?

Page 12: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Component Properties

• What Properties can be set?

• How can they be set?– “” – Literal?

– “${}” – Page Load?

– “#{}” – Compute Dynamically?

– Is it a list of things?

• Drop down Nodes

– What Type?

Page 13: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Property Panels

• Make a big difference in usability

• If well designed, reduce the need for Documentation

Page 14: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Drop Action

Page 15: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Component Behaviour

• How does it operate?

• Any special behaviour? E.g. dialog.show();

• For Input Controls, does it have default Validators, Converters?

• Is it an AJAX Component?

• Is it Themeable?

Page 16: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Runtime - Renderers

ONE UI V2 ONE UI V3 BOOTSTRAP

Page 17: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

PREPARATION

Page 18: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Setting Up To Explore

• Download Eclipse

• Download XPages SDK

• Download Extension Library Source Code

• Import Extension Library Projects to Eclipse

• Configure Eclipse with XPages SDK

• Slides covering this setup are in the Appendix! Download from Auslug after the conference

– I will also put them up on my blog / slideshare

Page 19: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

EXTENSION LIBRARY STRUCTURE

Page 20: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

41 Projects? Where to Start?

Let’s narrow our focus

• 3rd Party Library Projects• Feature Projects• Test Projects• Domino Access Services

projects

Make some more Working Sets

Page 21: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Identifying 3rd Party Library• In normal Java, JARs are just added

to the classpath

• For OSGi development, a plugin ‘wraps’ the jar and provides classes via the plugin framework

• These ‘wrapper’ plugins can usually be identified as only having one or more jar files in them

Page 22: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Feature Projects

• Contain feature.xml

• Often Project name ends in ‘feature’

• Only used when ‘packaging up’ the plugins

• These are BORING let’s get them out of the way

– We didn’t even need to import them in the first place, I just wanted to keep that step simple

• We can Delete from our eclipse ‘workspace’

Page 23: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Delete the feature projects

• Select all the feature projects

– The one’s on the left are the ones I did

• Press ‘delete’

• No Need to ‘delete contents on disk’

Page 24: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Test Plugins

• Used by developers during development to run ‘unit tests’ and what not

• We don’t really care at this point

• Let’s get them out of the way

Page 25: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Domino Access Service Projects / REST

• Used for DAS

• Look at them if you are interested!

• We are focussing on Xpages Controls, so we don’t care

• Lets put them in a Working set of their own

Page 26: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

These ones have all the ‘smarts’ and used during actual Xpages

runtime

These ones have extra ‘tooling’ informationFor Domino Designer to use

These ones aren’t of too much interest to us

9 Main Plugins

5 Designer Only Plugins

Page 27: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Main Control Library Plugins

com.ibm.xsp Description

.bluemix.util New classes for use of Xpages in ‘Bluemix’

.extlib Contains the ‘XspLibrary’ that you enable for your NSF, all other

plugins exposed through this one, not too much to look at though.

.extlib.controls The main Controls project with Components, default

renderers, xsp-config files, and faces-config.xml files.

*We are mainly interested in this one*

.extlib.core Contains Utility functions that are used by all other extlib plugins

.extlib.domino Any Controls SPECIFIC to domino go in here.

E.g. DynamicView, DominoNAB Value Picker etc.

.extlib.mobile All the mobile controls. Not sure if many ppl use these?

.extlib.oneui All the OneUI themes, resources, renderers, app layouts

.extlib.relational Code related to the Relational Database Access functionality

.theme.bootstrap All the Bootstrap themes, resources, renderers, app layouts

Page 28: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Designer Tooling Plugins

com.ibm.xsp.extlib Description

.designer Just some utility classes used by the tooling

.designer.bluemix All the new bluemix configuration and deployment tooling. Might

be interesting to look into but not for our purpose here

.designer.relational Tooling for JDBC Plugin Generator (Can be used to wrap JDBC

Drivers into a plugin for relational db access)

.designer.tooling Additional Tooling information for the Extension Library

controls

.designer.xspprops The ‘xsp.properties’ editor comes from here. Interesting to look at

but not for our purpose

Page 29: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Interesting to us for our ‘WidgetContainer’ Investigation

3 ‘Normal’ Projects

• com.ibm.xsp.extlib.controls

• com.ibm.xsp.extlib.oneui

• com.ibm.xsp.theme.bootstrap

1 Designer Tooling Project

• com.ibm.xsp.extlib.designer.tooling

Much simpler than 41 Projects!

Page 30: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

DISCOVERING THE SOURCE

Page 31: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Eclipse Shortcuts and Tips

Ctrl + Shift + T Find a Java Class by Name

Ctrl + Shift + R Find a Resource by name (XML file, image, text file etc.)

Search -> File Search Contents of files

Search -> Java Search Java types fields etc

Right Click -> References Find out where else that thing is used

Ctrl + Click Click through to the Definition of that thing

F4 Open Type Hierarchy – Navigable Help on that Hierarchy

Ctrl + T Quick Type Hierarchy (Tooltip help)

Ctrl + O Quick Outline of current class (jump to method / field)

Page 32: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Where to Start?

• Thought Process:

– Let’s find the Design Time Properties first

– Design time Properties will be in an .xsp-config file somewhere

– Those Properties should include the tag name

– We know it’s tagname is ‘widgetContainer’

– Let’s search for text ‘widgetContainer’ in *.xsp-config files

Page 33: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Eclipse Shortcuts and Tips

Ctrl + Shift + T Find a Java Class by Name

Ctrl + Shift + R Find a Resource by name (XML file, image, text file etc.)

Search -> File Search Contents of files

Search -> Java Search Java types fields etc

Right Click -> References Find out where else that thing is used

Ctrl + Click Click through to the Definition of that thing

F4 Open Type Hierarchy – Navigable Help on that Hierarchy

Ctrl + T Quick Type Hierarchy (Tooltip help)

Page 34: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

File Search

Page 35: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Scope Searches

Workspace All projects in the workspace

Selected Resources Whatever is selected in the Package Explorer (and children)

Enclosing Projects Search within the projects of the selected things

Working Set Just search within a Working Set (ExtLib, ExtLib Designer etc.)

Page 36: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

2 Files? Which one is correct

• Domino Designer actually uses the one without ‘raw’ prefix

• IBM Use the ‘raw’ one to generate the real one + localised properties

Page 37: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Difference between raw- and normal

Raw file has English descriptions, easier to read for source code browsing

Generated file has English descriptions replaced with localisation placeholders to allow for other languages

Page 38: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Find extlib-containers.xsp-config file

Jumps to

Page 39: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Commonly seen together

English Localisation Properties

Runtime Configuration

Design Time Configuration

raw-extlib-containers.xsp-config down with the R’s

Page 40: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Looking for the Design Time Elements

Things we can find in xsp-config

• Design Time

– Palette Entry

– Mark-up Tag Details

– Visualisation

– Component Class

– Component Properties

– Property Panels

– Drop Action

Page 41: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Other Details we look for in <component-extension> tag

• Find the <component> that relates to the widgetContainer• Look for <component-extension> tag within that

Default Namespace and Prefix

• Usually at the Top of the xsp-config file

Page 42: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

<component-extension>

Tag Name

Palette DetailsNo mention of Icon though?

VisualizationBUT this one is commented out, so where is it coming from?

Page 43: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Component Java Class

• Find the <component> tag for the WidgetContainer

• Find the <component-class> tag underneath that

Page 44: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Component Properties

• Find <component> tag for WidgetContainer

• Look at all the <property> tags beneath that

Page 45: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Component Properties – Group Type Reference

• Component may refer to previously defined groups of properties that are common amongst many Components

Page 46: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

How are we going?

• Design Time

– Palette Entry - Found but no Icon?

– Mark-up Tag Details - FOUND

– Visualisation – Found but commented out?

– Component Class - FOUND

– Component Properties - FOUND

– Property Panels

– Drop Action

Where is the Remaining info? Let’s expand our search to all file types

Page 47: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Search all files for widgetContainer

Page 48: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Lots of matches

After some digging amongst results…

Page 49: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Visualizer

• Visualization can be from xsp-config OR from a special Visualizer class

• Most of the Extension Library controls use a Visualizer class

Page 50: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Visualizer Markup example

Page 51: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

What is in plugin.xml in the designer.tooling project?

Page 52: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Entry in tooling plugin.xml

Palette Details

Where are these icons?Let’s use Find Resource

Page 53: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Eclipse Shortcuts and Tips

Ctrl + Shift + T Find a Java Class by Name

Ctrl + Shift + R Find a Resource by name (XML file, image, text file etc.)

Search -> File Search Contents of files

Search -> Java Search Java types fields etc

Right Click -> References Find out where else that thing is used

Ctrl + Click Click through to the Definition of that thing

F4 Open Type Hierarchy – Navigable Help on that Hierarchy

Ctrl + T Quick Type Hierarchy (Tooltip help)

Page 54: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Finding a Resource• Ctrl + Shift + R

Page 55: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Drop Action

• If the Component has a ‘Drop Action’ then this will be under the paletteItem

Page 56: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Entry in tooling plugin.xml

Panel Details

Page 57: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Custom Panel Example

Page 58: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

How are we tracking

• Design Time

– Palette Entry - FOUND

– Mark-up Tag Details - FOUND

– Visualisation – FOUND

– Component Class - FOUND

– Component Properties - FOUND

– Property Panels - FOUND

– Drop Action - FOUND

Page 59: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Discovering Runtime Elements

• Runtime

– Component Behaviour

– Renderers

• Default Renderer

• Renderers for Other themes

– One UI 2

– One UI 3

– bootstrap

Page 60: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Eclipse Shortcuts and Tips

Ctrl + Shift + T Find a Java Class by Name

Ctrl + Shift + R Find a Resource by name (XML file, image, text file etc.)

Search -> File Search Contents of files

Search -> Java Search Java types fields etc

Right Click -> References Find out where else that thing is used

Ctrl + Click Click through to the Definition of that thing

F4 Open Type Hierarchy – Navigable Help on that Hierarchy

Ctrl + T Quick Type Hierarchy (Tooltip help)

Page 61: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Ctrl + Shift + T

• Launches the ‘Open Type’ dialog

• Search for part of the class name it prompts with some matches

Page 62: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

UIWidgetContainer Class

• Most Component class names start with UI, e.g UIWidgetContainerUIDialog

• This is the real ‘brains’ of how the control works and the options it can have

• Clues on how the control interacts with the Xpages system and page lifecycle

Page 63: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Component - Property Getter Setter pattern

• Common pattern used to enable ‘dynamically computed’ properties

If property was set with literal value e.g. “3”, or on page load “${some.value}”, return that value

Otherwise if it was specified as Dynamically computed value“#{some.value}”,

Compute it, and return that value

Setter is used to set the property when it was specified as literal value e.g. “3” or a computed on page load “${some.value}” once and then stores it

Page 64: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Component - State Saving Pattern

• Between requests, the Xpages runtime MAY need to save the control’s state

• It asks the control for a state ‘object’ using the saveState function

• Function should return some object which contains all the properties to save

• Usually uses an Object array [] so it can contain mixed types

Page 65: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Component - Restore State Pattern

• When Xpages runtime re-creates a component tree, will ask the component to ‘restore itself’

• Xpages runtime gives the component the same state ‘object’ back that the saveState function gave to it to save

• Component can then placeall the properties back inthere fields, ready to useduring the execution of theXpage

Page 66: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Does our Component inherit properties/behaviour?• We can investigate with some shortcut keys

Ctrl + Shift + T Find a Java Class by Name

Ctrl + Shift + R Find a Resource by name (XML file, image, text file etc.)

Search -> File Search Contents of files

Search -> Java Search Java types fields etc

Right Click -> References Find out where else that thing is used

Ctrl + Click Click through to the Definition of that thing

F4 Open Type Hierarchy – Navigable Help on that Hierarchy

Ctrl + T Quick Type Hierarchy (Tooltip help)

Page 67: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Ctrl + T• Quick Tooltip overview of the currently selected Java Type’s hierarchy

Page 68: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

F4• More Interactive Hierarchy

• Navigate through the hierarchy

• Filter / sort fields methods etc.

Page 69: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Source not Found

• Just a class that is part of the core platform

– you don’t have Source code for – yet

Page 70: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Renderers!

• Most likely the first thing you might Dabble in

– Oliver Busse NotesIn9

• http://www.notesin9.com/2015/04/20/notesin9-174-getting-started-with-custom-renderers/

• What do we want to know?

– What is the Default Renderer?

– What are the Renderers for other Themes?

Page 71: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

How are Renderers Chosen?

Component Family

Renderer Type

Renderer

Themes are used to change the components renderer typeResulting in selecting a different renderer

Page 72: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Finding the Component Family

• Look for getFamily() method in the Component– Might be in one of the Superclasses

Ctrl + Click

Page 73: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Finding Component Family

• Our Widget Container’s Component Family – javax.faces.Panel

Page 74: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Component Family

javax.faces.Panel

Renderer Type

Renderer

Themes are used to change the components renderer typeResulting in selecting a different renderer

Page 75: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Finding the Default Renderer Type

• Usually is set in the Constructor using setRendererType

Ctrl + Click

Page 76: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Finding the Default Renderer Type

• Widget Container Default Renderer Type is– com.ibm.extlib.containers.WidgetContainer

Page 77: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Component Family

javax.faces.Panel

Renderer Type

com.ibm.xsp.extlib.containers.WidgetContainer

Renderer

Page 78: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Find the Default Renderer

• “RendererType” is our clue

• Renderer will be registered in a faces config *.xml file

• Let’s Search –> File for the renderer type within *.xml

Page 79: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

1 Result that’s easy

• Double click the result

Page 80: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Registration of Renderer in faces-config.xml

Page 81: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Found our Renderer!

Page 82: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Family + Renderer Type

• If you still couldn’t Determine them from the source

Page 83: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Which Renderers for other themes?

• Theme will change the ‘rendererType’ via properties using Control ID

• What is the ‘Control ID’ for theming ?– Lets look for getStyleKitFamily() in the Component;

Ctrl + Click

Page 84: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

WidgetContainer Control ThemeId

• Turns out most of these themeId’s are in this StyleKitExtLibDefault class

Page 85: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Finding Themes that Modify WidgetContainer Properties

• Should be in *.theme files

• Will reference our ‘Container.Widget’ theme id

Page 86: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Found theme

• Lets just look at the bootstrap one

Double Click the search result

Page 87: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Bootstrap WidgetContainer Renderer

Search for the Renderer typeIn faces-config xml files

Page 88: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Found 1 Result

Double Click

Page 89: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Found Renderer Faces Config

• Use the ‘renderer-class’ to find the actual Renderer

Page 90: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Found our Bootstrap Renderer

Page 91: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

About Renderers

• Basic Concept is to Output HTML Markup

• ‘Encode’ means generate output– encodeBegin() output before children

– encodeChildren() output the child controls

– encodeEnd() generate output after children

• ‘Decode’ means interpret the response– User may have input a value that needs to

be given back to the component

Page 92: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

ResponseWriter Concept

<div id=“someclientid”>

</div>

Page 93: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

How did we go?

• Runtime

– Component Behaviour - FOUND

– Renderers

• Default Renderer - FOUND

• Renderers for Other themes

– Bootstrap - FOUND

– One UI 2– Could find using same method

– One UI 3 – Could find using same method

Page 94: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

SOME EXAMPLES

Page 95: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

InPlaceForm Action

• Looked at the DynamicContent action

• Copied elements and modified to suit InPlaceForm

• Shared back to the ExtensionLibrary!

Page 96: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Markdown Control

• Borrowed some logic from Martin Rolph’s (OvalUK) Markdown Custom Control

– With permission!

Edit mode

Read only

Page 97: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Extended InputRichText Control

HTML only (no images)

• Removes CKEditor plugins that allow image uploads

• Prevents Pasting of images (custom CKEditor plugin)

Page 98: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

JqGrid Control

• Inspired by Sumit Tayal’s AUSLUG 2015 presentation

– Unmask the True Potential of xGrid

– http://www.slideshare.net/sumittayal78/xgrid-true-potential

• Dynamically generated columns from Notes View Definition

– Learnt and Copied technique from the Dynamic View Control

• Automatically Creates a ‘REST Service’

– Learnt and Copied technique from Extlib Rest service controls;

• Visualizers, Panels

– Looked at other Ext Lib controls for examples

• Automatically add Jquery resources

– Techniques discovered through extlib and also Xpages Community

Page 99: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

JqGrid Control

Page 100: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Page 101: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

XPages Slack Channel

Sign Up!

• http://xpages-slack-invites.herokuapp.com/

Page 102: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Page 103: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Thanks for your time!

http://auslug.org/survey2016

Page 104: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Links

• Xpages Configuration File Format– https://www-10.lotus.com/ldd/ddwiki.nsf/dx/XPages_configuration_file_format

Page 105: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Setting Up to Browse Extlib

• Download Things– Download Eclipse

– Download XPages SDK

– Download Extension Library

• Launch Eclipse

• Install XPages SDK

• Import Extension Library projects

• Configure Xpages SDK

Page 106: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Download Eclipse

Eclipse is an IDE “Integrated Development Environment” which is usually used for Xpages plugin development

Page 107: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Page 108: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Page 109: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Extract Downloaded Zip

I usually put it in a “c:\eclipse-version\eclipse” folder so that I can keep separate versions available e.g.C:\eclipse-kepler\eclipseC:\eclipse-luna\eclipseC:\eclipse-mars\eclipse

Page 110: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Download Xpages SDK

• Search for it on OpenNTF

Page 111: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Download the Xpages SDK

Page 112: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Start Up EclipseDecide where to put your ‘workspace’ (basically a folder for settings and new projects)

I keep separate workspaces for separate versions and so usually name it V:\eclipse-version\workspace-shortdesce.g.v:\eclipse-mars\workspace-extlib

Page 113: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Install the Xpages SDK

Page 114: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Page 115: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Install Xpages SDK

Page 116: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Page 117: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Might see this for a while

Then this

Then this

Page 118: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Download Extension Library

Page 119: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Download this link, and then Extract the Zip to anywhere you prefer

Page 120: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Unzip Source Folders

Unzip the src archives

Page 121: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Import into Eclipse

Page 122: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Choose Existing Projects into Workspace

Page 123: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Importing srcOpenNTF

Page 124: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Add Main Plugins to a Working Set

Page 125: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Importing srcOpenNTF-designer

Page 126: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Show Working Sets

Page 127: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

ERRORS!

• Don’t Panic!• You can still browse the code

Just fine

Page 128: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Disable Maven Nature

Page 129: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Configure Xpages SDK Preferences

Page 130: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Choose Notes JRE

Page 131: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Create a Target Platform

Page 132: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Page 133: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Choose Target Platform

Page 134: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Clean

Page 135: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

Delete pom.xml files from all projects

Page 136: Anatomy of a UI Control - Extension Library Case Study

March 10th & 11th, Sydney, AustraliaMeet.Share.Learn.Connect @AusLUG #@Inform2016

No more errors!

Don’t worry about warnings, there is always warnings