relational xpages !! using xpages as the presentation ... · relational xpages !! using xpages as...

Post on 17-Apr-2020

53 Views

Category:

Documents

4 Downloads

Preview:

Click to see full reader

TRANSCRIPT

MakeEvery

MomentCount

2016ConnectThe Premier Social Business and Digital Experience Conference

#ibmconnect

Relational XPages !! Using XPages As The Presentation Layer for RDBMS Data. Paul T. Calhoun, NetNotes Solutions Unlimited, Inc.

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Your Presenter – This Is Me! •  Paul T. Calhoun

Vice President - QDiligence Owner – NetNotes Solutions Unlimited, Inc. - pcalhoun@nnsu.com

•  A highly rated architect, engineer, speaker and presenter who provides customer-focused knowledge transfer and consulting to organizations worldwide.

•  I have architected Domino, Web, Java, and XML Web Services solutions for his customers using Domino and WebSphere/WebSphere Portal as the primary platforms.

•  I am the co-author of the IBM Redbook “XML Powered by Domino,” have developed self paced and classroom training for XPages, XML and Web Services as well as Java. I have written dozens of articles for worldwide technical publications.

•  IBM Champion – 2013 and 2016

•  Certified – Administrator and Developer

•  Grandfather of two and ½ FOUR !!! (I have pictures. Lots and Lots of Pictures !!)

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Agenda •  Planning •  Using the Extension Library •  Using Client Side Grids and Native Controls •  References

MakeEvery

MomentCount

2016ConnectThe Premier Social Business and Digital Experience Conference

#ibmconnect

Planning

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Planning •  With out a doubt…

THIS IS THE MOST IMPORTANT PHASE OF

ANY TRANSITION !!!

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Planning – The People •  What you are going to need

§  An XPage developer (hopefully that’s you)

§  Two DBA’s

•  Database Administrator

-  Manage the SQL server environment

•  Database Architect

-  Convert your Document based, unstructured, duplicated everywhere data to normalized schema’s

•  If you don’t have the last two, just STOP. This will NOT end well !!!

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Planning – The Technology •  Domino Server

•  SQL Server

§  You may not have any choice about this…

§  Most common are;

•  Oracle

•  DB2

•  MS SQL

•  MySQL

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Planning – Options •  Questions

§  Do you need access to the data from the Notes Client ?

•  If Yes, then

§  For Notes Client access, Domino Can Connect to RDBMS via

•  LEI

•  DECS

•  Data Connections (In Designer)

•  All of these REQUIRE storing SOME data in the NSF

-  This is NOT a bad thing!!

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Planning – Options •  Questions

§  Do you need access to the data from the Notes Client ?

•  If No, then

§  Use Extension Library components

§  Use Client Side Grids and Native XPage components

§  Combination of above

•  These are the options we will be demonstrating today

MakeEvery

MomentCount

2016ConnectThe Premier Social Business and Digital Experience Conference

#ibmconnect

Using the Extension Library

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

The Extension Library •  Native JDBC controls have been part of the OpenNTF Extension Library for a long time.

•  They became OFFICIALLY Supported in 9.01

§  This is IMPORTANT to a LOT of organizations !!

§  There are STILL a lot of shops that will NOT allow the OpenNTF extension library to be installed

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Steps •  Procure the JDBC driver .jars for your RDBMS of choice

§  Available from your DBA !! Or the intertubes.

•  Create JDBC Driver Plugin

§  There is a wizard in Designer that will allow you to create an OSGI plugin for the server and the designer client that manages the JDBC connection classes

•  Deploy the Plug-in

§  Use the UpdateSite.nsf to deploy the plug-in and keep it up to date.

•  Create the connection configuration

•  Create the View XPage

•  Create the Data XPage

•  Wire them together

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Create JDBC Driver Plugin •  In the Designer Client choose

§  Tools > JDBC Driver Plug-in Wizard

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Create JDBC Driver Plugin (cont) •  The wizard supports the creation of plug-ins for all the major (and some minor) RDBMS.

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Create JDBC Driver Plugin (cont) •  Once you choose the Type

§  The Class and Plug-in Name are automatically filled in for you

•  Click the “Add JARS” button to add the JDBC jar file of the RDBMS you want to connect to.

•  If a “TYPE 4” driver is available that is best !!!

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Create JDBC Driver Plugin (cont) •  Provide a directory name where the update site should be created

•  Leave the Create full Update Site selected

•  Click Finish

§  (Some magic happens… then bada boom bada bing, you have an update site)

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Deploy the Plug-in •  Plan one

§  Give it to your Domino Administrator

•  (they aren’t really that busy anyway !!!)

§  Deploy to the TEST server (yes the TEST server) via the Update Site application.

