SlideShare une entreprise Scribd logo
1  sur  25
Télécharger pour lire hors ligne
D2W Stateful Controllers
Fuego Digital Media QSTP-LLC
Daniel Roy
• Using WebObjects since 2004
• Work with government agencies, private companies and various
foundations globally
• Fuego Content Management System & Fuego Frameworks
• Presence in North America and Middle East
Fuego History
• 42% of community uses D2W
• “D2W is to WebObjects apps as the assembly line is to automobiles...you
provide customization directions (D2W rules) to the assembly line (D2W) to
build your end products (WOComponent pages).”
• Flow is controlled by delegates that manage the actions and direction of the
application
• Use ERDBranchDelegate to define the actions displayed on the page by rules
or via introspection
Direct To Web
The Basics
query select edit save
Start/Stop
Confirm
Edit
Confirm
Confirm
saveForLater
Save
Delete
edit
Edit CommentreadyToSubmit*
readyToSubmit*
saveAndSubmit
Submit
delete*
confirmDeletion
approveDeletion
confirm
edit*
List Expense
Claims
select
cancel
Notes:
- Cancel is present on all pages, but only
shown for first.
- Any branches with * are optional
and are shown based on business logic
- Any branches with the same name,
are the same page configuration, but
with different branches
Needs to enter
comment?
NO
Edit Comment
YES
WHAT?
WHAT???
??
Back in the day...
• Without Project Wonder, rely on nextPageDelegate and
nextPage for navigation
• nextPageDelegate is checked first, and if found call nextPage()
• without nextPageDelegate, nextPage() is called on the D2WPage
component directly
• Single class between each page
Next Page Delegate
D2WPage
NPD
(select)
D2WPage
NPD
(edit)
D2WPage
NPD
(query)
...
Plain WebObjects Controller Sample Code
public class ManageUserEditNextPageDelegate implements NextPageDelegate {
	 public WOComponent nextPage(WOComponent sender) {
	 	 NSArray<User> selectedObjects = ((ERDPickPageInterface) sender).selectedObjects();
	 	 User currentUser = selectedObjects.get(0);
	 	 EditPageInterface epi = (EditPageInterface) D2W.factory().pageForConfigurationNamed("ManageUsers_User_Edit_PC", sender.session());
	 	 epi.setNextPageDelegate(new ManageUserSaveNextPageDelegate());
	 	 epi.setObject(currentUser);
	 	 return (WOComponent) epi;
	 }
}
Enter Project Wonder
• ERDBranchDelegate to the rescue!
• Now you can show multiple branch choices for a page
• Pull choices from D2W context in the method
branchChoicesForContext(), using the D2W rule key
“branchChoices”
• Or, use introspection to find all methods that take a single
WOComponent as parameter
ERDBranchDelegate
D2WPage ERDBD
D2WPage
(search)
D2WPage
(add)
D2WPage
(cancel)
ERDBD
D2WPage
(save)
D2WPage
(cancel)
D2WPage
(add)
ERDBranchDelegate Sample Code
public class ManageUserControllerSelectBranchDelegate extends ERDBranchDelegate {
	 // Return an edit page for a single selected row in the pick page
	 public WOComponent edit(WOComponent sender) {
	 	 NSArray<User> selectedObjects = ((ERDPickPageInterface) sender).selectedObjects();
	 	 User currentUser = selectedObjects.get(0);
	 	 EditPageInterface epi = (EditPageInterface) D2W.factory().pageForConfigurationNamed("ManageUsers_User_Edit_PC", sender.session());
	 	 epi.setNextPageDelegate(new ManageUserControllerSaveBranchDelegate());
	 	 epi.setObject(currentUser);
	 	 return (WOComponent) epi;
	 }
	 // From the selected items in the pick page, perform a delete
	 public WOComponent delete(WOComponent sender) {
	 	 NSArray<User> users = ((ERDPickPageInterface) sender).selectedObjects();
	 	 for (User user : users) {
	 	 	 user.delete();
	 	 }
	 	 if (users.count() > 0) {
	 	 	 // Assuming all in same EC.
	 	 	 users.get(0).editingContext().saveChanges();
	 	 }
	 	 return sender.pageWithName("PageWrapper");
	 }
}
But wait...
• Must still set and get the
objects on each page
• Lots of classes to write
• Why not reuse the same
delegate?
Benefits of Delegate Reuse
• Enter the controller/delegate many times (one controller for
many pages)
• Reuse the stored state in editing context
• Support one or many flows within the single class
• Define the visible branches using rules
Re-entrant Branch Delegate
D2WPageBD
queryPage
search()
edit()
editPage
selectPage
save()
Is ERDBranchDelegate Enough?
• Yes....but...no.
• Branch choices are defined in the rules, but can lead to a
complex ruleset depending on the business logic
• Introspection on the ERDBranchDelegate returns all the
methods in the class
Hello (Stateful) World!
• FDStatefulController is a re-entrant branch delegate extending
ERDBranchDelegate
• Better separation of MVC
• Override branchChoicesForContext(D2WContext context)
• Reuse page configurations (define the PC in code)
• store state between pages
• editing context
• EOs, etc in subclasses
branchChoicesForContext
public class StatefulController extends ERDBranchDelegate {
	 private NSArray<?> branches;
	 private EOEditingContext editingContext;
	 public NSArray<?> getBranches() {
	 	 return branches;
	 }
	 public void setBranches(NSArray<?> branches) {
	 	 this.branches = branches;
	 }
	
