SlideShare una empresa de Scribd logo
1 de 72
Descargar para leer sin conexión
© 2013 Russell Maher
Managed Beans:
When, Why and How
Russell Maher
QDiligence / RGM Consulting
© 2013 Russell Maher
IamLUG 2013 Sponsors
IamLUG 2013
Speaker Introduction
• Russell Maher
 President, QDiligence / RGM Consulting
 Independent Consultant in Chicago area
 Exclusively Notes and Domino since 1994
 Certified Instructor, Developer, Admin
 Spoken 50+ times at LUG and The View events in U.S., Europe
and Australia and IBM Connect 2013
 Founded QDiligence in 2010
 Commercially hosted multi-tenant XPage SEC compliance
solution
 Blogs at XPageTips.com
3
IamLUG 2013
Attendee Introduction
• You are an XPager
 You have created and deployed actual XPage applications
• You know...
 Notes & Domino pretty well
 How to create XPages, data sources, custom controls, repeat
controls, etc.
 Domino Server-Side JavaScript API well enough to get things
done
• You DO NOT need to know Java™
4
IamLUG 2013
First Things First!
• THE CODE!
 http://www.rgmconsulting.com/IAmLugCode
 You want it…I want you to have it!
• THE SLIDES!
 http://www.rgmconsulting.com/IAmLUGSlides
5
IamLUG 2013
Agenda
• High Level Concepts
• Our First Managed Bean
• Debugging Managed Beans
• When Do Managed Beans Make Sense?
• Building The Audit Bean
• Q & A
6
IamLUG 2013
High Level Concepts
• What is a Managed Bean?
 A Serializable Plain Old Java Object (POJO) with a no-argument
constructor, private properties exposed via public getter and
setter methods and configured to a specific scope
• Created in IBM Domino Designer in Java design elements
• How are they used?
 Programmatically: To perform the same processing previously
done SSJS
 Professionally: To get Java in your fingers and expand your
Java skills
7
IamLUG 2013
High Level Concepts
• How are managed beans configured?
 Via the faces-config.xml file within the NSF
• How are they deployed?
 Right in your NSF!
 They are “hot” – no server changes required after updates
• How are they documented?
 You add JavaDoc comments
 You generate JavaDoc using, you guessed it, a JavaDoc
generator!
 Easily produces standard documentation format
8
IamLUG 2013
Agenda
• High Level Concepts
• Our First Managed Bean
• Debugging Managed Beans
• When Do Managed Beans Make Sense?
• Building The Audit Bean
• Q & A
9
IamLUG 2013
Our First Managed Bean
• Four Steps To Create A Managed Bean
 Create the managed bean class
 Add private properties with public getters/setters
 Configure the managed bean in faces-config.xml
 Use your managed bean in an XPage
10
IamLUG 2013
Step 1 – Create the Managed Bean Class
• In Domino Designer…
 Create a new Java Class Design Element
 Set the package as needed
 Set the Class name as desired
 Select…
 Constructors from superclass
 Generate comments
 Add the java.io.Serializable Interface
 Click “Finish”
11
IamLUG 2013
Step 1 – Create the Managed Bean Class
12
IamLUG 2013
Step 1 – Create the Managed Bean Class
• The Results:
A Serializable Java Class with a no-argument constructor
13
IamLUG 2013
Step 2 – Add Private Properties With Public Getters/Setters
• Add private properties to your Java class
14
IamLUG 2013
Step 2 – Add Private Properties With Public Getters/Setters
• Create methods to get or set those property values
(getters and setters)
 Right-click to access context menu
 Choose Source – Create getters and Setters…
 Select the properties (fields) that need get and/or set methods
 Choose a location for the new methods
 Click “OK”
15
IamLUG 2013
Step 2 – Add Private Properties With Public Getters/Setters
16
IamLUG 2013
Step 2 – Add Private Properties With Public Getters/Setters
• New getters/setters will appear in the location you chose
17
IamLUG 2013
Step 3 – Configure The Managed Bean In Faces-config.xml
• In Application Configuration locate and edit the faces-
config.xml
• Add configuration markup identifying the managed
bean’s…
 Reference name – The name you want to call it by
 Java class – The actual Java class
 Scope – Application, Session, View, Request or None
18
IamLUG 2013
Step 3 – Configure The Managed Bean In Faces-config.xml
19
IamLUG 2013
Step 4 – Use Your Managed Bean In An XPage
• Connect to your managed bean using…
 Expression Language (EL)
20
IamLUG 2013
Step 4 – Use Your Managed Bean In An XPage
• Connect to your managed bean using…
 Managed bean public methods
21
IamLUG 2013
Creating A “First” Managed Bean
22
IamLUG 2013
Agenda
• High Level Concepts
• Our First Managed Bean
• Debugging Managed Beans
• When Do Managed Beans Make Sense?
• Building The Audit Bean
• Q & A
23
IamLUG 2013
Debugging Managed Beans
• Domino Designer can debug your managed beans
 And SSJS in IBM Notes Social Edition
• Three steps to debugging
 Start your server in debug mode
 Create a debug configuration
 Set breakpoints in your code and “listen”
24
IamLUG 2013
Starting Your Server In Debug Mode
• Change your server notes.ini file by adding the following:
 JavaEnableDebug=1