•  You do have a TEST server don’t you?

§  Restart the server

•  Plan two

§  Do it yourself

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

What is your goal? •  So lets talk about goals !

§  What do you need to do here?

•  Read?

•  Read and Update?

•  Create, Read and Update?

•  Create, Read, Update and Delete?

•  In my experience (and YMMV) 84.2 percent of the time all you need to do is READ the data and present it in a nice way.

§  In reality there are very few DBA’s that are going to allow you Create, Update or Delete.

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Attaining your Goal ! •  This is where it’s crucial you interact with the DBA(rchitect)

§  You need to know…

•  Database Schema

§  Are you going to make calls via

•  Raw SQL statements

•  Stored procedures (think of these as compiled “agents” on the SQL server)

•  Stored procedures for everything (even SIMPLE reading) is the best practice.

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Creating the Connection configuration •  In the Package Explorer tab from the XPages perspective

§  Expand the WebContent folder of your application that will be used access the RDBMS

§  Expand the WEB-INF folder

•  Create a folder called “jdbc” all lower case

§  Right click on that folder and create a Newà Other à File

§  Call it what ever you want to, just make sure it ends in .jdbc

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Creating the Connection configuration •  Create the XML that will user the JDBC driver from the plug-in to connect to the RDBMS

•  Paul? Where did you learn that syntax ?

§  I read a book !!!! ( I always wanted to put this in a slide!! )

§  Specifically Chapter 12 of the XPages Extension Library Book

§  Then I read all of the release notes for each iteration of the JDBC parts of the extension library

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Creating the Connection configuration(cont) •  The <driver> parameter is class name from the deployed jar file

•  You will need to know…

§  The path and name to the server

§  The “Port” number the server is listening on (like 1352 for Domino)

§  User name and password to authenticate on the server and access the data.

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Creating the Connection configuration(cont) •  Finally add the parameters for the “Connection Pool”

§  This is one of the PRIMARY benefits of deploying your JDBC driver as a server plugin !

§  The “pool” will maintain the connections to the SQL server so all you have to do is get the data

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Get the Data •  If working with “Flat” content then the fastest way to get the data is via the

jdbcQueryJsonService !!

§  Pause for a moment of gratitude to the XPage Team !!!

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Get the Data (cont) •  Add a REST Service Control

•  Add a pathInfo variable

•  TIP: This allows you to test if you are getting JSON back from the service

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Get the Data (cont) •  Add the jdbcQueryJsonSeverice

•  Choose the connection name configured in the previous step

•  Set content type to “application/json”

•  Put in the name of the SQL table being conneted to

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Testing if you have data •  To test if you are getting data back from the REST service type in the URL of the XPage

and tack on the pathinfo variable

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Testing if you have data (cont) •  This also lets you know the “field names” that you need to wire to your display control

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Add a Dojo Data Grid control •  Set the storeComponentId to the name of the rest service

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Add columns for each JSON field to be displayed •  You can Drag over a Dojo Data Grid Column to the Grid control and set the properties

•  Then just copy and paste in the source to add more columns

•  The “field” property matches the field name returned by the JSON service

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

The Rendered Grid •  Some of the benefits of the Dojo Grid are

§  Automatic column sorting is the default !!!

§  Infinite scrolling

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Demo

32

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

What about displaying details though? •  The Dojo Grid is great for summary but I found it’s “Events” to be a bit hit or miss.

•  The View Control can also be wired to the REST service for displaying data.

•  A standard XPage can be used to display the details

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

The View Control •  A standard view control can use JDBC as the data source

§  NOTE: In order for the pager to work you MUST set ‘calculateCount’ to true !!!

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Code the Column click event •  The columns click event can be coded to read the clicked record number (or any column

used as the “key”)

§  Set this value to a scoped variable

•  Open the “Details” page

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

The Details Page •  In the ‘beforeRenderResponse’ event of the details page

§  Read the scoped variable

§  User the @JdbcExecuteQuery() function to read the specific record

§  Write the results of the query to the corresponding fields on the XPage

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

The Results •  Clicking a record in the view will open the details page and populate it with the returned

values from the @JdbcQuery function

•  So using the Extension Library and standard XPage controls you have created an interface to a RDBMS system !!!!!!

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Demo

38

MakeEvery

MomentCount

2016ConnectThe Premier Social Business and Digital Experience Conference

#ibmconnect

Using Client Side Grids and Native Controls

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

A More Elegant Solution •  Mixing Client Side Grids…

§  ExtJS

§  Dojo

§  jQuery

§  Etc...

•  With the Extension Library and Native controls allows Domino Developers to create modern look and feel interfaces for relational data.

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

