implementing portlets using web scripts
TRANSCRIPT
![Page 1: Implementing portlets using Web Scripts](https://reader035.vdocuments.net/reader035/viewer/2022062503/5888843e1a28ab3e658b492f/html5/thumbnails/1.jpg)
Implementing portlets using WebScriptsPiergiorgio LucidiOpen Source ECM Specialist
Alfresco Trainer / Wiki Gardener / ContributorAuthor / Technical Reviewer @ Packt PublishingPMC Member @ Apache Software Foundation
Project Leader / Committer @ JBoss
![Page 2: Implementing portlets using Web Scripts](https://reader035.vdocuments.net/reader035/viewer/2022062503/5888843e1a28ab3e658b492f/html5/thumbnails/2.jpg)
What is a portal?
![Page 3: Implementing portlets using Web Scripts](https://reader035.vdocuments.net/reader035/viewer/2022062503/5888843e1a28ab3e658b492f/html5/thumbnails/3.jpg)
What is a portal?
• A portal is an application focused on• Aggregating apps based on different technologies• Creating user oriented and dynamic websites• Page-centric approach
• Portlets / Apps / Gadgets
• Enterprise services• Authentication• Authorization• Personalization• Export / Import• APIs for integrations
![Page 4: Implementing portlets using Web Scripts](https://reader035.vdocuments.net/reader035/viewer/2022062503/5888843e1a28ab3e658b492f/html5/thumbnails/4.jpg)
What is a portlet?
A portlet is an application that•Contains specific business logic
•Provides a fragment of content•Potentially the output fragment can be dynamic for each user
•A permission can be given for•The entire portal•Page•Portlet
•Can be implemented using bridging and wrappers
![Page 5: Implementing portlets using Web Scripts](https://reader035.vdocuments.net/reader035/viewer/2022062503/5888843e1a28ab3e658b492f/html5/thumbnails/5.jpg)
Why exposing WebScripts as portlets?
• Agile and quick approach• Reuse of existing components• Modularization• It’s fun ^__^
![Page 6: Implementing portlets using Web Scripts](https://reader035.vdocuments.net/reader035/viewer/2022062503/5888843e1a28ab3e658b492f/html5/thumbnails/6.jpg)
Exposing WebScripts as portlets
WebScriptPortlet• alfresco.war
• WebScripts
Pure Spring WebScripts
ProxyPortlet• share.war
• Surf pages• Surf components
• WebScripts
Spring Surf
![Page 7: Implementing portlets using Web Scripts](https://reader035.vdocuments.net/reader035/viewer/2022062503/5888843e1a28ab3e658b492f/html5/thumbnails/7.jpg)
Spring WebScripts framework
![Page 8: Implementing portlets using Web Scripts](https://reader035.vdocuments.net/reader035/viewer/2022062503/5888843e1a28ab3e658b492f/html5/thumbnails/8.jpg)
WebScriptPortlet – Deployment scenario
WebScriptPortlet• JVM
• Portal
• alfresco.war• portlet.xml
• Presentation• Take contents directly
from the local Alfresco
• Single tier architecture
JVMPortal
Alfresco
![Page 9: Implementing portlets using Web Scripts](https://reader035.vdocuments.net/reader035/viewer/2022062503/5888843e1a28ab3e658b492f/html5/thumbnails/9.jpg)
WebScriptPortlet – Parameters
• scriptUrl• URL of the WebScript
• Authenticator factory• jsr168.webclient
• Cookie• jsr168
• Portal session
![Page 10: Implementing portlets using Web Scripts](https://reader035.vdocuments.net/reader035/viewer/2022062503/5888843e1a28ab3e658b492f/html5/thumbnails/10.jpg)
WebScriptPortlet – Portlet descriptor
![Page 11: Implementing portlets using Web Scripts](https://reader035.vdocuments.net/reader035/viewer/2022062503/5888843e1a28ab3e658b492f/html5/thumbnails/11.jpg)
WebScriptPortlet – Rendering in the portal
![Page 12: Implementing portlets using Web Scripts](https://reader035.vdocuments.net/reader035/viewer/2022062503/5888843e1a28ab3e658b492f/html5/thumbnails/12.jpg)
WebScriptPortlet – How it works
Rendering phases:1. The portal starts to render the page
1. Alfresco starts to render the WebScript
1. Alfresco will authenticate user
1. WebScript is executed using the user permissions
1. The controller will return results in the FTL
1. Alfresco ends to render the WebScript in the portlet
1. The portal finishes to render the page
![Page 13: Implementing portlets using Web Scripts](https://reader035.vdocuments.net/reader035/viewer/2022062503/5888843e1a28ab3e658b492f/html5/thumbnails/13.jpg)
WebScriptPortlet – Best Practices
• Divide all the functionalities in simple views• Each atomic feature matched with a WebScript
• Use Ajax calls with the ticket session• Any other interaction needed for the WebScript UI
• Don’t overload the WebScript
• Keep it simple!!!
![Page 14: Implementing portlets using Web Scripts](https://reader035.vdocuments.net/reader035/viewer/2022062503/5888843e1a28ab3e658b492f/html5/thumbnails/14.jpg)
ProxyPortlet – Spring Surf architecture
![Page 15: Implementing portlets using Web Scripts](https://reader035.vdocuments.net/reader035/viewer/2022062503/5888843e1a28ab3e658b492f/html5/thumbnails/15.jpg)
ProxyPortlet – Deployment scenario
ProxyPortlet• JVM
• Portal
• share.war• portlet.xml
• 2-tiers architecture• Presentation tier
• Share.war
• Data tier• alfresco.war
• Remote calls against the remote repository
JVMPortalShare
JVMAlfresco
![Page 16: Implementing portlets using Web Scripts](https://reader035.vdocuments.net/reader035/viewer/2022062503/5888843e1a28ab3e658b492f/html5/thumbnails/16.jpg)
ProxyPortlet – Parameters
viewScriptUrl• URL related to
• Surf page• Surf component
![Page 17: Implementing portlets using Web Scripts](https://reader035.vdocuments.net/reader035/viewer/2022062503/5888843e1a28ab3e658b492f/html5/thumbnails/17.jpg)
ProxyPortlet – Rendering in the portal
![Page 18: Implementing portlets using Web Scripts](https://reader035.vdocuments.net/reader035/viewer/2022062503/5888843e1a28ab3e658b492f/html5/thumbnails/18.jpg)
ProxyPortlet – How it works
Rendering phases:1. The portal starts to render the page
1. Share starts to render the Surf page
1. Surf starts to render the component
1. Share invokes Alfresco using external authentication
1. Alfresco executes the Data WebScript
1. The returned JSON will be used in the FTL
1. Share ends to render the Surf page
1. The portal finishes to render the portlet
![Page 19: Implementing portlets using Web Scripts](https://reader035.vdocuments.net/reader035/viewer/2022062503/5888843e1a28ab3e658b492f/html5/thumbnails/19.jpg)
ProxyPortlet – Best Practices
• Configure SSO between Alfresco and the portal• External authentication
• Each request from Share will have an HTTP header• Alfresco will delegate the portal for authentication
• Divide each functionality thinking about usability
• Use Ajax calls for creating dynamic UI
• Don’t overload Surf pages and components
• Keep it simple!!!