JavaDebugOptions=transport=dt_socket,server=y,suspend=n,a
ddress=8000
• You will see that your server is ready for Java debug
connections in the server console or log
25
IamLUG 2013
Creating A Debug Configuration
• Open a Java design element
• Open the Debug Configurations…
26
IamLUG 2013
Creating A Debug Configuration
• Alternatively switch to the Debug Perspective
• Open Debug Configurations…
27
IamLUG 2013
Creating A Debug Configuration
• Create a new debug configuration
28
IamLUG 2013
Creating A Debug Configuration
• Configure the debug configuration by adding or ensuring
the Project name includes your NSF
29
IamLUG 2013
Add Breakpoints To Your Managed Bean
30
IamLUG 2013
Now Go Forth And Debug!
• Connect to the server using your debug configuration
31
IamLUG 2013
Run Your Code
• After executing your code you may see this prompt to
switch to the Debug Perspective
32
IamLUG 2013
Run Your Code
• The Debug Perspective provides the debugging
functionality
33
IamLUG 2013
Debugging FirstBean
34
IamLUG 2013
Agenda
• High Level Concepts
• Our First Managed Bean
• Debugging Managed Beans
• When Do Managed Beans Make Sense?
• Building The Audit Bean
• Q & A
35
IamLUG 2013
When Do Managed Beans Make Sense?
• When there is Complexity
 Are you tracking many SSJS
scoped variables?
 Do your XPages have complex/progressive
disclosure requirements?
 Would the “work item” be better
represented as an “object”?
• When you need Persistence
 Persistence = “remembering things for later”
 Do you need to track user activity across the entire application?
 Does your application require cross-document tracking?
36
IamLUG 2013
The Demo Application
• Annual Audits Application
 Based on an existing production application
 Each year facilities are required to self audit
 Audits comprise different areas: Customs, Export, Finance and
others
 Each audit “type” has a different set of questions
 Each audit type is updated annually
 The audit cycle is a 60 day window in Q4
 Audits are assigned to individuals
37
IamLUG 2013
The Demo Application
• Complexity level is perfect for “beaning”
 Multiple audit types
 Multiple questions
 Multiple users
 Annual updates
 Hard deadlines
• Persistence is required
 User activity needs to be tracked throughout application
 We need cross-document access
 We need access to the same keywords throughout application
38
IamLUG 2013
Annual Audits Application
39
IamLUG 2013
Agenda
• High Level Concepts
• Our First Managed Bean
• Debugging Managed Beans
• When Do Managed Beans Make Sense?
• Building The Audit Bean
• Q & A
40
IamLUG 2013
Basic Java Syntax Rules
• Java is very similar to Server-Side JavaScript
 Java is case sensitive
 Statements end with a semi-colon;
 Most data types are objects
 Only a few primitives
 Integer (object) vs. int (primitive)
 If statements are used for testing
 if(x==9) { Do something }
41
IamLUG 2013
Basic Java Syntax Rules
• Try/Catch blocks surround methods that “throw”
exceptions
• Methods may or may not return values
42
IamLUG 2013
The Bean Rules
• A Plain Old Java Object is considered a bean if it follows
this basic structure
43
private fields
(properties)
No-Argument
Constructor
Operational
methods
Getters/Setters
IamLUG 2013
The Bean Rules
• Managed beans should implement the Serializable
interface
• Serialization is the ability to store the state of a Java
object for later use
 Removed from memory
 Stored typically to disc
 Read from disc
 Restored into memory
• serialVersionUID value is used to aid verification
during the process
44
IamLUG 2013
Adding the Serial Version UID
• Domino Designer will generate the required
serialVersionUID for you if you hover over the class
name
45
IamLUG 2013
Creating The Audit Bean Class
46
IamLUG 2013
Before You Bean…Architect Your Solution
• Managed bean flexibility can be a “Bridge to Nowhere”
• Time spent planning architecture is well worth it!
 What functions will beans provide?
 Reading/writing, emailing, math operations…
 What events will be handled by your managed beans?
 Saving, editing, approving/not approving…
 How many managed beans do you need and what will they do?
 Administrative bean, user bean, config bean, audit bean,
utility bean…
 What properties and methods will each bean have?
47
IamLUG 2013
Annual Audits Application Beans And Classes
48
AdminBean
• Provides Keyword Choices
• Audit Record Maintenance functions
AdminUtils
• Provides static utility
functions to other beans
and classes
AuditBean
• Represents a single
audit in its entirety
AuditUserBean
• Represents the current user
AuditLogBean
• Provides activity logging
to all other beans and classes
AuditQuestion
• Represents a single
audit question
IamLUG 2013
Bean Relationships
49
auditUserBean
• First Name
• Last Name
• Full Name
• Administrator?
• Visited home
page?
auditLog Bean
auditQuestion Class
• Format
• Text
• Required?
• Question Key
• Audit Control
Number
• Answer Doc UNID
auditBean
• Year
• Type
• Assigned To
• Key
• Control Number
• Status
auditQuestion
auditQuestion
auditQuestion
IamLUG 2013
Annual Audits Architectural Overview
• Question configuration separated from answers
 Each config is keyed to a specific annual audit year and type
• Answers are stored in individual documents
 One answer = one document
• Audit.xsp repeat control loops through a sorted list of
questions and answers
• Custom controls in the repeat are dynamically bound to
correct answer documents
50
IamLUG 2013
Advantages/Disadvantages
• Advantages
 Data normalization
 Individual answers can be easily maintained through code
 The data model lends itself very well to producing data exports,
reports and PDF files
 Allows for individualization on a per question basis
 Unlimited flexibility for audit creation
• Disadvantages
 A lot of documents
 A little more code
 Missing answer documents are fatal
51
IamLUG 2013
Audit Bean Task #1 – Set Basic Audit Information
• Audit.xsp uses the AuditBean properties for audit
information display
 Title of the audit
 The name of the current user
 Audit record control number
 Any other information that is audit-specific