	 public EOEditingContext editingContext() {
	 	 if (this.editingContext == null) {
	 	 	 this.editingContext = ERXEC.newEditingContext();
	 	 }
	 	 return this.editingContext;
	 }
	 public NSArray branchChoicesForContext(D2WContext context) {
	 	 NSArray choices = getBranches();
	 if (choices == null) {
	 	 	 branches = (NSArray) context.valueForKey(BRANCH_CHOICES);
} else {
	 NSMutableArray translatedChoices = new NSMutableArray();
	 for (Iterator iter = choices.iterator(); iter.hasNext();) {
... rest of method continues the same as ERDBranchDelegate
StatefulController Code
// Return an edit page for a single selected row in the pick page
public WOComponent edit(WOComponent sender) {
	 NSArray<User> selectedObjects = ((ERDPickPageInterface) sender).selectedObjects();
	 User currentUser = selectedObjects.get(0);
	 setBranches(new NSArray("save"));
	 EditPageInterface epi = (EditPageInterface) D2W.factory().pageForConfigurationNamed("ManageUsers_User_Edit_PC", sender.session());
	 epi.setNextPageDelegate(this);
	 epi.setObject(currentUser);
	 return (WOComponent) epi;
}
public WOComponent save(WOComponent sender) {
	 editingContext().saveChanges();
	 return sender.pageWithName("PageWrapper");
}
// From the selected items in the pick page, perform a delete
public WOComponent delete(WOComponent sender) {
	 setBranches(null);
	 NSArray<User> users = ((ERDPickPageInterface) sender).selectedObjects();
	 ERXUtilities.deleteObjects(editingContext(), users);
	 return save(sender);
}
Page Utility Methods
Interaction
editPage
queryPage
listPage
inspectPage
messagePage
pickPage
selectPage
Utility
editingContext()
nestedEditingContext
save()
Utility Method Examples
protected EditPageInterface editPage(Session session, String pageConfigurationName, EOEnterpriseObject enterpriseObject) {
	 EditPageInterface epi = (EditPageInterface) pageForConfigurationNamed(pageConfigurationName, session);
	 epi.setNextPageDelegate(this);
	 epi.setObject(enterpriseObject);
	 return epi;
}
protected WOComponent pageForConfigurationNamed(String pageConfigurationName, Session session) {
	 WOComponent component = D2W.factory().pageForConfigurationNamed(pageConfigurationName, session);
	 if (component instanceof D2WPage) {
	 	 ((D2WPage) component).setNextPageDelegate(this);
	 }
	 return component;
}
Summary
• Re-entrant controller provides code reusability
• Specify branch choices programmatically
• Storing the editing context allows easy access to associated
objects during flows and encourages a single point of save
• Utility and convenience methods allow for simple setup and
development of customized flows
Resources
• What is Direct To Web?
http://wiki.wocommunity.org/pages/viewpage.action?pageId=1049018
• D2W Flow Control
http://wiki.wocommunity.org/display/documentation/D2W+Flow+Control
• ERDBranchDelegateInterface
http://jenkins.wocommunity.org/job/Wonder/lastSuccessfulBuild/javadoc/er/directtoweb/pages/
ERD2WPage.html#pageController()
• Page controller in ERD2W
http://osdir.com/ml/web.webobjects.wonder-disc/2006-05/msg00041.html
Q&A

Contenu connexe

Tendances

Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO DevsWO Community
 
HTML5 and CSS3 refresher
HTML5 and CSS3 refresherHTML5 and CSS3 refresher
HTML5 and CSS3 refresherIvano Malavolta
 
D2W Branding Using jQuery ThemeRoller
D2W Branding Using jQuery ThemeRollerD2W Branding Using jQuery ThemeRoller
D2W Branding Using jQuery ThemeRollerWO Community
 
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
ZZ BC#7.5 asp.net mvc practice  and guideline refresh! ZZ BC#7.5 asp.net mvc practice  and guideline refresh!
ZZ BC#7.5 asp.net mvc practice and guideline refresh! Chalermpon Areepong
 
Staying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPStaying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPOscar Merida
 
Java EE revisits design patterns
Java EE revisits design patternsJava EE revisits design patterns
Java EE revisits design patternsAlex Theedom
 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQueryAkshay Mathur
 
Staying Sane with Drupal (A Develper's Survival Guide)
Staying Sane with Drupal (A Develper's Survival Guide)Staying Sane with Drupal (A Develper's Survival Guide)
Staying Sane with Drupal (A Develper's Survival Guide)Oscar Merida
 
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...Sencha
 
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...J V
 
How to Write Custom Modules for PHP-based E-Commerce Systems (2011)
How to Write Custom Modules for PHP-based E-Commerce Systems (2011)How to Write Custom Modules for PHP-based E-Commerce Systems (2011)
How to Write Custom Modules for PHP-based E-Commerce Systems (2011)Roman Zenner
 
Spring Web Service, Spring Integration and Spring Batch
Spring Web Service, Spring Integration and Spring BatchSpring Web Service, Spring Integration and Spring Batch
Spring Web Service, Spring Integration and Spring BatchEberhard Wolff
 

Tendances (20)

COScheduler
COSchedulerCOScheduler
COScheduler
 
.Net template solution architecture
.Net template solution architecture.Net template solution architecture
.Net template solution architecture
 
[2015/2016] JavaScript
[2015/2016] JavaScript[2015/2016] JavaScript
[2015/2016] JavaScript
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
 
HTML5 and CSS3 refresher
HTML5 and CSS3 refresherHTML5 and CSS3 refresher
HTML5 and CSS3 refresher
 
D2W Branding Using jQuery ThemeRoller
D2W Branding Using jQuery ThemeRollerD2W Branding Using jQuery ThemeRoller
D2W Branding Using jQuery ThemeRoller
 
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
ZZ BC#7.5 asp.net mvc practice  and guideline refresh! ZZ BC#7.5 asp.net mvc practice  and guideline refresh!
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
 
Staying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPStaying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHP
 
Java EE revisits design patterns
Java EE revisits design patternsJava EE revisits design patterns
Java EE revisits design patterns
 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQuery
 
[2015/2016] Backbone JS
[2015/2016] Backbone JS[2015/2016] Backbone JS
[2015/2016] Backbone JS
 
Real World MVC
Real World MVCReal World MVC
Real World MVC
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
Staying Sane with Drupal (A Develper's Survival Guide)
Staying Sane with Drupal (A Develper's Survival Guide)Staying Sane with Drupal (A Develper's Survival Guide)
Staying Sane with Drupal (A Develper's Survival Guide)
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
 
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
 
How to Write Custom Modules for PHP-based E-Commerce Systems (2011)
How to Write Custom Modules for PHP-based E-Commerce Systems (2011)How to Write Custom Modules for PHP-based E-Commerce Systems (2011)
How to Write Custom Modules for PHP-based E-Commerce Systems (2011)
 
Asp.Net MVC 5 in Arabic
Asp.Net MVC 5 in ArabicAsp.Net MVC 5 in Arabic
Asp.Net MVC 5 in Arabic
 
Spring Web Service, Spring Integration and Spring Batch
Spring Web Service, Spring Integration and Spring BatchSpring Web Service, Spring Integration and Spring Batch
Spring Web Service, Spring Integration and Spring Batch
 

En vedette

Reenabling SOAP using ERJaxWS
Reenabling SOAP using ERJaxWSReenabling SOAP using ERJaxWS
Reenabling SOAP using ERJaxWSWO Community
 
Build and deployment
Build and deploymentBuild and deployment
Build and deploymentWO Community
 
Using Nagios to monitor your WO systems
Using Nagios to monitor your WO systemsUsing Nagios to monitor your WO systems
Using Nagios to monitor your WO systemsWO Community
 
Chaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real WorldChaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real WorldWO Community
 
Filtering data with D2W
Filtering data with D2W Filtering data with D2W
Filtering data with D2W WO Community
 
Migrating existing Projects to Wonder
Migrating existing Projects to WonderMigrating existing Projects to Wonder
Migrating existing Projects to WonderWO Community
 
Advanced Apache Cayenne
Advanced Apache CayenneAdvanced Apache Cayenne
Advanced Apache CayenneWO Community
 
iOS for ERREST - alternative version
iOS for ERREST - alternative versioniOS for ERREST - alternative version
iOS for ERREST - alternative versionWO Community
 
Deploying WO on Windows
Deploying WO on WindowsDeploying WO on Windows
Deploying WO on WindowsWO Community
 
"Framework Principal" pattern
"Framework Principal" pattern"Framework Principal" pattern
"Framework Principal" patternWO Community
 

En vedette (14)

Reenabling SOAP using ERJaxWS
Reenabling SOAP using ERJaxWSReenabling SOAP using ERJaxWS
Reenabling SOAP using ERJaxWS
 
Build and deployment
Build and deploymentBuild and deployment
Build and deployment
 
Using Nagios to monitor your WO systems
Using Nagios to monitor your WO systemsUsing Nagios to monitor your WO systems
Using Nagios to monitor your WO systems
 
Chaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real WorldChaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real World
 
Filtering data with D2W
Filtering data with D2W Filtering data with D2W
Filtering data with D2W
 
Migrating existing Projects to Wonder
Migrating existing Projects to WonderMigrating existing Projects to Wonder
Migrating existing Projects to Wonder
 
WOver
WOverWOver
WOver
 
iOS for ERREST
iOS for ERRESTiOS for ERREST
iOS for ERREST
 
Advanced Apache Cayenne
Advanced Apache CayenneAdvanced Apache Cayenne
Advanced Apache Cayenne
 
iOS for ERREST - alternative version
iOS for ERREST - alternative versioniOS for ERREST - alternative version
iOS for ERREST - alternative version
 
High availability
High availabilityHigh availability
High availability
 
Deploying WO on Windows
Deploying WO on WindowsDeploying WO on Windows
Deploying WO on Windows
 
KAAccessControl
KAAccessControlKAAccessControl
KAAccessControl
 
"Framework Principal" pattern
"Framework Principal" pattern"Framework Principal" pattern
"Framework Principal" pattern
 

Similaire à D2W Stateful Controllers

ReactJS - A quick introduction to Awesomeness
ReactJS - A quick introduction to AwesomenessReactJS - A quick introduction to Awesomeness
ReactJS - A quick introduction to AwesomenessRonny Haase
 
Controllers & actions
Controllers & actionsControllers & actions
Controllers & actionsEyal Vardi
 
Asp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design PatternAsp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design Patternmaddinapudi
 
SFDC UI - Introduction to Visualforce
SFDC UI -  Introduction to VisualforceSFDC UI -  Introduction to Visualforce
SFDC UI - Introduction to VisualforceSujit Kumar
 
React.js: You deserve to know about it
React.js: You deserve to know about itReact.js: You deserve to know about it
React.js: You deserve to know about itAnderson Aguiar
 
Rails vs Web2py
Rails vs Web2pyRails vs Web2py
Rails vs Web2pyjonromero
 
Rest web service_with_spring_hateoas
Rest web service_with_spring_hateoasRest web service_with_spring_hateoas
Rest web service_with_spring_hateoasZeid Hassan
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners Varun Raj
 
Nuxeo World Session: Layouts and Content Views
Nuxeo World Session: Layouts and Content ViewsNuxeo World Session: Layouts and Content Views
Nuxeo World Session: Layouts and Content ViewsNuxeo
 
Advance java session 5
Advance java session 5Advance java session 5
Advance java session 5Smita B Kumar
 
Vs2010and Ne Tframework
Vs2010and Ne TframeworkVs2010and Ne Tframework
Vs2010and Ne TframeworkKulveerSingh
 
phpWebApp presentation
phpWebApp presentationphpWebApp presentation
phpWebApp presentationDashamir Hoxha
 
Patterns Are Good For Managers
Patterns Are Good For ManagersPatterns Are Good For Managers
Patterns Are Good For ManagersAgileThought
 
Do iOS Presentation - Mobile app architectures
Do iOS Presentation - Mobile app architecturesDo iOS Presentation - Mobile app architectures
Do iOS Presentation - Mobile app architecturesDavid Broža
 
Developing ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller PatternDeveloping ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller Patterngoodfriday
 
Parallelminds.web partdemo
Parallelminds.web partdemoParallelminds.web partdemo
Parallelminds.web partdemoManishaChothe
 

Similaire à D2W Stateful Controllers (20)

ReactJS - A quick introduction to Awesomeness
ReactJS - A quick introduction to AwesomenessReactJS - A quick introduction to Awesomeness
ReactJS - A quick introduction to Awesomeness
 
Controllers & actions
Controllers & actionsControllers & actions
Controllers & actions
 
Conductor vs Fragments
Conductor vs FragmentsConductor vs Fragments
Conductor vs Fragments
 
Asp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design PatternAsp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design Pattern
 
SFDC UI - Introduction to Visualforce
SFDC UI -  Introduction to VisualforceSFDC UI -  Introduction to Visualforce
SFDC UI - Introduction to Visualforce
 
React.js: You deserve to know about it
React.js: You deserve to know about itReact.js: You deserve to know about it
React.js: You deserve to know about it
 
Rails vs Web2py
Rails vs Web2pyRails vs Web2py
Rails vs Web2py
 
ASP .net MVC
ASP .net MVCASP .net MVC
ASP .net MVC
 
Rest web service_with_spring_hateoas
Rest web service_with_spring_hateoasRest web service_with_spring_hateoas
Rest web service_with_spring_hateoas
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
 
Nuxeo World Session: Layouts and Content Views
Nuxeo World Session: Layouts and Content ViewsNuxeo World Session: Layouts and Content Views
Nuxeo World Session: Layouts and Content Views
 
ReactJS
ReactJSReactJS
ReactJS
 
Advance java session 5
Advance java session 5Advance java session 5
Advance java session 5
 
Zend framework
Zend frameworkZend framework
Zend framework
 
Vs2010and Ne Tframework
Vs2010and Ne TframeworkVs2010and Ne Tframework
Vs2010and Ne Tframework
 
phpWebApp presentation
phpWebApp presentationphpWebApp presentation
phpWebApp presentation
 
Patterns Are Good For Managers
Patterns Are Good For ManagersPatterns Are Good For Managers
Patterns Are Good For Managers
 
Do iOS Presentation - Mobile app architectures
Do iOS Presentation - Mobile app architecturesDo iOS Presentation - Mobile app architectures
Do iOS Presentation - Mobile app architectures
 
Developing ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller PatternDeveloping ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller Pattern
 
Parallelminds.web partdemo
Parallelminds.web partdemoParallelminds.web partdemo
Parallelminds.web partdemo
 

Plus de WO Community

Localizing your apps for multibyte languages
Localizing your apps for multibyte languagesLocalizing your apps for multibyte languages
Localizing your apps for multibyte languagesWO Community
 
CMS / BLOG and SnoWOman
CMS / BLOG and SnoWOmanCMS / BLOG and SnoWOman
CMS / BLOG and SnoWOmanWO Community
 
Persistent Session Storage
Persistent Session StoragePersistent Session Storage
Persistent Session StorageWO Community
 
WebObjects Optimization
WebObjects OptimizationWebObjects Optimization
WebObjects OptimizationWO Community
 
ERRest: the Basics
ERRest: the BasicsERRest: the Basics
ERRest: the BasicsWO Community
 

Plus de WO Community (11)

Localizing your apps for multibyte languages
Localizing your apps for multibyte languagesLocalizing your apps for multibyte languages
Localizing your apps for multibyte languages
 
WOdka
WOdkaWOdka
WOdka
 
ERGroupware
ERGroupwareERGroupware
ERGroupware
 
CMS / BLOG and SnoWOman
CMS / BLOG and SnoWOmanCMS / BLOG and SnoWOman
CMS / BLOG and SnoWOman
 
Using GIT
Using GITUsing GIT
Using GIT
 
Persistent Session Storage
Persistent Session StoragePersistent Session Storage
Persistent Session Storage
 
Back2 future
Back2 futureBack2 future
Back2 future
 
WebObjects Optimization
WebObjects OptimizationWebObjects Optimization
WebObjects Optimization
 
Dynamic Elements
Dynamic ElementsDynamic Elements
Dynamic Elements
 
Practical ERSync
Practical ERSyncPractical ERSync
Practical ERSync
 
ERRest: the Basics
ERRest: the BasicsERRest: the Basics
ERRest: the Basics
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Dernier (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

D2W Stateful Controllers

  • 1. D2W Stateful Controllers Fuego Digital Media QSTP-LLC Daniel Roy
  • 2. • Using WebObjects since 2004 • Work with government agencies, private companies and various foundations globally • Fuego Content Management System & Fuego Frameworks • Presence in North America and Middle East Fuego History
  • 3.
  • 4. • 42% of community uses D2W • “D2W is to WebObjects apps as the assembly line is to automobiles...you provide customization directions (D2W rules) to the assembly line (D2W) to build your end products (WOComponent pages).” • Flow is controlled by delegates that manage the actions and direction of the application • Use ERDBranchDelegate to define the actions displayed on the page by rules or via introspection Direct To Web
  • 6. Start/Stop Confirm Edit Confirm Confirm saveForLater Save Delete edit Edit CommentreadyToSubmit* readyToSubmit* saveAndSubmit Submit delete* confirmDeletion approveDeletion confirm edit* List Expense Claims select cancel Notes: - Cancel is present on all pages, but only shown for first. - Any branches with * are optional and are shown based on business logic - Any branches with the same name, are the same page configuration, but with different branches Needs to enter comment? NO Edit Comment YES WHAT? WHAT??? ??
  • 7. Back in the day... • Without Project Wonder, rely on nextPageDelegate and nextPage for navigation • nextPageDelegate is checked first, and if found call nextPage() • without nextPageDelegate, nextPage() is called on the D2WPage component directly • Single class between each page
  • 9. Plain WebObjects Controller Sample Code public class ManageUserEditNextPageDelegate implements NextPageDelegate { public WOComponent nextPage(WOComponent sender) { NSArray<User> selectedObjects = ((ERDPickPageInterface) sender).selectedObjects(); User currentUser = selectedObjects.get(0); EditPageInterface epi = (EditPageInterface) D2W.factory().pageForConfigurationNamed("ManageUsers_User_Edit_PC", sender.session()); epi.setNextPageDelegate(new ManageUserSaveNextPageDelegate()); epi.setObject(currentUser); return (WOComponent) epi; } }
  • 10. Enter Project Wonder • ERDBranchDelegate to the rescue! • Now you can show multiple branch choices for a page • Pull choices from D2W context in the method branchChoicesForContext(), using the D2W rule key “branchChoices” • Or, use introspection to find all methods that take a single WOComponent as parameter
  • 12. ERDBranchDelegate Sample Code public class ManageUserControllerSelectBranchDelegate extends ERDBranchDelegate { // Return an edit page for a single selected row in the pick page public WOComponent edit(WOComponent sender) { NSArray<User> selectedObjects = ((ERDPickPageInterface) sender).selectedObjects(); User currentUser = selectedObjects.get(0); EditPageInterface epi = (EditPageInterface) D2W.factory().pageForConfigurationNamed("ManageUsers_User_Edit_PC", sender.session()); epi.setNextPageDelegate(new ManageUserControllerSaveBranchDelegate()); epi.setObject(currentUser); return (WOComponent) epi; } // From the selected items in the pick page, perform a delete public WOComponent delete(WOComponent sender) { NSArray<User> users = ((ERDPickPageInterface) sender).selectedObjects(); for (User user : users) { user.delete(); } if (users.count() > 0) { // Assuming all in same EC. users.get(0).editingContext().saveChanges(); } return sender.pageWithName("PageWrapper"); } }
  • 13. But wait... • Must still set and get the objects on each page • Lots of classes to write • Why not reuse the same delegate?
  • 14. Benefits of Delegate Reuse • Enter the controller/delegate many times (one controller for many pages) • Reuse the stored state in editing context • Support one or many flows within the single class • Define the visible branches using rules
  • 16. Is ERDBranchDelegate Enough? • Yes....but...no. • Branch choices are defined in the rules, but can lead to a complex ruleset depending on the business logic • Introspection on the ERDBranchDelegate returns all the methods in the class
  • 17. Hello (Stateful) World! • FDStatefulController is a re-entrant branch delegate extending ERDBranchDelegate • Better separation of MVC • Override branchChoicesForContext(D2WContext context) • Reuse page configurations (define the PC in code) • store state between pages • editing context • EOs, etc in subclasses
  • 18. branchChoicesForContext public class StatefulController extends ERDBranchDelegate { private NSArray<?> branches; private EOEditingContext editingContext; public NSArray<?> getBranches() { return branches; } public void setBranches(NSArray<?> branches) { this.branches = branches; } public EOEditingContext editingContext() { if (this.editingContext == null) { this.editingContext = ERXEC.newEditingContext(); } return this.editingContext; } public NSArray branchChoicesForContext(D2WContext context) { NSArray choices = getBranches(); if (choices == null) { branches = (NSArray) context.valueForKey(BRANCH_CHOICES); } else { NSMutableArray translatedChoices = new NSMutableArray(); for (Iterator iter = choices.iterator(); iter.hasNext();) { ... rest of method continues the same as ERDBranchDelegate
  • 19. StatefulController Code // Return an edit page for a single selected row in the pick page public WOComponent edit(WOComponent sender) { NSArray<User> selectedObjects = ((ERDPickPageInterface) sender).selectedObjects(); User currentUser = selectedObjects.get(0); setBranches(new NSArray("save")); EditPageInterface epi = (EditPageInterface) D2W.factory().pageForConfigurationNamed("ManageUsers_User_Edit_PC", sender.session()); epi.setNextPageDelegate(this); epi.setObject(currentUser); return (WOComponent) epi; } public WOComponent save(WOComponent sender) { editingContext().saveChanges(); return sender.pageWithName("PageWrapper"); } // From the selected items in the pick page, perform a delete public WOComponent delete(WOComponent sender) { setBranches(null); NSArray<User> users = ((ERDPickPageInterface) sender).selectedObjects(); ERXUtilities.deleteObjects(editingContext(), users); return save(sender); }
  • 21. Utility Method Examples protected EditPageInterface editPage(Session session, String pageConfigurationName, EOEnterpriseObject enterpriseObject) { EditPageInterface epi = (EditPageInterface) pageForConfigurationNamed(pageConfigurationName, session); epi.setNextPageDelegate(this); epi.setObject(enterpriseObject); return epi; } protected WOComponent pageForConfigurationNamed(String pageConfigurationName, Session session) { WOComponent component = D2W.factory().pageForConfigurationNamed(pageConfigurationName, session); if (component instanceof D2WPage) { ((D2WPage) component).setNextPageDelegate(this); } return component; }
  • 22.
  • 23. Summary • Re-entrant controller provides code reusability • Specify branch choices programmatically • Storing the editing context allows easy access to associated objects during flows and encourages a single point of save • Utility and convenience methods allow for simple setup and development of customized flows
  • 24. Resources • What is Direct To Web? http://wiki.wocommunity.org/pages/viewpage.action?pageId=1049018 • D2W Flow Control http://wiki.wocommunity.org/display/documentation/D2W+Flow+Control • ERDBranchDelegateInterface http://jenkins.wocommunity.org/job/Wonder/lastSuccessfulBuild/javadoc/er/directtoweb/pages/ ERD2WPage.html#pageController() • Page controller in ERD2W http://osdir.com/ml/web.webobjects.wonder-disc/2006-05/msg00041.html
  • 25. Q&A