The Grid •  I’m going to be using ExtJS (Sencha)

§  But I have also done this with the Dojo library (not extension controls)

•  I’m using the same Extension Library connection and REST service from the previous example

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Setup •  Add the needed libraries and CSS to the WebContent folder

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

The “View” XPage •  The View XPage contains

§  The REST Service control to get the data

§  An Output Script control

•  This is where all of the client side script code is written

§  A Panel (actually a <div> to render the grid)

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

The “View” XPage (cont) •  Add the CSS and libraries

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

The “View” XPage (cont) •  Define the “Model” (Fields)

•  Set configuration parameters and required functionality

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

The “View” XPage (cont) •  Create the data store (function that gets the json data)

•  Notice the URL is to the REST service ‘pathInfo’ variable from the same page

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

The “View” XPage (cont) •  Create the grid

§  The renderTo property maps it to the panel with the id of ‘gridHere’

§  The store references the json REST service

§  The listener is what reads the clicked row and passes the id to the person XPage to do the lookup.

§  Then all of the columns are defined

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

The Rendered Grid

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Demo

49

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

The Details Page •  This part is a little trickier

§  We need a way to read the specific selected record…

§  Then store those values...

§  Then render them on the page…

•  The Solution !! (Really “A” solution, there are LOTS of ways to paint this house !!)

§  Create a Java Class to capture the selected “key”, lookup and return the record

§  A Managed Bean to store the values and map to the XPage components

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

The Person Bean •  Create a Java class that will become the “backing” bean for the person XPage

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Create a Java Class… •  Create a Java class that executes the JDBC Query

•  Instantiates the Person Bean

•  Populates the Person Bean with the results of the JDBC Query

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

The Details Page •  Add controls to the XPage and bind them to the bean components via the expression

language

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Call the Java Code •  In the beforeRenderResponse event of the page instantiate the Java class and call the

method of the class the does the magic.

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

The Rendered Page •  The JDBC Query results are then displayed in the XPage !!!!!

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Implement full CRUD •  If the DBA allows it, you can use the @JDBCXXXX functions to implement a full CRUD

(Create,Read,Update,Delete) model

§  We have already “Read”

§  Add buttons to the XPage for each of the other tasks

•  Update, Create, Delete

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Demo

57

MakeEvery

MomentCount

2016ConnectThe Premier Social Business and Digital Experience Conference

#ibmconnect

References

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

References •  Get a Trial version of ExtJS

§  https://www.sencha.com/products/extjs/#overview

•  The XPages Extension Library book

§  http://www.amazon.com/XPages-Extension-Library-Step-Step/dp/0132901811

•  TLCC Courses

§  Java

§  The Extension Library

§  XPages

•  https://www.tlcc.com

MakeEvery

MomentCount

2016ConnectThe Premier Social Business and Digital Experience Conference

#ibmconnect

Thank you !!!!!

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Acknowledgements and Disclaimers Availability. References in this presentation to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates.

The workshops, sessions and materials have been prepared by IBM or the session speakers and reflect their own views. They are provided for informational purposes only, and are neither intended to, nor shall have the effect of being, legal or other guidance or advice to any participant. While efforts were made to verify the completeness and accuracy of the information contained in this presentation, it is provided AS-IS without warranty of any kind, express or implied. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, this presentation or any other materials. Nothing contained in this presentation is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software.

All customer examples described are presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual environmental costs and performance characteristics may vary by customer. Nothing contained in these materials is intended to, nor shall have the effect of, stating or implying that any activities undertaken by you will result in any specific sales, revenue growth or other results.

2016ConnectThe Premier Social Business and Digital Experience Conference

Ma

ke Every Mom

ent Coun

t

Acknowledgements and Disclaimers cont. © Copyright IBM Corporation 2015. All rights reserved.

•  U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

•  Please update paragraph below for the particular product or family brand trademarks you mention such as WebSphere, DB2, Maximo, Clearcase, Lotus, etc.

•  IBM, the IBM logo, ibm.com, [IBM Brand, if trademarked], and [IBM Product, if trademarked] are trademarks or registered trademarks of International Business Machines Corporation in the United States, other countries, or both. If these and other IBM trademarked terms are marked on their first occurrence in this information with a trademark symbol (® or ™), these symbols indicate U.S. registered or common law trademarks owned by IBM at the time this information was published. Such trademarks may also be registered or common law trademarks in other countries. A current list of IBM trademarks is available on the Web at “Copyright and trademark information” at www.ibm.com/legal/copytrade.shtml

If you have mentioned trademarks that are not from IBM, please update and add the following lines:

[Insert any special 3rd party trademark names/attributions here]

Other company, product, or service names may be trademarks or service marks of others.

top related