52
IamLUG 2013
AuditBean Step #1 – Setting Basic Audit Information
53
IamLUG 2013
Audit Bean Task #2 – Building The Questions
• Next up, the AuditBean creates a list of all the questions
for this audit
 The list of questions is sorted by key
 Each question is represented as an auditQuestion object
 auditQuestion properties:
 Format of the question
 Question text
 Whether it is required
 Question key
 UNID of the associated answer document
54
IamLUG 2013
Java TreeMaps
• Java has a wonderful object called a TreeMap
 Perfect for tracking auditQuestion objects
• Java TreeMaps…
 Sort themselves automatically
 Are comprised of MapEntry objects
 Each MapEntry object has a key and a value
55
IamLUG 2013
AuditBean Step #3 – Building The Questions
56
IamLUG 2013
Connecting the Audit Record to an Audit
• Audit Records contain information about the year and
type of audit
• Audits are represented by an AuditBean instantiated
before the audit is accessed
• AuditBean initialization method called from a link in the
audit records view
• AuditBean built before audit.xsp is opened
57
IamLUG 2013
Path From Link To Audit
58
IamLUG 2013
Connecting The Audit Record To The AuditBean
59
IamLUG 2013
How Audit.xsp Works
• When auditPage.xsp opens…
 Repeat Control accesses the AuditBean
 Loops through the TreeMap of auditQuestion objects
 Automatically sorted in question order for this specific year
and audit type
 A questionControl Custom Control is repeated once for every
auditQuestion object
 The questionControl contains:
 Document data source
 Question Text
 Custom controls for different answer formats (Radio, Text)
 Everything the questionControl needs to know about the
current question is contained in the auditQuestion object
60
IamLUG 2013
Creating AuditPage.xsp
61
IamLUG 2013
Sharing Data Between Managed Beans
• Sharing data between beans is very common
 Why duplicate information when you can just go read it?
• Several ways to do this:
 “Note Passing” via the sessionMap
 Bean injection and managed properties
 One managed bean can be a property of another managed
bean
62
IamLUG 2013
Using the SessionMap To Share Data
• The sessionMap is a Java Map
 Objects accessible by a key value
 You already use this when you write sessionScope.put(“x”,5)
• Utility functions can be used to read from/write to the
sessionMap
 Handy mechanism especially since all of your sessionScoped
managed beans exist in the sessionMap
 Does require you to keep track of the scoped variables being
passed around
 Documentation anyone?
63
IamLUG 2013
SessionMap Utility Functions
64
IamLUG 2013
Using Managed Properties
• Managed beans can be configured to have default values
for their properties
• Set in the faces-congif.xml
65
IamLUG 2013
Using A Managed Bean As A Managed Property
• Managed beans often have properties that are Java
objects
 questionsList property of AuditBean is a TreeMap
• A managed property can have a default value that is
another managed bean
66
IamLUG 2013
Sharing Managed Bean Data
67
IamLUG 2013
Agenda
• High Level Concepts
• Our First Managed Bean
• Debugging Managed Beans
• When Do Managed Beans Make Sense?
• Building The Audit Bean
• Q & A
68
IamLUG 2013
Q & A
• Questions?
• ¿Preguntas?
• Domande?
• Haben Sie Fragen?
• 有问题吗?
• Spørsmål?
• Spørgsmål?
• 質問はありますか?
69
IamLUG 2013
Recommended Resources
• The BalusC Code
 EXCELLENT resource on Java and JSF!
 http://balusc.blogspot.com/
• StackOverflow
 http://StackOverflow.com
• Code Ranch
 JSF Forum - http://www.coderanch.com/forums/f-82/JSF
 Active discussion on All Thinge JSF and Java
• NotesIn9
 http://NotesIn9.com
70
IamLUG 2013
Thank You For Coming!
71
IamLUG 2013
72
Follow Up
How to contact me:
Russell Maher
Russ.Maher@RGMConsulting.com
XPageTips.com

Más contenido relacionado

La actualidad más candente

Play Framework workshop: full stack java web app
Play Framework workshop: full stack java web appPlay Framework workshop: full stack java web app
Play Framework workshop: full stack java web appAndrew Skiba
 
Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Saeed Zarinfam
 
Java Builds with Maven and Ant
Java Builds with Maven and AntJava Builds with Maven and Ant
Java Builds with Maven and AntDavid Noble
 
An introduction to Maven
An introduction to MavenAn introduction to Maven
An introduction to MavenJoao Pereira
 
Java9 and the impact on Maven Projects (JFall 2016)
Java9 and the impact on Maven Projects (JFall 2016)Java9 and the impact on Maven Projects (JFall 2016)
Java9 and the impact on Maven Projects (JFall 2016)Robert Scholte
 
An Introduction to Maven Part 1
An Introduction to Maven Part 1An Introduction to Maven Part 1
An Introduction to Maven Part 1MD Sayem Ahmed
 
Maven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafeMaven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafeHolasz Kati
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemAndres Almiray
 
Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]Ryan Cuprak
 
Maven plugins, properties en profiles: Advanced concepts in Maven
Maven plugins, properties en profiles: Advanced concepts in MavenMaven plugins, properties en profiles: Advanced concepts in Maven
Maven plugins, properties en profiles: Advanced concepts in MavenGeert Pante
 
BP207 - Meet the Java Application Server You Already Own – IBM Domino
BP207 - Meet the Java Application Server You Already Own – IBM DominoBP207 - Meet the Java Application Server You Already Own – IBM Domino
BP207 - Meet the Java Application Server You Already Own – IBM DominoSerdar Basegmez
 

La actualidad más candente (20)

Maven basics
Maven basicsMaven basics
Maven basics
 
Play Framework workshop: full stack java web app
Play Framework workshop: full stack java web appPlay Framework workshop: full stack java web app
Play Framework workshop: full stack java web app
 
Apache Lucene for Java EE Developers
Apache Lucene for Java EE DevelopersApache Lucene for Java EE Developers
Apache Lucene for Java EE Developers
 
Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)
 
Apache Maven
Apache MavenApache Maven
Apache Maven
 
Java Builds with Maven and Ant
Java Builds with Maven and AntJava Builds with Maven and Ant
Java Builds with Maven and Ant
 
Maven
Maven Maven
Maven
 
Apache maven 2 overview
Apache maven 2 overviewApache maven 2 overview
Apache maven 2 overview
 
An introduction to Maven
An introduction to MavenAn introduction to Maven
An introduction to Maven
 
Introduction to maven
Introduction to mavenIntroduction to maven
Introduction to maven
 
Java9 and the impact on Maven Projects (JFall 2016)
Java9 and the impact on Maven Projects (JFall 2016)Java9 and the impact on Maven Projects (JFall 2016)
Java9 and the impact on Maven Projects (JFall 2016)
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
An Introduction to Maven Part 1
An Introduction to Maven Part 1An Introduction to Maven Part 1
An Introduction to Maven Part 1
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
Maven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafeMaven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafe
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX Ecosystem
 
Apache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolboxApache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolbox
 
Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]
 
Maven plugins, properties en profiles: Advanced concepts in Maven
Maven plugins, properties en profiles: Advanced concepts in MavenMaven plugins, properties en profiles: Advanced concepts in Maven
Maven plugins, properties en profiles: Advanced concepts in Maven
 
BP207 - Meet the Java Application Server You Already Own – IBM Domino
BP207 - Meet the Java Application Server You Already Own – IBM DominoBP207 - Meet the Java Application Server You Already Own – IBM Domino
BP207 - Meet the Java Application Server You Already Own – IBM Domino
 

Destacado

OpenData Hackathon Vancouver- IMBY
OpenData Hackathon Vancouver- IMBYOpenData Hackathon Vancouver- IMBY
OpenData Hackathon Vancouver- IMBYBen Cappellacci
 
Agro ecology strategies A Lecture by Mr. Allah Dad Khan Visiting Professor t...
Agro ecology strategies  A Lecture by Mr. Allah Dad Khan Visiting Professor t...Agro ecology strategies  A Lecture by Mr. Allah Dad Khan Visiting Professor t...
Agro ecology strategies A Lecture by Mr. Allah Dad Khan Visiting Professor t...Mr.Allah Dad Khan
 
Optimum ventures - Bevo Agro - Take Private Proposal
Optimum ventures - Bevo Agro - Take Private ProposalOptimum ventures - Bevo Agro - Take Private Proposal
Optimum ventures - Bevo Agro - Take Private ProposalBen Cappellacci
 
Sustainable Dry Bean Production
Sustainable Dry Bean ProductionSustainable Dry Bean Production
Sustainable Dry Bean ProductionElisaMendelsohn
 
One village one product
One village one product One village one product
One village one product Barun Khadka
 
Global Pulse Scenario: Consumption, Production and Trade
Global Pulse Scenario: Consumption, Production and TradeGlobal Pulse Scenario: Consumption, Production and Trade
Global Pulse Scenario: Consumption, Production and TradeICARDA
 
Project to develope a model village by 2016 ( eng)
Project to develope a model village by 2016 ( eng)Project to develope a model village by 2016 ( eng)
Project to develope a model village by 2016 ( eng)Nutan Chaturvedi
 
L.L. Bean Marketing Strategy
L.L. Bean Marketing StrategyL.L. Bean Marketing Strategy
L.L. Bean Marketing Strategywenzelhe
 
Production technology of French bean
Production technology of French bean Production technology of French bean
Production technology of French bean Student
 
3 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 20173 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 2017Drift
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheLeslie Samuel
 

Destacado (13)

OpenData Hackathon Vancouver- IMBY
OpenData Hackathon Vancouver- IMBYOpenData Hackathon Vancouver- IMBY
OpenData Hackathon Vancouver- IMBY
 
Agro ecology strategies A Lecture by Mr. Allah Dad Khan Visiting Professor t...
Agro ecology strategies  A Lecture by Mr. Allah Dad Khan Visiting Professor t...Agro ecology strategies  A Lecture by Mr. Allah Dad Khan Visiting Professor t...
Agro ecology strategies A Lecture by Mr. Allah Dad Khan Visiting Professor t...
 
Optimum ventures - Bevo Agro - Take Private Proposal
Optimum ventures - Bevo Agro - Take Private ProposalOptimum ventures - Bevo Agro - Take Private Proposal
Optimum ventures - Bevo Agro - Take Private Proposal
 
Sustainable Dry Bean Production
Sustainable Dry Bean ProductionSustainable Dry Bean Production
Sustainable Dry Bean Production
 
One village one product
One village one product One village one product
One village one product
 
Global Pulse Scenario: Consumption, Production and Trade
Global Pulse Scenario: Consumption, Production and TradeGlobal Pulse Scenario: Consumption, Production and Trade
Global Pulse Scenario: Consumption, Production and Trade
 
Project to develope a model village by 2016 ( eng)
Project to develope a model village by 2016 ( eng)Project to develope a model village by 2016 ( eng)
Project to develope a model village by 2016 ( eng)
 
L.L. Bean Marketing Strategy
L.L. Bean Marketing StrategyL.L. Bean Marketing Strategy
L.L. Bean Marketing Strategy
 
LL Bean Case Study
LL Bean Case StudyLL Bean Case Study
LL Bean Case Study
 
Production technology of French bean
Production technology of French bean Production technology of French bean
Production technology of French bean
 
Parle Agro Pvt. Ltd.
Parle Agro Pvt. Ltd.Parle Agro Pvt. Ltd.
Parle Agro Pvt. Ltd.
 
3 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 20173 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 2017
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
 

Similar a Managed Beans: When, Why and How

JMP402 Master Class: Managed beans and XPages: Your Time Is Now
JMP402 Master Class: Managed beans and XPages: Your Time Is NowJMP402 Master Class: Managed beans and XPages: Your Time Is Now
JMP402 Master Class: Managed beans and XPages: Your Time Is NowRussell Maher
 
Application Lifecycle Management with Visual Studio 2013
Application Lifecycle Management  with Visual Studio 2013Application Lifecycle Management  with Visual Studio 2013
Application Lifecycle Management with Visual Studio 2013Mahmoud Samara
 
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug JavaWriting better code: How the Netbeans IDE Helps you Write, Test and Debug Java
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Javaidrsolutions
 
Ibm rational build merge online Training at GoLogica
Ibm rational build merge online Training at GoLogicaIbm rational build merge online Training at GoLogica
Ibm rational build merge online Training at GoLogicaGoLogica Technologies
 
Symantec - From Early Drupal Adoption to the Latest Drupal Innovations
Symantec - From Early Drupal Adoption to the Latest Drupal InnovationsSymantec - From Early Drupal Adoption to the Latest Drupal Innovations
Symantec - From Early Drupal Adoption to the Latest Drupal InnovationsTag1 Consulting, Inc.
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSCreating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSGunnar Hillert
 
AD208 - End to End Quality Processes for Top Notch XPages Apps
AD208 - End to End Quality Processes for Top Notch XPages AppsAD208 - End to End Quality Processes for Top Notch XPages Apps
AD208 - End to End Quality Processes for Top Notch XPages Appsbeglee
 
Agile and Continuous Delivery for Audits and Exams - DC Continuous Delivery M...
Agile and Continuous Delivery for Audits and Exams - DC Continuous Delivery M...Agile and Continuous Delivery for Audits and Exams - DC Continuous Delivery M...
Agile and Continuous Delivery for Audits and Exams - DC Continuous Delivery M...Simon Storm
 
Accessibility Testing - Using Asqatasun - Meetup Webinar
Accessibility Testing - Using Asqatasun - Meetup WebinarAccessibility Testing - Using Asqatasun - Meetup Webinar
Accessibility Testing - Using Asqatasun - Meetup WebinarKeyur Shah
 
Connect 2014 JMP101: Java for XPages Development
Connect 2014 JMP101: Java for XPages DevelopmentConnect 2014 JMP101: Java for XPages Development
Connect 2014 JMP101: Java for XPages Developmentpanagenda
 
Streamlining Testing with Visual Studio 2012
Streamlining Testing with Visual Studio 2012Streamlining Testing with Visual Studio 2012
Streamlining Testing with Visual Studio 2012Imaginet
 
Agile Secure Cloud Application Development Management
Agile Secure Cloud Application Development ManagementAgile Secure Cloud Application Development Management
Agile Secure Cloud Application Development ManagementAdam Getchell
 
Webinar: Ten Ways to Enhance Your Salesforce.com Application in 2013
Webinar: Ten Ways to Enhance Your Salesforce.com Application in 2013Webinar: Ten Ways to Enhance Your Salesforce.com Application in 2013
Webinar: Ten Ways to Enhance Your Salesforce.com Application in 2013Emtec Inc.
 
A Day in the Life: Developer Enhancements with Visual Studio 2012
A Day in the Life: Developer Enhancements with Visual Studio 2012A Day in the Life: Developer Enhancements with Visual Studio 2012
A Day in the Life: Developer Enhancements with Visual Studio 2012Imaginet
 
AD1545 - Extending the XPages Extension Library
AD1545 - Extending the XPages Extension LibraryAD1545 - Extending the XPages Extension Library
AD1545 - Extending the XPages Extension Librarypaidi_ed
 
Introduction to the IBM Java Tools
Introduction to the IBM Java ToolsIntroduction to the IBM Java Tools
Introduction to the IBM Java ToolsChris Bailey
 

Similar a Managed Beans: When, Why and How (20)

JMP402 Master Class: Managed beans and XPages: Your Time Is Now
JMP402 Master Class: Managed beans and XPages: Your Time Is NowJMP402 Master Class: Managed beans and XPages: Your Time Is Now
JMP402 Master Class: Managed beans and XPages: Your Time Is Now
 
Application Lifecycle Management with Visual Studio 2013
Application Lifecycle Management  with Visual Studio 2013Application Lifecycle Management  with Visual Studio 2013
Application Lifecycle Management with Visual Studio 2013
 
Neoload
Neoload Neoload
Neoload
 
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug JavaWriting better code: How the Netbeans IDE Helps you Write, Test and Debug Java
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java
 
Ibm rational build merge online Training at GoLogica
Ibm rational build merge online Training at GoLogicaIbm rational build merge online Training at GoLogica
Ibm rational build merge online Training at GoLogica
 
Symantec - From Early Drupal Adoption to the Latest Drupal Innovations
Symantec - From Early Drupal Adoption to the Latest Drupal InnovationsSymantec - From Early Drupal Adoption to the Latest Drupal Innovations
Symantec - From Early Drupal Adoption to the Latest Drupal Innovations
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSCreating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJS
 
AD208 - End to End Quality Processes for Top Notch XPages Apps
AD208 - End to End Quality Processes for Top Notch XPages AppsAD208 - End to End Quality Processes for Top Notch XPages Apps
AD208 - End to End Quality Processes for Top Notch XPages Apps
 
Agile and Continuous Delivery for Audits and Exams - DC Continuous Delivery M...
Agile and Continuous Delivery for Audits and Exams - DC Continuous Delivery M...Agile and Continuous Delivery for Audits and Exams - DC Continuous Delivery M...
Agile and Continuous Delivery for Audits and Exams - DC Continuous Delivery M...
 
Accessibility Testing - Using Asqatasun - Meetup Webinar
Accessibility Testing - Using Asqatasun - Meetup WebinarAccessibility Testing - Using Asqatasun - Meetup Webinar
Accessibility Testing - Using Asqatasun - Meetup Webinar
 
Connect 2014 JMP101: Java for XPages Development
Connect 2014 JMP101: Java for XPages DevelopmentConnect 2014 JMP101: Java for XPages Development
Connect 2014 JMP101: Java for XPages Development
 
Streamlining Testing with Visual Studio 2012
Streamlining Testing with Visual Studio 2012Streamlining Testing with Visual Studio 2012
Streamlining Testing with Visual Studio 2012
 
Agile Secure Cloud Application Development Management
Agile Secure Cloud Application Development ManagementAgile Secure Cloud Application Development Management
Agile Secure Cloud Application Development Management
 
Webinar: Ten Ways to Enhance Your Salesforce.com Application in 2013
Webinar: Ten Ways to Enhance Your Salesforce.com Application in 2013Webinar: Ten Ways to Enhance Your Salesforce.com Application in 2013
Webinar: Ten Ways to Enhance Your Salesforce.com Application in 2013
 
A Day in the Life: Developer Enhancements with Visual Studio 2012
A Day in the Life: Developer Enhancements with Visual Studio 2012A Day in the Life: Developer Enhancements with Visual Studio 2012
A Day in the Life: Developer Enhancements with Visual Studio 2012
 
AD1545 - Extending the XPages Extension Library
AD1545 - Extending the XPages Extension LibraryAD1545 - Extending the XPages Extension Library
AD1545 - Extending the XPages Extension Library
 
Introduction to the IBM Java Tools
Introduction to the IBM Java ToolsIntroduction to the IBM Java Tools
Introduction to the IBM Java Tools
 
Kku2011
Kku2011Kku2011
Kku2011
 
Automated Browser Testing
Automated Browser TestingAutomated Browser Testing
Automated Browser Testing
 
Modular enablement
Modular enablementModular enablement
Modular enablement
 

Último

Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Adtran
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8DianaGray10
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfAijun Zhang
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPathCommunity
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 

Último (20)

Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdf
 
201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation Developers
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 

Managed Beans: When, Why and How

  • 1. © 2013 Russell Maher Managed Beans: When, Why and How Russell Maher QDiligence / RGM Consulting
  • 2. © 2013 Russell Maher IamLUG 2013 Sponsors
  • 3. IamLUG 2013 Speaker Introduction • Russell Maher  President, QDiligence / RGM Consulting  Independent Consultant in Chicago area  Exclusively Notes and Domino since 1994  Certified Instructor, Developer, Admin  Spoken 50+ times at LUG and The View events in U.S., Europe and Australia and IBM Connect 2013  Founded QDiligence in 2010  Commercially hosted multi-tenant XPage SEC compliance solution  Blogs at XPageTips.com 3
  • 4. IamLUG 2013 Attendee Introduction • You are an XPager  You have created and deployed actual XPage applications • You know...  Notes & Domino pretty well  How to create XPages, data sources, custom controls, repeat controls, etc.  Domino Server-Side JavaScript API well enough to get things done • You DO NOT need to know Java™ 4
  • 5. IamLUG 2013 First Things First! • THE CODE!  http://www.rgmconsulting.com/IAmLugCode  You want it…I want you to have it! • THE SLIDES!  http://www.rgmconsulting.com/IAmLUGSlides 5
  • 6. IamLUG 2013 Agenda • High Level Concepts • Our First Managed Bean • Debugging Managed Beans • When Do Managed Beans Make Sense? • Building The Audit Bean • Q & A 6
  • 7. IamLUG 2013 High Level Concepts • What is a Managed Bean?  A Serializable Plain Old Java Object (POJO) with a no-argument constructor, private properties exposed via public getter and setter methods and configured to a specific scope • Created in IBM Domino Designer in Java design elements • How are they used?  Programmatically: To perform the same processing previously done SSJS  Professionally: To get Java in your fingers and expand your Java skills 7
  • 8. IamLUG 2013 High Level Concepts • How are managed beans configured?  Via the faces-config.xml file within the NSF • How are they deployed?  Right in your NSF!  They are “hot” – no server changes required after updates • How are they documented?  You add JavaDoc comments  You generate JavaDoc using, you guessed it, a JavaDoc generator!  Easily produces standard documentation format 8
  • 9. IamLUG 2013 Agenda • High Level Concepts • Our First Managed Bean • Debugging Managed Beans • When Do Managed Beans Make Sense? • Building The Audit Bean • Q & A 9
  • 10. IamLUG 2013 Our First Managed Bean • Four Steps To Create A Managed Bean  Create the managed bean class  Add private properties with public getters/setters  Configure the managed bean in faces-config.xml  Use your managed bean in an XPage 10
  • 11. IamLUG 2013 Step 1 – Create the Managed Bean Class • In Domino Designer…  Create a new Java Class Design Element  Set the package as needed  Set the Class name as desired  Select…  Constructors from superclass  Generate comments  Add the java.io.Serializable Interface  Click “Finish” 11
  • 12. IamLUG 2013 Step 1 – Create the Managed Bean Class 12
  • 13. IamLUG 2013 Step 1 – Create the Managed Bean Class • The Results: A Serializable Java Class with a no-argument constructor 13
  • 14. IamLUG 2013 Step 2 – Add Private Properties With Public Getters/Setters • Add private properties to your Java class 14
  • 15. IamLUG 2013 Step 2 – Add Private Properties With Public Getters/Setters • Create methods to get or set those property values (getters and setters)  Right-click to access context menu  Choose Source – Create getters and Setters…  Select the properties (fields) that need get and/or set methods  Choose a location for the new methods  Click “OK” 15
  • 16. IamLUG 2013 Step 2 – Add Private Properties With Public Getters/Setters 16
  • 17. IamLUG 2013 Step 2 – Add Private Properties With Public Getters/Setters • New getters/setters will appear in the location you chose 17
  • 18. IamLUG 2013 Step 3 – Configure The Managed Bean In Faces-config.xml • In Application Configuration locate and edit the faces- config.xml • Add configuration markup identifying the managed bean’s…  Reference name – The name you want to call it by  Java class – The actual Java class  Scope – Application, Session, View, Request or None 18
  • 19. IamLUG 2013 Step 3 – Configure The Managed Bean In Faces-config.xml 19
  • 20. IamLUG 2013 Step 4 – Use Your Managed Bean In An XPage • Connect to your managed bean using…  Expression Language (EL) 20
  • 21. IamLUG 2013 Step 4 – Use Your Managed Bean In An XPage • Connect to your managed bean using…  Managed bean public methods 21
  • 22. IamLUG 2013 Creating A “First” Managed Bean 22
  • 23. IamLUG 2013 Agenda • High Level Concepts • Our First Managed Bean • Debugging Managed Beans • When Do Managed Beans Make Sense? • Building The Audit Bean • Q & A 23
  • 24. IamLUG 2013 Debugging Managed Beans • Domino Designer can debug your managed beans  And SSJS in IBM Notes Social Edition • Three steps to debugging  Start your server in debug mode  Create a debug configuration  Set breakpoints in your code and “listen” 24
  • 25. IamLUG 2013 Starting Your Server In Debug Mode • Change your server notes.ini file by adding the following:  JavaEnableDebug=1 JavaDebugOptions=transport=dt_socket,server=y,suspend=n,a ddress=8000 • You will see that your server is ready for Java debug connections in the server console or log 25
  • 26. IamLUG 2013 Creating A Debug Configuration • Open a Java design element • Open the Debug Configurations… 26
  • 27. IamLUG 2013 Creating A Debug Configuration • Alternatively switch to the Debug Perspective • Open Debug Configurations… 27
  • 28. IamLUG 2013 Creating A Debug Configuration • Create a new debug configuration 28
  • 29. IamLUG 2013 Creating A Debug Configuration • Configure the debug configuration by adding or ensuring the Project name includes your NSF 29
  • 30. IamLUG 2013 Add Breakpoints To Your Managed Bean 30
  • 31. IamLUG 2013 Now Go Forth And Debug! • Connect to the server using your debug configuration 31
  • 32. IamLUG 2013 Run Your Code • After executing your code you may see this prompt to switch to the Debug Perspective 32
  • 33. IamLUG 2013 Run Your Code • The Debug Perspective provides the debugging functionality 33
  • 35. IamLUG 2013 Agenda • High Level Concepts • Our First Managed Bean • Debugging Managed Beans • When Do Managed Beans Make Sense? • Building The Audit Bean • Q & A 35
  • 36. IamLUG 2013 When Do Managed Beans Make Sense? • When there is Complexity  Are you tracking many SSJS scoped variables?  Do your XPages have complex/progressive disclosure requirements?  Would the “work item” be better represented as an “object”? • When you need Persistence  Persistence = “remembering things for later”  Do you need to track user activity across the entire application?  Does your application require cross-document tracking? 36
  • 37. IamLUG 2013 The Demo Application • Annual Audits Application  Based on an existing production application  Each year facilities are required to self audit  Audits comprise different areas: Customs, Export, Finance and others  Each audit “type” has a different set of questions  Each audit type is updated annually  The audit cycle is a 60 day window in Q4  Audits are assigned to individuals 37
  • 38. IamLUG 2013 The Demo Application • Complexity level is perfect for “beaning”  Multiple audit types  Multiple questions  Multiple users  Annual updates  Hard deadlines • Persistence is required  User activity needs to be tracked throughout application  We need cross-document access  We need access to the same keywords throughout application 38
  • 39. IamLUG 2013 Annual Audits Application 39
  • 40. IamLUG 2013 Agenda • High Level Concepts • Our First Managed Bean • Debugging Managed Beans • When Do Managed Beans Make Sense? • Building The Audit Bean • Q & A 40
  • 41. IamLUG 2013 Basic Java Syntax Rules • Java is very similar to Server-Side JavaScript  Java is case sensitive  Statements end with a semi-colon;  Most data types are objects  Only a few primitives  Integer (object) vs. int (primitive)  If statements are used for testing  if(x==9) { Do something } 41
  • 42. IamLUG 2013 Basic Java Syntax Rules • Try/Catch blocks surround methods that “throw” exceptions • Methods may or may not return values 42
  • 43. IamLUG 2013 The Bean Rules • A Plain Old Java Object is considered a bean if it follows this basic structure 43 private fields (properties) No-Argument Constructor Operational methods Getters/Setters
  • 44. IamLUG 2013 The Bean Rules • Managed beans should implement the Serializable interface • Serialization is the ability to store the state of a Java object for later use  Removed from memory  Stored typically to disc  Read from disc  Restored into memory • serialVersionUID value is used to aid verification during the process 44
  • 45. IamLUG 2013 Adding the Serial Version UID • Domino Designer will generate the required serialVersionUID for you if you hover over the class name 45
  • 46. IamLUG 2013 Creating The Audit Bean Class 46
  • 47. IamLUG 2013 Before You Bean…Architect Your Solution • Managed bean flexibility can be a “Bridge to Nowhere” • Time spent planning architecture is well worth it!  What functions will beans provide?  Reading/writing, emailing, math operations…  What events will be handled by your managed beans?  Saving, editing, approving/not approving…  How many managed beans do you need and what will they do?  Administrative bean, user bean, config bean, audit bean, utility bean…  What properties and methods will each bean have? 47
  • 48. IamLUG 2013 Annual Audits Application Beans And Classes 48 AdminBean • Provides Keyword Choices • Audit Record Maintenance functions AdminUtils • Provides static utility functions to other beans and classes AuditBean • Represents a single audit in its entirety AuditUserBean • Represents the current user AuditLogBean • Provides activity logging to all other beans and classes AuditQuestion • Represents a single audit question
  • 49. IamLUG 2013 Bean Relationships 49 auditUserBean • First Name • Last Name • Full Name • Administrator? • Visited home page? auditLog Bean auditQuestion Class • Format • Text • Required? • Question Key • Audit Control Number • Answer Doc UNID auditBean • Year • Type • Assigned To • Key • Control Number • Status auditQuestion auditQuestion auditQuestion
  • 50. IamLUG 2013 Annual Audits Architectural Overview • Question configuration separated from answers  Each config is keyed to a specific annual audit year and type • Answers are stored in individual documents  One answer = one document • Audit.xsp repeat control loops through a sorted list of questions and answers • Custom controls in the repeat are dynamically bound to correct answer documents 50
  • 51. IamLUG 2013 Advantages/Disadvantages • Advantages  Data normalization  Individual answers can be easily maintained through code  The data model lends itself very well to producing data exports, reports and PDF files  Allows for individualization on a per question basis  Unlimited flexibility for audit creation • Disadvantages  A lot of documents  A little more code  Missing answer documents are fatal 51
  • 52. IamLUG 2013 Audit Bean Task #1 – Set Basic Audit Information • Audit.xsp uses the AuditBean properties for audit information display  Title of the audit  The name of the current user  Audit record control number  Any other information that is audit-specific 52
  • 53. IamLUG 2013 AuditBean Step #1 – Setting Basic Audit Information 53
  • 54. IamLUG 2013 Audit Bean Task #2 – Building The Questions • Next up, the AuditBean creates a list of all the questions for this audit  The list of questions is sorted by key  Each question is represented as an auditQuestion object  auditQuestion properties:  Format of the question  Question text  Whether it is required  Question key  UNID of the associated answer document 54
  • 55. IamLUG 2013 Java TreeMaps • Java has a wonderful object called a TreeMap  Perfect for tracking auditQuestion objects • Java TreeMaps…  Sort themselves automatically  Are comprised of MapEntry objects  Each MapEntry object has a key and a value 55
  • 56. IamLUG 2013 AuditBean Step #3 – Building The Questions 56
  • 57. IamLUG 2013 Connecting the Audit Record to an Audit • Audit Records contain information about the year and type of audit • Audits are represented by an AuditBean instantiated before the audit is accessed • AuditBean initialization method called from a link in the audit records view • AuditBean built before audit.xsp is opened 57
  • 58. IamLUG 2013 Path From Link To Audit 58
  • 59. IamLUG 2013 Connecting The Audit Record To The AuditBean 59
  • 60. IamLUG 2013 How Audit.xsp Works • When auditPage.xsp opens…  Repeat Control accesses the AuditBean  Loops through the TreeMap of auditQuestion objects  Automatically sorted in question order for this specific year and audit type  A questionControl Custom Control is repeated once for every auditQuestion object  The questionControl contains:  Document data source  Question Text  Custom controls for different answer formats (Radio, Text)  Everything the questionControl needs to know about the current question is contained in the auditQuestion object 60
  • 62. IamLUG 2013 Sharing Data Between Managed Beans • Sharing data between beans is very common  Why duplicate information when you can just go read it? • Several ways to do this:  “Note Passing” via the sessionMap  Bean injection and managed properties  One managed bean can be a property of another managed bean 62
  • 63. IamLUG 2013 Using the SessionMap To Share Data • The sessionMap is a Java Map  Objects accessible by a key value  You already use this when you write sessionScope.put(“x”,5) • Utility functions can be used to read from/write to the sessionMap  Handy mechanism especially since all of your sessionScoped managed beans exist in the sessionMap  Does require you to keep track of the scoped variables being passed around  Documentation anyone? 63
  • 65. IamLUG 2013 Using Managed Properties • Managed beans can be configured to have default values for their properties • Set in the faces-congif.xml 65
  • 66. IamLUG 2013 Using A Managed Bean As A Managed Property • Managed beans often have properties that are Java objects  questionsList property of AuditBean is a TreeMap • A managed property can have a default value that is another managed bean 66
  • 68. IamLUG 2013 Agenda • High Level Concepts • Our First Managed Bean • Debugging Managed Beans • When Do Managed Beans Make Sense? • Building The Audit Bean • Q & A 68
  • 69. IamLUG 2013 Q & A • Questions? • ¿Preguntas? • Domande? • Haben Sie Fragen? • 有问题吗? • Spørsmål? • Spørgsmål? • 質問はありますか? 69
  • 70. IamLUG 2013 Recommended Resources • The BalusC Code  EXCELLENT resource on Java and JSF!  http://balusc.blogspot.com/ • StackOverflow  http://StackOverflow.com • Code Ranch  JSF Forum - http://www.coderanch.com/forums/f-82/JSF  Active discussion on All Thinge JSF and Java • NotesIn9  http://NotesIn9.com 70
  • 71. IamLUG 2013 Thank You For Coming! 71
  • 72. IamLUG 2013 72 Follow Up How to contact me: Russell Maher Russ.Maher@RGMConsulting.com XPageTips.com