Microsoft®, WINDOWS®, NT®, EXCEL®, Word®, PowerPoint® and SQL Server® are registered trademarks of Microsoft Corporation.
•
IBM®, DB2®, OS/2®, DB2/6000®, Parallel Sysplex®, MVS/ESA®, RS/6000®, AIX®, S/390®, AS/400®, OS/390®, and OS/400® are registered trademarks of IBM Corporation.
•
ORACLE® is a registered trademark of ORACLE Corporation.
•
INFORMIX®-OnLine for SAP and INFORMIX® Dynamic ServerTM are registered trademarks of Informix Software Incorporated.
•
UNIX®, X/Open®, OSF/1®, and Motif® are registered trademarks of the Open Group.
•
Citrix®, the Citrix logo, ICA®, Program Neighborhood®, MetaFrame®, WinFrame®, VideoFrame®, MultiWin® and other Citrix product names referenced herein are trademarks of Citrix Systems, Inc.
•
HTML, DHTML, XML, XHTML are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology.
•
JAVA® is a registered trademark of Sun Microsystems, Inc.
•
JAVASCRIPT® is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape.
•
SAP, SAP Logo, R/2, RIVA, R/3, SAP ArchiveLink, SAP Business Workflow, WebFlow, SAP EarlyWatch, BAPI, SAPPHIRE, Management Cockpit, mySAP.com Logo and mySAP.com are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other products mentioned are trademarks or registered trademarks of their respective companies.
Disclaimer THESE MATERIALS ARE PROVIDED BY SAP ON AN "AS IS" BASIS, AND SAP EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR APPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THESE MATERIALS AND THE SERVICE, INFORMATION, TEXT, GRAPHICS, LINKS, OR ANY OTHER MATERIALS AND PRODUCTS CONTAINED HEREIN. IN NO EVENT SHALL SAP BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES OF ANY KIND WHATSOEVER, INCLUDING WITHOUT LIMITATION LOST REVENUES OR LOST PROFITS, WHICH MAY RESULT FROM THE USE OF THESE MATERIALS OR INCLUDED SOFTWARE COMPONENTS.
g2006112212631
About This Handbook This handbook is intended to complement the instructor-led presentation of this course, and serve as a source of reference. It is not suitable for self-study.
Typographic Conventions American English is the standard used in this handbook. The following typographic conventions are also used. Type Style
Description
Example text
Words or characters that appear on the screen. These include field names, screen titles, pushbuttons as well as menu names, paths, and options. Also used for cross-references to other documentation both internal (in this documentation) and external (in other locations, such as SAPNet).
62
Example text
Emphasized words or phrases in body text, titles of graphics, and tables
EXAMPLE TEXT
Names of elements in the system. These include report names, program names, transaction codes, table names, and individual key words of a programming language, when surrounded by body text, for example SELECT and INCLUDE.
Example text
Screen output. This includes file and directory names and their paths, messages, names of variables and parameters, and passages of the source text of a program.
Example text
Exact user entry. These are words and characters that you enter in the system exactly as they appear in the documentation.
Variable user entry. Pointed brackets indicate that you replace these words and characters with appropriate entries.
Unit 1: Overview and positioning of development tools.......... 1 Overview and positioning of development tools ....................2
Unit 2: Visual Composer ............................................... 19 Visual Composer ...................................................... 20
Unit 3: Using SAP NetWeaver Developer Studio ................. 39 Create a portal application........................................... 40 Debugging ............................................................. 53
Unit 4: Portal Applications and the Portal Runtime.............. 75 Portal Applications and the Portal Runtime ....................... 76
Unit 6: Portal Services and Web Services ........................ 199 Portal Services .......................................................200 Web Services.........................................................222
Unit 7: Standard Portal Services .................................... 237 User Management ...................................................238 Connector Framework...............................................266
Web Dynpro Context and Navigation .............................332 Web Dynpro Architecture ...........................................338
Unit 10: Web Dynpro Controllers.................................... 361 Model, View Controller ..............................................362 Web Dynpro Controllers.............................................398
Unit 11: The Adaptive RFC Layer ................................... 433 Remote Invocation of ABAP Functionality .......................435 The Adaptive RFC (aRFC) Model Object.........................441 Configuring SLD and JCo Connections ...........................486
Unit 12: Visualising the Java Web Dynpro through the SAP Portal....................................................................... 521 Introduction ...........................................................522 Creating a Web Dynpro iView ......................................525 Portal Eventing, Navigation and WorkProtect ....................531
Unit 13: ABAP Web Dynpro .......................................... 561 Introduction to ABAP Web Dynpro ................................562 Creating an ABAP Web Dynpro....................................569 Integrating an ABAP Web Dynpro into the Portal................575 Portal Eventing, Navigation and WorkProtect with ABAP Web Dynpro .............................................................578
Glossary................................................................... 613 Index ....................................................................... 615
Course Overview Understand the SAP tools for content development for the NetWeaver Portal
Target Audience This course is intended for the following audiences: • •
NetWeaver Portal Java Developers Development Consultants
Course Prerequisites Required Knowledge • •
J2EE Development Java WebDynpro Development
Recommended Knowledge •
NetWeaver Portal Content Administration
Course Goals This course will prepare you to: • • • •
Use Visual Composer Use SAP NetWeaver Development Studio Develop NetWeaver Portal components and services Use and Understand NetWeaver Portal APIs and services
Course Objectives After completing this course, you will be able to: • • • •
Use Visual Composer Use SAP NetWeaver Development Studio Develop NetWeaver Portal components and services Use and Understand NetWeaver Portal APIs and services
SAP Software Component Information The information in this course pertains to the following SAP Software Components and releases:
Unit 1 Overview and positioning of development tools Unit Overview Describe and differentiate approaches of content development on the SAP NetWeaver platform.
Unit Objectives After completing this unit, you will be able to: • • • • • • • •
Describe and differentiate the different approaches of content development on the SAP NetWeaver platform: SAP NetWeaver Visual Composer SAP NetWeaver Developer Studio The Portal Developer Kit for Java and .Net Know the main resources for developing EP applications: The Portal Content Studio The SAP Developer Network (SDN) The SAP Help Portal
Unit Contents Lesson: Overview and positioning of development tools .....................2 Exercise 1: Citrix Login .......................................................9 Exercise 2: System Setup.................................................. 13
Unit 1: Overview and positioning of development tools
EP120
Lesson: Overview and positioning of development tools Lesson Overview SAP provides a number of tools and resources to assist you in developing applications on the SAP NetWeaver platform. This track focuses on the tools and resources required to build NetWeaver Portal Content on the Java platform. Some of the tools and resources available to you as a developer are: • • • • •
SAP NetWeaver Visual Composer SAP NetWeaver Developer Studio SAP Enterprise Portal Developer Kit (PDK) SAP Developer Network (SDN) – http://sdn.sap.com SAP Help Portal - http://help.sap.com/nw04s
Lesson Objectives After completing this lesson, you will be able to: • • • • • • • •
Describe and differentiate the different approaches of content development on the SAP NetWeaver platform: SAP NetWeaver Visual Composer SAP NetWeaver Developer Studio The Portal Developer Kit for Java and .Net Know the main resources for developing EP applications: The Portal Content Studio The SAP Developer Network (SDN) The SAP Help Portal
Business Example Choose the appropriate technology to develop portal applications.
Lesson: Overview and positioning of development tools
Overview and positioning of development tools
Figure 1: Positioning of content approaches
For consultants, developers, and business process designers … …in organizations using the SAP NetWeaver portal ... …who need to develop, deploy, and maintain business content (iViews) for their portal… …SAP NetWeaver (though a component code-named “Visual Composer”) ... …reduces the TCO through model driven development of portal content ... … by eliminating the need to program which improves stability, maintainability and accelerates the time-to-value. Unlike integration platforms or portal solutions of other vendors… … which require massive, error-prone custom coding to bring business content into their portal... …SAP NetWeaver has a solution for the complete life-cycle of portal content that does not require programming. So what's the difference between Visual Composer and Web Dynpro? … NetWeaver provides the ability to develop portal content without programming through Visual Composer (Outside-in approach). … NetWeaver provides the user interface technology for individual applications through Web Dynpro (Inside-out approach). … Both Visual Composer and Web Dynpro are being developed as complementary technologies.
Unit 1: Overview and positioning of development tools
EP120
Figure 2: The SAP Portal Content Studio
Former SAP iViewStudio More than 6000 iViews in about 160 Business Packages categorized in 24 industries! The SAP NetWeaver Visual Composer (NW VC) •
•
•
Visual Composer is a visual modeling tool that enables sophisticated content development for the SAP NW Portal merely by dragging and dropping appropriate objects and establishing relationships between them. No programming required. Visual Composer is completely Web based. Business experts can sit next to the business users and access Visual Composer from any machine to build or customize to reflect the business needs on demand The purpose of Visual Composer is to provide a visual tool that enable customers quick and easy content development thereby – – – –
Minimize the time and effort to create content Lead to quicker go live decision Reduce Total Cost of Ownership (TCO) Increase ROI
The word Portal has been widely abused lately. Over 100 companies now say they provide a portal of some sorts, from IBM and Microsoft down. What is clear is that there is no absolute definition, but most people agree that it is a “webtop” of information targeted at audiences both within and external to a company. What is
Lesson: Overview and positioning of development tools
important is to consider all kinds of information to be made available in the portal, and to extend the idea to actually make the portal a work-place where all functions and applications are unified together.
Figure 3: The SAP NetWeaver Developer Studio
Eclipse provides an open architecture platform for developing and integrating your own tools. That is why much of the Eclipse function set is generic in nature. The main priority for Eclipse is to provide a robust and (as far as possible) universal infrastructure for developing highly integrated tools.
Unit 1: Overview and positioning of development tools
EP120
The Portal Development Kit (PDK) •
• • • • • •
The Portal Development Kit (PDK) is an extension of the SAP NetWeaver Development Studio and represents a collection of: – Development documentation – Sample applications providing reference coding – Tools for use by developers It’s shipped as Business Package available in the Portal Content Studio and requires a full installation of a SAP NetWeaver Portal Use the Software Delivery Manager (SDM) in order to install the PDK After installation assign the predefined role com.sap.pct.pdk.JavaDeveloper to your user. Contains a huge bundle of documentation and howtos All available coding samples you find here Sample Applications include: – – – – –
– – – – –
6
OBN - Object Based Navigation Navigation Connector – Application Integrator – Work with various web applications Webdynpro – Integrate WebDynpro applications into the portal HTML Business for Java (HTMLB) - Browser-independent HTML based on the SAP style sheet that maintain the corporate identity throughout the application. Internationalization - Access the required language resource files for multilingual applications. Portal Data Viewer (PDV) - Present data from different sources (XML, JDBC query, etc.) in tabular form. JCo - to connect to SAP systems. User Management – User Mapping examples Enterprise Portal Client Framework (EPCF) – Eventing framework examples
Lesson: Overview and positioning of development tools
Figure 4: The Portal Development Kit (PDK)
Once you have been assigned the Java Developers Role, you will be able to navigate to different SAP Portal development menu options. These include Tools, Getting Started, User Interface Development, Portal Development, Portal Runtime Technology, Knowledge Management and Javadocs.
Figure 5: The SAP Developer Network (SDN)
Access further information via the website can be located at http://sdn.sap.com.
Lesson: Overview and positioning of development tools
Exercise 2: System Setup Exercise Objectives After completing this exercise, you will be able to: • Create Portal users and System Setup
Business Example Task: Create Portal Users and setup system. 1.
Follow the solution to create User: EP120.E-XX Password: welcome User:EP120.D-XX Password:welcome
where XX is your group number as assigned by the instructor. The EP120.E-XX user is an end user and EP120.D-XX is a content developer. Create a System to connect to the backend ABAP system.
Unit 1: Overview and positioning of development tools
EP120
Solution 2: System Setup Task: Create Portal Users and setup system. 1.
Follow the solution to create User: EP120.E-XX Password: welcome User:EP120.D-XX Password:welcome
where XX is your group number as assigned by the instructor. The EP120.E-XX user is an end user and EP120.D-XX is a content developer. Create a System to connect to the backend ABAP system. a)
Unit 1: Overview and positioning of development tools
EP120
Figure 14:
Figure 15:
Logoff the portal and the windows desktop session. You will use the citrix common training environment for all exercises. Follow path Start → Favorites → Template URL Portal Training. Change the URL address replacing twdfxxx with your portal server. Login with user EP120.D-xx password welcome where xx is your group number.
Lesson: Overview and positioning of development tools
Lesson Summary You should now be able to: • Describe and differentiate the different approaches of content development on the SAP NetWeaver platform: • SAP NetWeaver Visual Composer • SAP NetWeaver Developer Studio • The Portal Developer Kit for Java and .Net • Know the main resources for developing EP applications: • The Portal Content Studio • The SAP Developer Network (SDN) • The SAP Help Portal
Unit Summary You should now be able to: • Describe and differentiate the different approaches of content development on the SAP NetWeaver platform: • SAP NetWeaver Visual Composer • SAP NetWeaver Developer Studio • The Portal Developer Kit for Java and .Net • Know the main resources for developing EP applications: • The Portal Content Studio • The SAP Developer Network (SDN) • The SAP Help Portal
Drag a Page from Compose Model to Design tab of workspace. Double click to enlarge to entire design area. Drag an IView from Compose Model to Design tab of workspace. Double click to enlarge to entire design area. Add a data Service by selecting Find Data. Choose System and enter search criteria. Select a Service and drag to Design tab of workspace. Right mouse click and select execute to test Service.
Drag input from Service and Add Input Form Drag output structure from Service and Add either a table view, chart view, filter or sort the data. Click Run to test
Models designed in Visual Composer can be deployed to run in one or more technology engines, including SAP HTML/B and Flex. The same model can be deployed to more than one environment, although not all components and controls are fully supported in each. Visual Composer implements a proprietary XML-based Visual Composer Language as its source code for creating the models. Only at deployment is the model actually compiled into the executable code required by the selected UI technology. The result is a model once run anywhere capability. The models that you build in Visual Composer are generated in Generic Modeling Language (GML) code. To deploy your application to a portal, the GML code must be compiled into a language supported by the portal. During compilation, warnings and possible errors may be discovered, enabling you to check the model validity. The compiled content is deployed directly to the portal, in the runtime environment that you select. In runtime, transactional content can run through HTML/B and Flex, while analytic content which may require a more animated environment may run through Flex. The models deployed by Visual Composer to the portal include runtime metadata, which is stored with the model in the PCD and exported in the business package, for delivery to customers.
Exercise 3: The SAP NetWeaver Visual Composer Exercise Objectives After completing this exercise, you will be able to: • Work with the SAP NW Visual Composer • Develop applications using the features of the SAP NW Visual Composer
Business Example Task: SAP NetWeaver Visual Composer 1.
Create a page with an iView to enable a portal user to view a list of flights for a specified airline, departure city, departure country, arrival city and arrival country. Please install the Visual composer. Use service BAPI_SFLIGHT_GETLIST. Sort the list by departure date and flight time. Generate an input form with the following. Airlineid Arrdate Arrtime Cityfrom Cityto Connectid Deptime Flightdate
Solution 3: The SAP NetWeaver Visual Composer Task: SAP NetWeaver Visual Composer 1.
Create a page with an iView to enable a portal user to view a list of flights for a specified airline, departure city, departure country, arrival city and arrival country. Please install the Visual composer. Use service BAPI_SFLIGHT_GETLIST. Sort the list by departure date and flight time. Generate an input form with the following. Airlineid Arrdate Arrtime Cityfrom Cityto Connectid Deptime Flightdate a)
Unit 3 Using SAP NetWeaver Developer Studio Unit Overview Getting started with SAP NWDS. Creating a Portal Application Project. Creating a Portal Application Component. Upload and test the component.
Unit Objectives After completing this unit, you will be able to: • • • • • •
Getting started with SAP NWDS Create a portal application project Create a simple portal application component Upload the component to the portal Test the component Debug a portal application
Unit Contents Lesson: Create a portal application ........................................... 40 Exercise 4: First Portal Component ....................................... 45 Lesson: Debugging .............................................................. 53
Lesson: Create a portal application Lesson Overview
Lesson Objectives After completing this lesson, you will be able to: • • • • •
Getting started with SAP NWDS Create a portal application project Create a simple portal application component Upload the component to the portal Test the component
Business Example Build a simple portal application.
If the buttons do not display on the toolbar, you may need to add them to your perspective. Choose Window → Customize Perspective → Other → Enterprise Portal Project Actions
Figure 44: Create New Portal Component
A Portal project usually consists of one or more components. Create a new component (application object) and specify the type of component you wish to create. You can use File → New → Other → Portal Application → Portal Application Object
There are currently 4 templates that you can choose from: AbstractPortalComponent, AbstractTestComponent, JSPDynPage, and DynPage. The templates are stored in the directory \eclipse\plugins\com.sap.ep.applicationDevelopment\templates The location refers to where the generated Java class will be located. If you select “Core”, then the class is located in the private space and is not accessible by other components. If you select “API”, then the class is located in the public space and other components may access objects and methods defined in the class. This PRT functionality simplifies sharing of components in a large, complex portal installation.
Figure 45: Create New Portal Component Example
See the “Tips and Tricks” and “What's New” from the Help Menu for information about how to use Eclipse. Code Assist and other features are configurable via the Window → Preferences menu
Figure 46: Uploading the Portal Application - Configuration
After your project has been created, you can upload it to the portal. For convenience, the portal landscape servers should be entered in the preferences dialog so that it will be easier to upload on subsequent development sessions. You need to perform this process only once.
Figure 47: Uploading the Portal Application
The Uploader defaults to the project selected in the Navigator window
The name of your project should contain a namespace that is not reserved by SAP. Although you are not technically prevented from doing so, do not use “com.sap.*” for the name of the PAR file. Once you have uploaded your project one time, you can use the key combination Ctrl-Alt-U to quickly upload it again. This shortcut is configurable via the Window → Preferences → Keys → Enterprise Portal → PAR Upload option.
Figure 48: Testing Your Application
Testing the application can be done within NWDS or the portal. It is often convenient to unit test the component before you create an iView out of it. NWDS will remember your ID/password for the duration of your session so you don't have to type it in each time you want to test. If you exit NWDS, then you will have to enter your credentials again.
Exercise 4: First Portal Component Exercise Objectives After completing this exercise, you will be able to: • Leverage the wizards and tools available in the SAP NWDS • Realize easy Portal Applications
Business Example Task: First Portal Component Write your first Portal Component which presents a simple output like “Hello World” to the portal user. Use the integrated wizards to fulfill this task.
62
1.
Start the SAP NWDS and create a new Portal Application Project named 03-FirstPortalProjectXX where XX is your student number.
2.
Click on the icon of the Portal Application Object wizard. Select Portal Component → Abstract Portal Component as template. Enter HelloWorldComponent into the name field. Enter com.sap.training.portal into the package name field. Click finish.
3.
Implement the doContent method and so that some simple HTML output like “Hello World!” is written to the response. Use the code assistant to find the right method of the response object.
4.
Create a PAR file named 03-FirstPortalProjectXX.par where XX is your student number and deploy this using the Create/Export PAR File wizard. XX is your group number
5.
Test the application by executing it from within NWDS.
Solution 4: First Portal Component Task: First Portal Component Write your first Portal Component which presents a simple output like “Hello World” to the portal user. Use the integrated wizards to fulfill this task. 1.
Start the SAP NWDS and create a new Portal Application Project named 03-FirstPortalProjectXX where XX is your student number. a)
(Detailed Solution below) Start the SAP NWDS and create a new Portal Application Project named 03-FirstPortalProjectXX.
2.
Click on the icon of the Portal Application Object wizard. Select Portal Component → Abstract Portal Component as template. Enter HelloWorldComponent into the name field. Enter com.sap.training.portal into the package name field. Click finish. a)
3.
Implement the doContent method and so that some simple HTML output like “Hello World!” is written to the response. Use the code assistant to find the right method of the response object. a)
4.
The class HelloWorldComponent is opened automatically by the wizard. You also find it in 03-FirstPortalProjectXX → src.core → com → sap → training → portal. Enter “response” Into the doContent{} function. The code completion wizard offers all available methods and fields. Select write(String arg 0) – void and enter “Hello World!” as argument.
Create a PAR file named 03-FirstPortalProjectXX.par where XX is your student number and deploy this using the Create/Export PAR File wizard. XX is your group number a)
5.
Create a new AbstractPortalComponent subclass named com.sap.training.portal.HelloWorldComponent by means of the Portal Application Objects wizard.
Click on the Icon Create/Export PAR File. Verify the name of the PAR and mark “Deploy PAR”. In the section Servers verify the connectivity and enter the valid password. Click on Finish.
Test the application by executing it from within NWDS. a)
Double click on 03-FirstPortalProjectXX → dist → PORTAL-INF → portalapp.xml. The portalapp.xml editor opens. Click on the button Run next to the link HelloWorldComponent. The Application is executed in a new browser window. Continued on next page
Lesson Summary You should now be able to: • Getting started with SAP NWDS • Create a portal application project • Create a simple portal application component • Upload the component to the portal • Test the component
Lesson Objectives After completing this lesson, you will be able to: •
Debug a portal application
Business Example
Debugging Preparation for Debugging • • • •
Stop the Portal if running Launch the Config tool of J2EE engine Start SAP NetWeaver Developer Studio and open your project for debugging Make sure that the latest version of the debuggable code is deployed in the debug portal
You can make your programs easier to debug by following these guidelines: •
•
62
Where possible, do not put multiple statements on a single line, because some debugger features operate on a line basis. For example, you cannot step over or set line breakpoints on more than one statement on the same line. Attach source code to JAR / PAR files if you have the source code.
First step of the debugging setup is to start the config tool of the J2EE engine. The tool is located in the directory \JC00\j2ee\configtool\configtool.bat Switch to the current instance and goto the debug tab. Set Enable debug mode checked, starts the VM of J2EE in debug mode. Set a valid debug port, default port is 50021. Save the settings and restart the J2EE Engine
Add the host name, port, and alias of each EP6 instance in which you wish to connect to NetWeaver Developer Stuido. A valid user ID and password must also be supplied!
Goto Debug → Remote Java Application and create a new setting for your current Portal Application project Insert the portals DNS or IP Address and the debug port specified in the config tool, default port is 50021. If the portal runs on the local machine you can enter localhost instead of IP adress or DNS name. Important: Make sure that your portal application is already deployed in the portal
The export function allows an option to include the source code of the project in the PAR file (located in: /PORTAL-INF/srclib.api/parname.src.jar and /PORTAL-INF/srclib.core/parname.src.jar) and to deploy your application to your local Portal.
The Breakpoints view lists all the breakpoints you have set in the workbench projects. You can double-click a breakpoint to display its location in the editor. In this view, you can also enable or disable breakpoints, delete them, or add new ones. This view also lists Java exception breakpoints, which suspend execution at the point where the exception is thrown. You can add or remove exceptions.
To enable the breakpoint using the Breakpoints View • • •
62
Locate the breakpoint in the marker bar of an editor Open the breakpoint's context menu and select Enable Breakpoint. The breakpoint image will change back to a blue circle.
Locate the breakpoint in the marker bar of an editor Open the breakpoint's context menu and select Disable Breakpoint. The breakpoint image will change to a white circle.
Open the class in the Outline view, and select the method where you want to add a method breakpoint. From the method's pop-up menu, select Add/Remove Method Breakpoint. A breakpoint appears in the Breakpoints view. If source exists for the class, then a breakpoint also appears in the marker bar in the file's editor for the method that was selected. While the breakpoint is enabled, thread execution suspends when the method is entered, before any line in the method is executed.
Select the breakpoint to which a hit count is to be added. From the breakpoint's pop-up menu, select Hit Count. In the Enter the new hit count for the breakpoint field, type the number of times you want to hit the breakpoint before suspending execution.
When the breakpoint is hit for the nth time, the thread that hit the breakpoint suspends. The breakpoint is disabled until either it is re-enabled or its hit count is changed.
Choose Add Java Exception Breakpoint from the Breakpoints view or the workbench Run menu. A dialog listing all of the available exceptions is shown. Either type the name of the exception you want to catch or select it from the list. At the bottom of the page, use the check boxes to specify how you want execution to suspend at locations where the exception is thrown. • •
62
Select Caught if you want execution to suspend at locations where the exception is thrown but caught. Select Uncaught if you want execution to suspend at locations where the exception is uncaught.
When stack frame is selected, you can see the visible variables in that stack frame in the Variables view. The Variables view shows the value of primitive types. Complex variables can be examined by expanding them to show their members. To launch the Variables View: • •
68
Choose Window → Show View → Other Select Debug → Variables View
Force the portal to execute your deployed coding, e.g. an iView can be launched with PortalAnywhere.Go. The VM stops at the specified break point. The current values of the member variables can be tracked in the variables window of SAP NetWeaver Developer Studio.
Debugging with the variables view may be useful in situations where you are not receiving a runtime error but the component is not functioning correctly.
Unit Summary You should now be able to: • Getting started with SAP NWDS • Create a portal application project • Create a simple portal application component • Upload the component to the portal • Test the component • Debug a portal application
Unit 4 Portal Applications and the Portal Runtime Unit Overview Review the Portal Runtime Guide. Describe a Portal application. Describe the PAR file format. Describe the properties of the deployment descriptor file (portalapp.xml). Describe Portal Components and Services.
Unit Objectives After completing this unit, you will be able to: • • • • • •
Download and review the Portal Runtime Guide Describe what makes up a Portal Application Describe the PAR file format and how it relates to deployment of a portal application Describe the various properties of the deployment descriptor (portalapp.xml) Describe Portal Components Describe Portal Services
Unit Contents Lesson: Portal Applications and the Portal Runtime ........................ 76 Exercise 5: Portal Applications and the Portal Runtime................ 87
Unit 4: Portal Applications and the Portal Runtime
EP120
Lesson: Portal Applications and the Portal Runtime Lesson Overview
Lesson Objectives After completing this lesson, you will be able to: • • • • • •
Download and review the Portal Runtime Guide Describe what makes up a Portal Application Describe the PAR file format and how it relates to deployment of a portal application Describe the various properties of the deployment descriptor (portalapp.xml) Describe Portal Components Describe Portal Services
Business Example
Portal Applications and the Portal Runtime The Portal Runtime (PRT) • • • •
The Portal Runtime (PRT) is one basic part of the portal environment integrated into the Web AS Provides a runtime and its corresponding services Provides a development environment Defines and manages the objects that make up a portal environment
Note: The architecture and components of the PRT are described in the PRT Guide. You will find a copy of the PRT Guide in the PDK Documentation under: Java Developer → Getting Started → Portal Runtime Guide You can also download a copy of the current PRT Guide from SDN using Portal Runtime Technology Release 6 as keywords in the SDN search field. The Portal Runtime is one basic part of the SAP Enterprise Portal Environment integrated in the SAP J2EE environment.
Lesson: Portal Applications and the Portal Runtime
The Portal Runtime Technology provides a Java based framework to define, build, and execute Applications in a Portal Environment by allowing the aggregation and the display of various contents such as rich text, xml, videos etc… The Portal Runtime Technology provides a runtime and its corresponding services as well as a development environment for Portal applications. The motivation behind the design and the technical implementation of the Portal Runtime are the following: Area of concern: The goal of the PRT is very well identified and restricts itself to the life cycle of portal applications. Open and Extensible: Many of the components of the PRT can be changed or customized to be adapted to the environment in which the PRT is executed. So the model proposed by the PRT can be extended to support, for example, different user interface models or different programming models. So, the Portal Runtime clearly positions itself as one of the key block used to build and execute any kind of Portal. The Portal Runtime defines and manages two kinds of objects that define a Portal Application. They are: Portal Components. From a user point of view, a component that can be displayed into a portal page. From an application development perspective, a plug able component designed to be executed into a Portal environment. Portal Services. A Component offering a globally accessible function in the Portal. The portal runtime development model offers a way to implement a clear separation between a Service API and its implementation. Portal Applications •
Portal Applications ... – – –
–
62
.. are bundles of Portal Components and Portal Services. .. are packaged as PAR (Portal Application ARchive) files – format that the Portal Runtime accepts for deployment of Portal Applications. A PAR file is an archive file/standard JAR file (ZIP format) containing a Portal Application with a XML-based Portal Application Deployment Descriptor (DD) called portalapp.xml. DD describes the portal application itself and provides information required at runtime
Unit 4: Portal Applications and the Portal Runtime
EP120
Portal Applications contain two types of resources: •
Web Resources
•
– Accessible via http(s) requests to a web server – All files NOT under WEB-INF Non-Web Resources – –
Not accessible via an http(s) request All files under WEB-INF
A Portal Application can contain: • • •
several Portal Components and several Portal Services. Using several sections in DD these components and services are defined. only 1 Portal Components only 1 Portal Services
Each Portal Application can be accessed by . Everything can be packaged in a PAR file but depending on the purpose of the objects different properties may be needed to be set.
Startup: If set to “true”, the application as a whole will be "started" (initialized) on startup of the server. In particular this means that it will be locally deployed. Releasable: Because PRT allows hot deployment, all applications are releasable and the application instance can be dropped at any time by the system. Nevertheless some critical applications may want to avoid the release of their instance when the system runs low in memory. They should then set this property to false.
This is an executable part of the Portal Application. It can be described as a Java Code or JSP defined by properties and executed in a particular mode. Three different flavours (types):
•
– iView Code (AbstractPortalComponent, …) – System – Layout The distinction is made by the property “ComponentType” – – –
iView: “JSPNative”, “none” or “servlet” System: com.sapportals.portal.system Layout: com.sapportals.portal.layout
Flavours, System and Layout are just a matter of configuration. There is comprehensive documentation to be found in the online help (http://help.sap.com/nw04). In the further sections we refer to the flavor “iView” when speaking about Portal Components.
Lesson: Portal Applications and the Portal Runtime
Figure 82: Portal Applications - Components
Portal Component Config The component config is a set of properties which configures the Portal Component (class name, etc.). Portal Component Profile The component profile is a set of properties (name-value pairs) representing the dynamic part of the Portal Component that could be customized/personalized to change the behavior of a Portal Application.
AuthRequirement: (new in EP6.0) A list of roles can be specified. This protection is important because the component can be launched directly (without using an iView). Cause the ACL‘s are set for iViews only, this was a protection while direct launching is possible.
Lesson: Portal Applications and the Portal Runtime
Figure 86: iView Properties and Delta Links
The Portal Component shown above is an executable component (code) which is (up-)loaded to the portal as part of an archive. It lays at the beginning of the inheritance chain. The component-profile section contains properties that make up the profile of the Portal Component as accessible from the com.sapportals.portal.prt.component.IPortalComponentProfile interface at runtime. The profile is usually abstracted in a personalizable entity, the iView. The values of properties in this section define the default values. By administrative modification or personalization, these values may be modified. Explain the inheritance using Delta Links
Unit 4: Portal Applications and the Portal Runtime
EP120
Portal Applications – Services •
Portal Services bring commonly used functionality into the Portal – – –
•
Portal Services are a way to provide JAVA based functionality to Portal Components and other Portal Service By the handling of Portal Applications, Portal Services may enjoy separation of API and implementation Portal Services may now be accessed from outside of the Portal Framework using SOAP/Web Services Protocol
In the non-trivial case, a service provides an interface based API and an implementation. –
•
The implementatoin is non-public and will not be seen by nor interfer with using applications. – The service interface relates the service API and its implementation by offering access to implementations of API interfaces through factories. – The API should not rely on any other non-standard API. A portal service can be transfered into a Web Service.
Figure 87: Portal Applications - Services
Attention please here again the separation between “config” and “profile” definition. In the config section only two important properties are set. (see next slide)
Lesson: Portal Applications and the Portal Runtime
Figure 88: Portal Applications - Service Configuration
Portal Applications – Service Profile • • •
•
Contains properties that make up the profile of the Portal Service. Properties are accessible via the interfacecom.sapportals.portal.prt.service.IServiceProfile. In contrast to the service config, the service profile properties may be modified by administrative environment and is available at next start of the service. There are no predefined service profile properties.
Unit 4: Portal Applications and the Portal Runtime
EP120
Sharing References declare API extensions (with 6.0 policy). Private Sharing References declare APIs used by the application's private code Service-config defines essential settings for the service. The Class Loading Policy determines how definitions of this application are exported and definitions from other applications are imported. "transitive" is the default.
Lesson: Portal Applications and the Portal Runtime
Exercise 5: Portal Applications and the Portal Runtime Exercise Objectives After completing this exercise, you will be able to: • Explain the differences between Portal Applications, Portal Components and Portal Services • What are the essential parts of a PAR file? • What is the Deployment Descriptor?
Business Example Task: Portal Terminology
62
1.
Explain the differences between Portal Applications, Portal Components and Portal Services.
Unit 4: Portal Applications and the Portal Runtime
EP120
Solution 5: Portal Applications and the Portal Runtime Task: Portal Terminology 1.
Explain the differences between Portal Applications, Portal Components and Portal Services. a)
The Portal Runtime defines and manages two kinds of objects that define a Portal Application: the Portal Components and the Portal Services.Thus a Portal Application compromises Portal Components and Portal Services. From a user point of view, a portal component can be displayed into a portal page. From an application development perspective, the portal component is a plugable component that is designed to be executed into a Portal environment. A portal service offers functionality that is globally accessible for components in the Java iView Runtime. The component accesses the service via an API.
2.
What are the essential parts of a PAR file? a)
The PAR file is a zip compatible format which includes at least the deployment descriptor portalapp.xml and the according implementation classes as compiled classes or as jar-libs.
Lesson: Portal Applications and the Portal Runtime
3.
What is the Deployment Descriptor? a)
The Deployment Descriptor defines: • • •
How a portal component is handled by the platform Which portal services and other portal components are accessed Which parameters can be personalized by the user
It is defined in the file portalapp.xml and noted as an XML definition. The root element is the application element. The application element can have an attribute alias, containing a comma-separated list of aliases on the portal application. The portal application name is defined by the name of the portal archive (par file). The attribute alias defines an additional name for the portal application. Attention: It is not recommended to use the aliases because of name clashes. This feature is meant to be used for backward compatibility reasons. Three child elements are allowed in the application element: • • •
62
application-config: the properties defined in this section affect the portal application as a whole. components: all portal components of a portal application are declared in this element services: all portal services of a portal application are declared in this element
Unit 4: Portal Applications and the Portal Runtime
EP120
Lesson Summary You should now be able to: • Download and review the Portal Runtime Guide • Describe what makes up a Portal Application • Describe the PAR file format and how it relates to deployment of a portal application • Describe the various properties of the deployment descriptor (portalapp.xml) • Describe Portal Components • Describe Portal Services
Unit Summary You should now be able to: • Download and review the Portal Runtime Guide • Describe what makes up a Portal Application • Describe the PAR file format and how it relates to deployment of a portal application • Describe the various properties of the deployment descriptor (portalapp.xml) • Describe Portal Components • Describe Portal Services
Unit 5 Portal Components Unit Overview Use Abstract Portal components, Dynpage components and JSP Dynpage components. Leverage personalization features. Leverage internationalization features. Describe the features of HTMLB and use HTMLB in Portal components. Use JSP pages. Understand Model-View-Controller (MVC) approach to developing Portal applications.
Unit Objectives After completing this unit, you will be able to: • • • • • • • •
Understand and build abstract portal components Discuss the nature of the security zone Discuss how a Portal application uses the security zone features Discuss permissions and security zones Allow end user personalization of portal applications Write Portal Applications that are language independent and handle complex phrases in a language neutral fashion. Build Portal applications using HTMLB controls Use the Model-View-Controller (MVC) approach when developing your Portal Applications.
Lesson Objectives After completing this lesson, you will be able to: •
Understand and build abstract portal components
Business Example
Abstract Portal Components
Figure 90: The IPortalComponent Interface
possible causes for calling the destroy() method are 1. Portal is terminating or 2. The Portal runtime needs to free up some memory For example when a new version of the application is being uploaded. After the call to destroy(), the garbage collector collects the component.
-> Show documenation in Java Doc of the PDK !! doContent - Generates the content of the component. doEdit - Provides personalization dialog. doHandleEditData Default handler upon personalization according to the convention, which is that a personalization dialog presentation should use profile names as parameter names and it should contain a field “save” if the parameter set should be saved into the profile. doBeforeContent Handles the BEFORE_CONTENT event. doAfterContent Handles the AFTER_CONTENT event. doRequestEvent - Handles a client raised event that is not handled in a specific event handler. Portal Components that extend the AbstractPortalComponent class can overwrite and implement methods for content creation and request processing.
Lesson: Security Zones Lesson Overview In this lesson you will learn about security zones and how the portal administrator can use them to control access to portal services and components.
Lesson Objectives After completing this lesson, you will be able to: • • •
Discuss the nature of the security zone Discuss how a Portal application uses the security zone features Discuss permissions and security zones
Business Example As a portal content developer, you have been tasked with developing a portal application to display highly sensitive information. To ensure that only those users authorized can access this application and its related portal components and portal services, this application may not be accessible directly from outside the portal. To run this application on the portal platform, you need to secure it under a security zone.
What is a Security Zone? Security zones are used to prevent unauthorized users from accessing iViews, portal components and portal services through a direct URL used outside of the portal environment. When activated, security zones enable system administrators to control which portal components and portal services a portal user can launch. Security zones provide a means of implementing an optional, secondary layer of security to portal components and services which are accessed by a URL. URL access to portal components and services can occur directly or indirectly via an iView, and is controlled by means of progressive safety levels and permissions, which are assigned by system administrators to authorized users in the permission editor.
A security zone specifies the vendor ID, the security area, and safety level for each portal component and portal service (Web services accessed through the SOAP protocol). Access to portal components and services by authorized users is controlled by assigning portal user permissions to the hierarchical structure of vendor ID, the security area, and progressive safety levels in the portal’s security zones. Content developers assign portal components and services to a security zone during the development phase. The security zone is defined in a portal application’s descriptor XML file. Typically, it is the content or system administrator’s responsibility to provide the appropriate security zone assignment to the content developer.
After a portal application is deployed in a portal, an administrator with access to the central permission editor must assign authorized users, groups, or roles to the security zone to which the portal component or service belongs. Security zones are displayed in the Portal Catalog in a hierarchical structure. A portal component or service can belong to only one security zone; however portal components and services may share the same safety level. This allows the administrator to assign permissions to a safety level, instead of assigning them directly to each portal component or service, thus taking advantage of the permission inheritance mechanism, which passes the permissions from the safety level to any portal component or service located in it. You can control access to portal components through direct URLs or through iViews. Access controlled through direct URLs Generally, portal components are accessed through an iView. However, special cases – such as the portal logon component – require direct URL access to portal applications without an iView. A user is allowed direct access by URL at runtime under the following conditions: • •
102
The portal component or service declares its security zone. The user (or group or role) has been assigned end-user permissions in the permission editor to the security zone defined by the portal component.
Access controlled through iViews When an iView is launched by a user at runtime, the Portal Runtime (PRT) initially determines if the user is assigned end-user permission to the role object containing the iView. If authorized, the user can view the iView’s content. Security zones offer an extra, but optional, layer of code-level security to iViews accessed through standard role-based assignment. When this functionality is activated, the PRT also checks if the user has been assigned end-user permission to the iView’s portal component in its designated security zone. Note that this check is performed after the end-user permission to the iView has been approved. The user must pass both checks to view the iView’s content. This second level of security for iViews is activated or deactivated by setting a Java VM (virtual machine) parameter using the J2EE Config Tool (for both server and instance or server only). By default, this functionality is disabled • •
To activate it, set the Dcom.sap.nw.sz parameter to true. To deactivate it, set the Dcom.sap.nw.sz parameter to false. Hint: This parameter also prevents unauthorized users from accessing iViews through a direct URL used outside of the portal environment. In future release, this parameter may be deprecated; the functionality it provides will remain and operate permanently.
How to Get a Portal Application into a Security Zone When the portal application archive is loaded in the system, zones are created if they do not exist. The entries that correspond to the portal objects are then created in the zone. When a portal object (portal component or portal service) is accessed, the portal runtime checks if the current user has the permissions required to access the zone to which the portal object belongs.
Figure 97: Example of Security Zone Entry in the Deployment Descriptor
You can specify security zones in the portal application descriptor file, portalapp.xml, in the following ways: • •
Computed (preferred method) Fully specified
In the computed method, the security zone of a component is defined by creating the following properties in the portalapp.xml file in the application PAR file: •
•
VendorID and SecurityArea: These properties are defined in the application-config section, and apply to all the components and services in the PAR. SafetyLevel: This property is defined for each component and service
When the portal application is deployed in the portal, the full security zone is then automatically generated by the PRT using the above properties and the names of the components and services: • •
In the fully specified method, the security zone is defined in the portal application descriptor with a single property, SecurityZone. The syntax of this property can be any slash-separated (/) string to define the security zone hierarchy; however, either of the following formats is recommended: • •
Rules for Creating the Zones During the deployment of the portal application in the portal, the following rules apply to creating the zones associated to the portal objects: •
•
104
If the portal application specifies a SecurityZone property (fully specified method), its value will take precedence even if the portal application also specifies the VendorID and SafetyLevel properties (computed method). If no security zone is specified, the PRT computes a zone for each portal objects using the properties Vendor, SecurityArea and SafetyLevel. Any component that does not have a proper vendor, security area or safety level property are listed under an UndefinedVendor, UndefinedSecurityArea or UndefinedSafetyLevel folder in the appropriate location in the Security Zones folder in the Portal Catalog. This enables administrators to easily locate components whose PAR has been deployed without the proper security zone properties.
How Are Permissions and Security Zones Related Security zones extend to components and services the permission model implemented in the PRT, which controls access to all portal objects: • •
Portal components – either accessed from the prtroot URL or from the portal application repository. Portal services – when accessed as Web services by the SOAP connection.
In the portal, security zones are located in the root Security Zones folder within the Portal Catalog and are represented as a set of portal components and portal services, to which Access Control Lists (ACL) are attached and checked at runtime when the portal object belonging to a zone is accessed. During the development phase, the security zone allows you to abstract the security level that a portal component or a portal service will require at runtime. You do not need to know the name of the roles or the name of the users that will be present in the portal environment in which the portal application will be installed. The zone defines a logical catalog containing a set of portal objects. You have to associate the principal security of the system to that zone by creating ACLs. The ACLs define the permission required for accessing a specific zone. A safety level for a security zone enables you to group objects that belong to a zone into different categories. Within that zone, you can define different safety levels. Each of these safety levels can then be assigned to different permissions. This helps you to organize and classify objects that belong to a certain zone. The portal defines the following standard safety levels for initial portal content to which out-of-the-box groups and roles are assigned permissions (note that the description of each safety level is based on the end-user permission setting only, regardless of the administrator permission setting):
Anonymous users are permitted to access portal components defined in the security zone.
Low Safety
A user must be at least an authenticated portal user to access portal components defined in the security zone.
Medium Safety
A user must be assigned to a particular portal role that is authorized to access portal components defined in the security zone.
High Safety
A user must be assigned to a portal role with higher administrative rights that is authorized to access portal components defined in the security zone.
For information on which initial groups and roles are assigned to the standard security zones shipped with the portal, see Default Permissions section below. We highly recommend that customers use this convention and the standard safety levels when deploying custom-made applications in the portal. Hint: Problems related to accessing the portal and its content are often attributed to insufficient permissions in security zones. When troubleshooting access-related issues in the portal, it is recommended to also check the security zone permissions. Default Permissions for Maximum Security The portal comes with a minimum set of permissions assigned to its initial content. These default permissions are designed to provide maximum security for a freshly installed portal. The default permissions settings are sufficient to enable users assigned to the super administrator role to work and gain access to all initial content. They also enable the remaining standard administration roles (content, system, and user) to access tools specific to these roles, but not to initial content objects. For example, a content administrator has access to the Portal Content Studio, but is not able to gain access to any content objects, such as iViews, pages, and roles — the Portal Catalog in the Portal Content Studio is empty. This topic describes the default permissions assigned to the initial content of the portal.
Caution: The initial permissions described in this topic are only valid for a fresh and full installation of the portal. When upgrading a portal, the initial permissions script in the portal is not executed. This prevents the permissions in an existing portal from being overwritten. If you are upgrading your portal, you will however need to assign permission to the standard portal components and services shipped with the portal. These components and services reside in the Security Zones folder. It is recommended to use as a basis the initial permissions set for security zones in a fresh installation (as described in the Permissions in Security Zones section above). On one hand, iViews automatically inherit their permissions from the role to which they are used. On the other hand, portal components and services inherit their permissions from the security zone or safety level to which they are assigned. Most generic portal applications intended for standard users in an organization should apply to either the no safety or low safety levels, and no additional role-specific permissions need to be assigned to their security zones. The reason for this is that the Everyone and Authenticated Users groups are by default assigned end-user permission to the no safety and low safety levels, respectively, and thereby permit all anonymous and authorized user activity already. The medium safety and high safety levels are typically reserved for sensitive applications, which require permission assignments that are targeted to specific users, groups, or roles. Note: •
Security zone functionality is only operational when the PRT security mode is set to production mode. The Located at \J2eeRoot\cluster\server0\apps\sap.com\irj\servlet_jsp\irj\root\WEBINF\portal\system\properties\prtCentral.properties The portal.runtime.security.mode=production setting must be set to "production", which does not allow portal components to start directly. Possible values are "development" or "production" or "test".
•
To prevent a complete lockout situation that prevents access to the portal by all users, including super users, you must make sure that all portal groups representing anonymous users (for example, the Everyone group) have end-user permission enabled for the safety level that permits anonymous access to portal components and services accessed by a URL (for example, the no safety level). Typically, you should grant end-user permission to the Everyone group in the following standard security zones that are shipped with the portal: – –
Exercise 6: Security Zones Exercise Objectives After completing this exercise, you will be able to: • Add a security zone to your portal application
Business Example Prevent unauthorized users from running portal applications from the command line.
Task: Add a security zone to your portal application to stop unauthorized access.
62
1.
Open portal component 05-PersonalizationXX or the template solution. Open the portalapp.xml file and add a vendor of com.customer and a SecurityArea of portal to the application configuration section.
2.
Add a safety level of low_safety to the component configuration section to the welcome component.
3.
Deploy the component. Close all browsers down and try running the component from portalapp.xml file of NWDS. Login into the portal as user EP120.E-XX and re-test the application. Login into the portal as user EP120.D-XX and re-test the application. What are the results in each case and why?
Solution 6: Security Zones Task: Add a security zone to your portal application to stop unauthorized access. 1.
Open portal component 05-PersonalizationXX or the template solution. Open the portalapp.xml file and add a vendor of com.customer and a SecurityArea of portal to the application configuration section. a)
In the application section of the portalapp.xml file add a standard configuration property of Vendor: com.customer and SecurityArea: portal.
Add a safety level of low_safety to the component configuration section to the welcome component. a)
In the component Welcome add a standard configuration property of low_safety.
Figure 99:
3.
Deploy the component. Close all browsers down and try running the component from portalapp.xml file of NWDS. Login into the portal as user EP120.E-XX and re-test the application. Login into the portal as user EP120.D-XX and re-test the application. What are the results in each case and why? a)
Deploy the component. Close all browsers down and try running the component from portalapp.xml file of NWDS. You should receive an error. Login into the portal as user EP120.E-xx and password of welcome. Run the component again and this time you will receive an security error. Login to the portal as user EP120.D-XX. Run the application one more time. This should now be successful and shows you must be authorized to run a portal component from the command line. User EP120.D-xx is a super administrator and is therefore able to run all component.
Lesson Summary You should now be able to: • Discuss the nature of the security zone • Discuss how a Portal application uses the security zone features • Discuss permissions and security zones
Modifying and storing per user data of a Portal Component Displaying and handling of personalization dialogs that offer modification of iView properties
Hint: The personalization dialog can be tested directly before creating an iview. Run the portal application from the portalapp.xml file. When the browser is open append ?prtmode=edit to the end of the URL. For example http://twdf0xxx.wdf.sap.corp:50000/irj/servlet/prt/portal/prtroot/05Personalization.Welcome?prtmode=edit
Exercise 7: Personalization Exercise Objectives After completing this exercise, you will be able to: • Leverage the component profile to implement personalization for your Portal Component
Business Example Task: Personalization Enhance your Portal Component by enabling the user to change your properties by a personalization feature. 1. 1. Create a new Portal Application Project within the EP perspective. Call the project 05-PersonalizationXX. 2. Add a new Portal Component named Welcome. 3. Navigate to the Outline box, bottom left, – right click on Welcome and select Add property in and component profile. Ensure that you have the PortalApp.xml displayed in the editor 4. Create a new property called colorName and assign an initial value of blue. 5. Create a new property called petsName and assign an initial value of your choice e.g. Flower 6. Create a new property called location and assign an initial value of your choice e.g. Paris. 7. Add a sub-property to colorName and assign a name of type with value select e.g. select[Red,Orange,Green,Blue,Yellow,Purple,Violet] 8. Add a sub-property to colorName and assign a name plainDescription and value of Favourite Colour or Favorite Color depending on which side of the Atlantic you reside. 9. Add a sub-property to colorName and assign a name personalization and value of dialog. 10. Add a sub-property to location and assign a name plainDescription and value of Country of Residence. Continued on next page
11. Add a sub-property to location and assign a name personalization and value of dialog. 12. Add a sub-property to petsName and assign a name plainDescription and value of Pet’s Name. 13. Add a sub-property to petsName and assign a name personalization and value of dialog. 14. Check the Portalapp.xml file to check all the added entries. 15. Within the doContent method of your AbstractPortalComponent please add the following code:IPortalComponentProfile profile = request.getComponentContext().getProfile(); String colorName = profile.getProperty("colorName"); String petsName = profile.getProperty("petsName"); String location = profile.getProperty("location"); response.write("
"); response.write( "
Hello.
Your favorite color is
" + colorName + "
"); response.write( "
Your pet's name is
" + petsName + "
"); response.write( "
You live in
" + location + "
"); response.write("
");
16. Create an iView to test the working of your Personalization.
Solution 7: Personalization Task: Personalization Enhance your Portal Component by enabling the user to change your properties by a personalization feature. 1. 1. Create a new Portal Application Project within the EP perspective. Call the project 05-PersonalizationXX. 2. Add a new Portal Component named Welcome. 3. Navigate to the Outline box, bottom left, – right click on Welcome and select Add property in and component profile. Ensure that you have the PortalApp.xml displayed in the editor 4. Create a new property called colorName and assign an initial value of blue. 5. Create a new property called petsName and assign an initial value of your choice e.g. Flower 6. Create a new property called location and assign an initial value of your choice e.g. Paris. 7. Add a sub-property to colorName and assign a name of type with value select e.g. select[Red,Orange,Green,Blue,Yellow,Purple,Violet] 8. Add a sub-property to colorName and assign a name plainDescription and value of Favourite Colour or Favorite Color depending on which side of the Atlantic you reside. 9. Add a sub-property to colorName and assign a name personalization and value of dialog. 10. Add a sub-property to location and assign a name plainDescription and value of Country of Residence. 11. Add a sub-property to location and assign a name personalization and value of dialog. 12. Add a sub-property to petsName and assign a name plainDescription and value of Pet’s Name. 13. Add a sub-property to petsName and assign a name personalization and value of dialog.
14. Check the Portalapp.xml file to check all the added entries. 15. Within the doContent method of your AbstractPortalComponent please add the following code:IPortalComponentProfile profile = request.getComponentContext().getProfile(); String colorName = profile.getProperty("colorName"); String petsName = profile.getProperty("petsName"); String location = profile.getProperty("location"); response.write("
"); response.write( "
Hello.
Your favorite color is
" + colorName + "
"); response.write( "
Your pet's name is
" + petsName + "
"); response.write( "
You live in
" + location + "
"); response.write("
");
16. Create an iView to test the working of your Personalization. a)
Exercise 8: Internationalization Exercise Objectives After completing this exercise, you will be able to: • Support multiple languages in your Portal Application
Business Example Task: Internationalization Support multiple locales in your personalized Portal Component. Extend the previous exercise and translate all labels on the screen. “Hello. Your favorite color is” → “Hallo. Ihre Lieblingsfarbe ist” “Your pet's name is” → “Der Name Ihres Haustiers ist” “You live in” → “Sie wohnen in” 1.
Solution 8: Internationalization Task: Internationalization Support multiple locales in your personalized Portal Component. Extend the previous exercise and translate all labels on the screen. “Hello. Your favorite color is” → “Hallo. Ihre Lieblingsfarbe ist” “Your pet's name is” → “Der Name Ihres Haustiers ist” “You live in” → “Sie wohnen in” 1. 1.
Open project 05-PersonalizationXX.
2.
Add the property ResourceBundleName to the component-config of welcome. Set the property to myBundle.
3.
Add the following 3 files to the directory 05-PersonalizationXX → dist → PORTAL-INF localization: •
myBundle.properties containing favorite_color= Hello. Your favorite color is pet_name= Your pet's name is home= You live in
•
myBundle_de.propeties containing favorite_color= Hallo. Ihre Lieblingsfarbe ist pet_name= Der Name Ihres Haustiers ist home= Sie wohnen in
•
myBundle_en.properties containing favorite_color= Hello. Your favorite color is pet_name= Your pet's name is home= You live in
4.
Add a new component-profile property ForcedRequestLanguage with value en to easily test component through personalization option in iview.
5.
Access the string within the doContent method of the component HelloWorldComponent. Change all literals to use the translatable language tokens.
6.
Deploy and test your component Continued on next page
Lesson Summary You should now be able to: • Write Portal Applications that are language independent and handle complex phrases in a language neutral fashion.
Lesson Objectives After completing this lesson, you will be able to: •
Build Portal applications using HTMLB controls
Business Example Build portal applications using HTMLB controls.
HTMLB HTMLB – What it is • • •
HTMLB (HTML-Business for Java) provides a full set of easy-to-use Web controls HTMLB allows a design-oriented page layout It is designed to overcome typical servlet problems, such as: – –
•
Visualization and business logic are not separate Content management consumes a lot of qualified manpower. Skills in HTML, CSS, JavaScript etc. are essential – Development has to take care of different web clients and -versions – Maintaining the corporate identity through out the whole application is hard to achieve – Namespace conflicts with form elements Also provides the technological infrastructure for easy customer branding
Although development skills are essential, there is more room for flexibility while developing the application
Figure 171: HTMLB - Creating Pages in Abstract Portal Components using the class library
Figure 172: HTMLB - DynPage Approach
doInitialization: Called when the application is started. The call is made when the page is directly called per URI without parameters and no event occurred. Usually this method is used to initialize data and to set up models. Be aware of the fact that the doInitialization event is also caused when another portal component on the same page sends an event doProcessAfterInput: Called when the web client sends the form to the web server. Except on doInitialization the call is performed every time an event occurs doProcessBeforeOutput: Called before the form is sent to the web client. The call is performed every time even on doInitialization
Please notice that the highlighted code in the above example are the areas that the developer has added. The line myButton.setOnClick(click); will invoke the method onClick when the user clicks this button.
Exercise 9: HTMLB Exercise Objectives After completing this exercise, you will be able to: • To write a portal Application based on the DynPage approach. • Use HTMLB eventing. • Use a complex HTMLB element (dateNavigator).
Business Example Task: Use the DynPage approach to implement an easy user interface. In this exercise we implement an HTMLB dateNavigator element. 1. 1. 2. 3.
Create new Portal Application Project named 05-Basic1HTMLBXX where XX is your student number. Create a new DynPage component with the Portal Component Wizard. Name this Basic1Dynpage. Please add the following code into the doProcessingBeforeOutput method to add a new input field.myForm.addText("This is your Basic HTMLB Application
");
InputField inputField = new InputField("myInputField"); inputField.setValue("This is your inputfield text"); myForm.addComponent(inputField);
Solution 9: HTMLB Task: Use the DynPage approach to implement an easy user interface. In this exercise we implement an HTMLB dateNavigator element. 1. 1. 2. 3.
Create new Portal Application Project named 05-Basic1HTMLBXX where XX is your student number. Create a new DynPage component with the Portal Component Wizard. Name this Basic1Dynpage. Please add the following code into the doProcessingBeforeOutput method to add a new input field.myForm.addText("This is your Basic HTMLB Application
");
InputField inputField = new InputField("myInputField"); inputField.setValue("This is your inputfield text"); myForm.addComponent(inputField);
4.
Perform a quick par upload and test.
5.
Add the dateNavigator code into the doProcessBeforeOutput method:IPortalComponentRequest request
Lesson Objectives After completing this lesson, you will be able to: •
Use the Model-View-Controller (MVC) approach when developing your Portal Applications.
Business Example Build applications using MVC.
MVC Java Server Pages (JSPs) - Motivation The Java servlet approach for developing server-side web applications has some drawbacks, e.g. • • •
Application logic and content creation is mixed Generation HTML output from a Java class is not comfortable (e.g. out.println(“
”) Developers need both Java and HTML know-how
These issues have been overcome with the introduction of Java Server Pages (JSPs). These are simple HTML (or XML, WML, …) templates, enriched with special tags for server side page processing. At runtime, the JSPs are compiled to Java Servlets.
Both the HTTPServletRequest and the IPortalComponentRequest are available Only the IPortalComponentResponse is available (no HTTPServletResponse!) Only the HTTPSession is available (no IPortalComponentSession!)
Exercise 10: JSPDynPage Exercise Objectives After completing this exercise, you will be able to: • Write Portal Applications that using JSPDynPages. • Add your elements to a TabStrip
Business Example Task: Create an Application using the TabStrip HTMLB element to demonstrate the use of tags in the JSPDynPages. 1. 1.
Create a Portal Application with the name 05-JSPTabStrip-htmlbXX where XX is your student or group number.
2.
Create a Portal Component based on a JSPDynpage with the name JSPtabstrip.
3.
Ensure that you have the following code at the top of your JSP page:
Add more tabstrips items within the tabstrip start and end tags. These form the screens that will be displayed when a user presses the top tab. hbj:tabStripItemHeader>
12. Enter this code into the doInitialization method. This will enable the first tab to be selected when we first access this screen(the user has not had a chance to change). We could change this to 2 or 3 later. // set the initial entry button to the first tab IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest(); request.putValue("tabselection1", "1");
13. Create a par file, deploy onto your server and test. 14. Optional: Add other htmlb elements into your ‘tab screens’.
id="myDropdownListBox1"
tooltip="Tooltip for my DropdownListBox" selection="k2" disabled="false" nameOfKeyColumn="KeyCol" nameOfValueColumn="ValueCol" >
key="k1" value="Spanish Seville" selected="true"/>
Add more tabstrips items within the tabstrip start and end tags. These form the screens that will be displayed when a user presses the top tab. hbj:tabStripItemHeader>
12. Enter this code into the doInitialization method. This will enable the first tab to be selected when we first access this screen(the user has not had a chance to change). We could change this to 2 or 3 later. // set the initial entry button to the first tab IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest(); request.putValue("tabselection1", "1");
13. Create a par file, deploy onto your server and test. 14. Optional: Add other htmlb elements into your ‘tab screens’.
id="myDropdownListBox1"
tooltip="Tooltip for my DropdownListBox" selection="k2" disabled="false" nameOfKeyColumn="KeyCol" nameOfValueColumn="ValueCol" >
key="k1" value="Spanish Seville" selected="true"/>
Unit Summary You should now be able to: • Understand and build abstract portal components • Discuss the nature of the security zone • Discuss how a Portal application uses the security zone features • Discuss permissions and security zones • Allow end user personalization of portal applications • Write Portal Applications that are language independent and handle complex phrases in a language neutral fashion. • Build Portal applications using HTMLB controls • Use the Model-View-Controller (MVC) approach when developing your Portal Applications.
Unit 6 Portal Services and Web Services Unit Overview Describe Portal Services. Develop and deploy Portal Services. Access Portal Services from another Portal application. Generate Web Services proxies fro a portal services. Generate proxies for a Web Service and access them from a Portal Application.
Unit Objectives After completing this unit, you will be able to: • • • • • •
Describe what Portal Services are and situations where they are typically used Develop and Deploy your own Portal Services Access Portal Services from another Portal Application Describe the basic components of Web Services and how they are used Generate Web Service Proxies for a Portal Service Generate Proxies for a Web Service and access them from a Portal Application
Unit Contents Lesson: Portal Services ........................................................200 Exercise 11: Custom Portal Services .................................... 211 Lesson: Web Services .........................................................222
Lesson Objectives After completing this lesson, you will be able to: • • •
Describe what Portal Services are and situations where they are typically used Develop and Deploy your own Portal Services Access Portal Services from another Portal Application
Business Example Deploy a portal service and use it in another application.
In the non-trivial case, a service provides an interface based API and an implementation. • • •
The implementatoin is non-public and will not be seen by nor interfer with using applications. The service interface relates the service API and its implementation by offering access to implementations of API interfaces through factories. The API should not rely on any other non-standard API.
A portal service can be transfered into a Web Service.
Exercise 11: Custom Portal Services Exercise Objectives After completing this exercise, you will be able to: • Implement your own service and access this within your Portal Application
Business Example Task:
62
1.
Create a new portal project called 06-CustomPortalServiceXX where XX is your group number. Create a service called PercentCalc with a method getPercentage. getPercentage accepts two floating point numbers and returns a floating point result which is the precentage of the two numbers passed in. Deploy this service to the portal.
2.
Create a portal application called CustomPortalServiceTestXX to call the portal service you just deployed.
Create a new portal project called 06-CustomPortalServiceXX where XX is your group number. Create a service called PercentCalc with a method getPercentage. getPercentage accepts two floating point numbers and returns a floating point result which is the precentage of the two numbers passed in. Deploy this service to the portal. a)
Lesson Summary You should now be able to: • Describe what Portal Services are and situations where they are typically used • Develop and Deploy your own Portal Services • Access Portal Services from another Portal Application
Lesson Objectives After completing this lesson, you will be able to: • • •
Describe the basic components of Web Services and how they are used Generate Web Service Proxies for a Portal Service Generate Proxies for a Web Service and access them from a Portal Application
Figure 257: Web Services Support in the Portal (1)
By providing a SOAP connection to the Portal Service, external components can access to the services and applications developed with the PRT technology using the SOAP protocol. The PRT provides tools and facilities to generate Proxies to external WEB Services, so that Portal Components and Portal Services can easily access to external WEB Services to build Portal Applications.
Figure 258: Web Services Support in the Portal (2)
Inqmysoap.jar: a JAXM 1.0 Implementation (based on the Java API for XML Messaging (JAXM)) which was developed as JSR067 under the Java Community Process.
Alias: is the alias name for the service in the portalapp.xml Output: is the name of the wsdl file Location import: if you want to use multiple wsdl files to describe your wsdl file, this option will write tag import in the generated wsdl (not often used) Location URL: The end of the URL to access to the portal, at runtime sth. Is added like to give the service the port addess in the wsdl file.
Generate the virtual portal service client: this will generate a proxy service use in communication between two PRT with Web Service protocol. In this case a proxy will fake a true PortalService on PRT Client side. Enable the getter/setter limitation: If disable allow you to generate in wsdl/serializer signature of complex only based on getter (no need to code setter for each attribute). This should only be used for inside/out scenario, when need to give back to soap call messaeg such complex type. Enable Security: Enable security based on ACL/Portal User Management. If set true you will need to setup for each possible user right in ACL. The user are extracted from the httprequest as in the normal portal scenario: user/password/sso ticket/https.....
Lesson Summary You should now be able to: • Describe the basic components of Web Services and how they are used • Generate Web Service Proxies for a Portal Service • Generate Proxies for a Web Service and access them from a Portal Application
Unit Summary You should now be able to: • Describe what Portal Services are and situations where they are typically used • Develop and Deploy your own Portal Services • Access Portal Services from another Portal Application • Describe the basic components of Web Services and how they are used • Generate Web Service Proxies for a Portal Service • Generate Proxies for a Web Service and access them from a Portal Application
Unit 7 Standard Portal Services Unit Overview Describe available services in the Portal Runtime. Describe key components of the User Management Engine (UME) and use the UM API to work with user, group and role objects. Describe the architecture of the Connector Framework and use the Connector gateway to connect to an ABAP system and a RDBMS.
Unit Objectives After completing this unit, you will be able to: • • •
Describe the available services in the Portal Runtime Describe the key components of the User Management Engine (UME) and use the UM API to work with user, group and roles objects Describe the architecture of the Connector Framework and use the Connector gateway to connect to an R/3 system and to RDBMS
Unit Contents Lesson: User Management....................................................238 Exercise 12: User Management ..........................................261 Lesson: Connector Framework ...............................................266 Exercise 13: JDBC Connection...........................................289
Lesson Objectives After completing this lesson, you will be able to: • •
Describe the available services in the Portal Runtime Describe the key components of the User Management Engine (UME) and use the UM API to work with user, group and roles objects
Business Example Build applications to access standard portal services such as User Management
Public Services of the PRT • • • • • • • • • • • • •
User Agent Service Logging Service Connector Framework JCo client service HTML Business for Java (HTMLB) User Management User Mapping Navigation System Console EPCF Toolbox System Landscape Admin Logviewer ...
Client eventing: The Client Framework enables portal components to communicate easily on the client. Several features like automatic relaxing of the JavaScript Origin Policy, Client Eventing and Client Data-Bag simplifies the integration and cooperation of different portal components from different servers. Logger: This service is used to diagnose problems and to return detailed information about the problems identified. Depending on the target user, it is possible to define simple or more complex logging. The logger provides a set of convenient methods for generating log messages.
JCo client service: This service defines all the actions needed to connect to an SAP system through RFC connections. HTML Business for Java: HTML Business for Java provides the user with an efficient set of controls, similar to JavaSwing. The controls are based on servlets and JSP pages. The developer uses bean-like components or JSP tags. Renderer classes translate the components into HTML commands. User Mapping: Map the user id, if the user has diffrent ids in diffrent systems User Management: Get user information (for example, role assignment) from portal user management Navigation: Create custom navigation iViews or custom navigation hierarchies System Console: Administration console to load PARs, monitor Cluster Landscape, and manage Portal Applications Xsltransform: Provides API to apply XLS transformation toXML document jcoclient: Manage JCO Client access by implementing pooling and session timeout/logoff detection Application Contentconverter: Generic XSL Converter providing factories to convert RSS to HTML and XML to HTML. Application Contentconversion: The Content Type Conversion Service offers API to add content converter capabilities to the response process. Admin Logviewer: search, filter, browser, download log files of the Platform. Admin Logadmin: manage logger configuration of the Platform. EPCF Toolbox: Java classes for EPCF integration Useragent: User-Agent (Browser) detection plus affiliation checker System Landscape: Get information about the system landscape iView Service: iViews/Pages/Systems semantic layer
Figure 278: Architecture Overview User Management Engine
UME is the central storage place for user and role information for all Java and ABAP applications that use UME. As such, the individual services do not have to rely on their own UM and the user is confronted with only one central user management service. Persistence Manager: Responsible for reading the data from or writing the data to the correct data source. The data source to which the persistence manager writes is transparent to the application. Specific user sets or attributes can be distributed across different repositories. Persistence Adapters Data source specific implementation for data storage and retrieval. The persistence manager consults the persistence adapters when creating, reading, writing, and searching user management data. Persistence adapters for the following types of repositories are available: Database Lightweight Directory Access Protocol (LDAP) directory SAP R/3 System 6.20 You can configure UME to use one or more of these persistence devices in parallel. Users can also be stored in several different physical LDAP directory servers, or in different branches of the same LDAP directory server.
The application programming interface (API): Layer on top of the persistence manager. In the persistence manager, you configure which data is written to or read from which data source, so that the applications using the API do not have to know any details about where user management data is stored Replication Manager The replication manager replicates UME data to external systems. User data that is written to the persistence manager is also written to the replication manager. The replication manager generates XML documents and sends them to the external systems which process them and perform the corresponding actions. For example, if you are using UME with SAP Enterprise Portal and want an SAP Customer Relationship Management (CRM) system to work with the same user base as the portal, you can configure UME to replicate all user data from the portal to the CRM system.
Figure 280: User Management Access in Portal Components
How do I determine which JAR file contains the API I want to use? -> A utility is available from the Alphaworks (IBM) website which plugs into the Eclipse IDE and provide a useful means of determining which JAR files need to be referenced. Download the free utility from the Alphaworks website http://www.alphaworks.ibm.com/aw.nsf/reqs/jarclassfinder (registration required). Unzip it into your NWDS eclipse\plugins directory. Restart NWDS.
The examples illustrate various objects returned: USER.CORP_LDAP.uid=i802895,ou=people,dc=sap,dc=corp (User from CORP_LDAP server) GRUP.CORP_LDAP_2.cn=developers,ou=groups,dc=sap,dc=corp (Group from a different LDAP server) GRUP.SUPER_GROUPS_DATASOURCE.EVERYONE (Special group "Everyone") ROLE.PCD_ROLE_PERSISTENCE.VvlvkEGjiW9zPFaxR/4pd2/bX5Q= (Role "super_admin") USER.PRIVATE_DATASOURCE.un:admin (User from database PRIVATE_DATASOURCE)
The IUser object contains most the information that you probably need regarding a user. Information about the name of the user, their unique ID, LDAP attributes, display name, role membership, etc are available from the IUser object. If you
have a user object (either from the authenticated user or any other user), you can use that object to query the user’s profile using the respective get() - methods. It is also possible to edit the corresponding profile data with the interface IUserMaint.
Figure 288: IUser Methods
IUser is read-only. In order to modify a user, use IUserMaint
Figure 290: Obtaining Information about another User
This example illustrates how to obtain information about a user using the Logon ID as a key. The exception checks to see if a nested exception such as NoSuchUserAccountException occurred
Figure 291: Obtaining Information about another User (2)
This example illustrates how to obtain information about a user using the Unique ID as a key. The exception checks to see if a nested exception such as NoSuchUserException occurred
Different applications or iViews which want to store application-specific data for the same principal object might cause inconsistencies by overwriting or deleting the data written by another application or iView. To prevent inconsistencies of this type, UME configuration files support namespaces, where each application can store its application-specific data in a separate namespace. In this way, custom attributes that have the same name are stored in a different namespace and do not clash with each other. Example: A user, USER.CORP_LDAP.uid=testuser,ou=research,o=sap, has three email addresses, one in it’s master data (in the UME default namespace com.sap.security.core.usermanagement), one for application1 and another for application2. Additional Custom Attributes can be added by editing the dataSourceConfiguration_xxx file. A mapping (logical to physical) needs to be performed for each attribute Use getAttribute() to retrieve the value of the required custom LDAP attribute
Figure 294: Attribute Mapping Configuration
In this example the LOGICAL attribute "lastname" is mapped to the PHYSICAL attribute "sn" The attribute mappings are defined in the dataSourceConfiguration_xxx.xml file for the appropriate LDAP vendor. See the How-To Guide
The namespace corresponds to the namespace defined in the XML configuration file. The name of the default (SAP standard) namespace is IPrincipal.DEFAULT_NAMESPACE
Users can be created with the UserFactory newUser() method. IUserMaint represents a modifiable user object. You must issue a commit() in order to actually create the user. An associated account needs to be created for the User with newUserAccount() using the UniqueID of the new User. Take care to delete the user if an error occurs (catch the appropriate exception and handle it).
Exercise 12: User Management Exercise Objectives After completing this exercise, you will be able to: • Access your account’s details through the IPortalComponentRequest object • Access further information like role assignments through the UMFactory
Business Example Task: User Management Service Develop an iView that displays personal attributes belonging to your user account, i.e. the email address, first and last name. In addition find out what roles are assigned to your user account. 1.
Open the in Exercise 3 generated project 03-FirstPortalProject.
2.
Create a new AbstractPortalComponent named com.sap.training.portal.UserInfoComponent
3.
Add a sharing reference to the usermanagement service to the component-config section in the portalapp.xml
4.
Get access to your user account attributes and print them. Use the IPortalComponentRequest object to perform this task. See course material for details. Find and add the necessary imports by the “Source → Organize Imports” wizard.
62
5.
Iterate through all roles available in the portal. Print roles assigned to current user. Use the UMFactory resp. the IRoleFactory to perform this task.
Solution 12: User Management Task: User Management Service Develop an iView that displays personal attributes belonging to your user account, i.e. the email address, first and last name. In addition find out what roles are assigned to your user account. 1.
Open the in Exercise 3 generated project 03-FirstPortalProject. a)
2.
Open the in Exercise 3 generated project FirstPortalProject
Create a new AbstractPortalComponent named com.sap.training.portal.UserInfoComponent a)
Click on the icon of the Portal Application Object wizard. Select Portal Component → Abstract Portal Component as template. Enter UserInfoComponent into the name field. Enter com.sap.training.portal into the package name field. Click finish.
3.
Add a sharing reference to the usermanagement service to the component-config section in the portalapp.xml a)
4.
Add a sharing reference to the new component. Double click on the portalapp.xml in FirstPortalProject → dist → PORTAL-INF → portalapp.xml. Click on More in the application section and then on Add... → Add Standard. Choose PrivateSharingReference and enter usermanagement into the value field. Finish the wizard. (This reference is only necessary for step 5)
Get access to your user account attributes and print them. Use the IPortalComponentRequest object to perform this task. See course material for details.
Find and add the necessary imports by the “Source → Organize Imports” wizard. a)
Add the coding for your details to the doContent() method. This could look as follows: IUser user = request.getUser(); String userName = user.getDisplayName(); String depName = user.getDepartment(); String phone = user.getTelephone(); String email = user.getEmail();
Iterate through all roles available in the portal. Print roles assigned to current user. Use the UMFactory resp. the IRoleFactory to perform this task. a)
In order to list all roles you have to get a search filter from the roleFactory and search using the wildcard *. The coding may look like this: response.write(" Your roles: "); IRoleFactory roleFactory = UMFactory.getRoleFactory(); IRoleSearchFilter rFilter; try { rFilter = roleFactory.getRoleSearchFilter(); rFilter.setDescription("*", ISearchAttribute.LIKE_OPERATOR, false); ISearchResult result; result = roleFactory.searchRoles(rFilter); if (result.getState() == ISearchResult.SEARCH_RESULT_OK) { while (result.hasNext()) { String uniqId = (String) result.next(); if (user.isMemberOfRole(uniqId, true)) { IRole aRole = roleFactory.getRole(uniqId); response.write(aRole.getDescription() + " "); } } } } catch (UMException e) { // TODO Auto-generated catch block e.printStackTrace(); }
Lesson Summary You should now be able to: • Describe the available services in the Portal Runtime • Describe the key components of the User Management Engine (UME) and use the UM API to work with user, group and roles objects
Lesson Objectives After completing this lesson, you will be able to: •
Describe the architecture of the Connector Framework and use the Connector gateway to connect to an R/3 system and to RDBMS
Business Example Build reports from RFC, BAPI or SQL Queries.
Connector Framework
Figure 305: JCA (J2EE Connector Architecture)
JCA/J2EE Connector Architecture is not API: it's the name of the architecture, as the name implies. The goal of JCA is to provide the pluggable connector architecture between J2EE Application Servers and EIS/Enterprise Information Systems (ex. ERP, RDBMS). JCA 1.0 defines set of system level contracts between J2EE Application Servers and EIS:
Connection management The J2EE Connector Architecture provides support for efficient connection management by relying on application connection pooling. Connections with EIS data and services are established, configured, cached, and reused automatically by application servers that are compliant with J2EE 1.3 technology. Rather than create and destroy EIS connections on an as-needed basis -- an inefficient approach at best -- J2EE Connector Architecture calls on Java technology application servers to monitor and manage them intelligently, in an effort to maximize runtime performance and scalability on the fly. The Java application server manages the EIS connection pool automatically and transparently, so no additional programming is required by either EIS or Java technology developers. Transaction management Transactional integrity is another thorny EIS integration issue elegantly solved by the J2EE Connector Architecture. The J2EE Connector Architecture prescribes "transaction management contracts" between application servers and EIS connectors. Third-party EIS vendors simply encapsulate transaction support within EIS connectors that are compliant with J2EE 1.3 technology to make them available to Java technology developers. For EIS vendors, this can range from no transaction support at all (for legacy systems), to support for one or all three types of enterprise transactions: local or XA (with either single- or two- phase commit). Conversely, Java technology application server vendors have no say in the matter of transaction support. The J2EE Connector Architecture specification requires them to deliver products to the market that uphold all EIS transaction types. Security The J2EE Connector Architecture defines portable "security contracts" that don't rely on platform- or implementation- specific technologies. The scope of these generic security contracts depends upon the particular back-end EIS system. For example, it could require password user-authentication, or an end-to-end environment, in addition to specific security requirements of the EIS. As with connection pooling and transactional support, it's up to the individual EIS connector vendors to roll in full support for their platform's security requirements. A J2EE Application Server vendor is responsible for shipping a set of Java API called "CCI/Common Client Interface". On the other hand, An EIS vendor is responsible for shipping "Resource Adapter", which is wrapped by CCI API. Resource Adapter may contain platform specific native libraries. You can think that the relationship of CCI and Resource Adapter is similar with the one we have in JDBC API and vendor specific database drivers. In theory, by using the JCA, EIS vendors no longer need to customize their product for each J2EE Application Server.
SAP has partnered with I-Way software to provide a number of RAs (they have over 250) Implements both CCI and uses the EIS's proprietary APIs for integration Shields the developer from complexities of the EIS APIs
Using the SAP Connector
Figure 306: Connector Framework (for SAP Connector)
Figure 309: How ABAP implements interface with RFM?
"Function Modules" are the routines of ABAP program.Theyhave well-defined interfaces called "Import parameters" and "Export parameters". ABAP has 3 data types - Scalar, Structure and Table values. SAP developed it's proprietary communication protocol called "RFC/Remote Function Call", which is originally based on the standard RPC/Remote Procedure Call. We call a RFC-enabled Function Module a "RFM/Remote Function Module". CCI/Common Client Interface API is a Java wrapping layer ofRFM.
Figure 310: Connector Framework (for SAP Connector)
Use the Connector Gateway Service to obtain connections to back end systems Use the Connection Properties object to facilitate SSO Create an Executable Interaction interact to describe the interaction with the back end system (Function Module, BAPI call, etc) Create an Interaction Spec (IInteractionSpec) to specify function module to call Create an input record (MappedRecord) describing input parameters Execute the interaction Spec with the input record
If you access ABAP data via JCA, the Java data type you need is only "Mapped Record type. MappedRecord is a collection of Record instances ordered by key-value pairs. We'll put respective scalar values, structure values, and table values on this MappedRecord instance. MappedRecord belongs to javax.resource.cci.* package.
Use the Connector Gateway Service to obtain connections to back end systems Use the Connection Properties object to facilitate SSO Obtain a connection to the back end system Create a Query object to describe the query you wish to execute on the back end system Execute the query and check the return status Obtain the output - usually returns an IRecordset object Iterate through the record set and deal with the data
Lesson Summary You should now be able to: • Describe the architecture of the Connector Framework and use the Connector gateway to connect to an R/3 system and to RDBMS
Unit Summary You should now be able to: • Describe the available services in the Portal Runtime • Describe the key components of the User Management Engine (UME) and use the UM API to work with user, group and roles objects • Describe the architecture of the Connector Framework and use the Connector gateway to connect to an R/3 system and to RDBMS
Unit 8 Enterprise Portal Client Framework Unit Overview Understand the architecture and features of EPCF. Use the Client Framework to raise and subscribe to events. Understand the Client Data Bag and pass data to receiving components using the Client Data Bag. Understand the different Navigation features and use the Navigation API. Understand the Work Protect feature.
Unit Objectives After completing this unit, you will be able to: • • • • •
Understand the architecture and features of the EPCF Use the Client Framework to raise and subscribe to events Understand the Client Data Bag and pass data to receiving components using the Client Data Bag Understand the different Navigation features and use the Navigation API Understand the WorkProtect feature and implement Portal Applications that handle unsaved data
Lesson Objectives After completing this lesson, you will be able to: • • • • •
Understand the architecture and features of the EPCF Use the Client Framework to raise and subscribe to events Understand the Client Data Bag and pass data to receiving components using the Client Data Bag Understand the different Navigation features and use the Navigation API Understand the WorkProtect feature and implement Portal Applications that handle unsaved data
Business Example
Enterprise Portal Client Framework • • •
•
302
Eventing Send and receive events without server involvement. Data Bag Store and load data on the client side. Navigation with Navigation Target Navigate to any portal page or iView inside a role through by URL Cross-navigate: use links within any portal application and the navigation nodes are automatically updated. WorkProtect Handle unsaved data in stateful applications.
getInstanceID: This method returns an unique EPCF instance as type String. The method is used by the EPCF core to distinguish the pages after a page refresh. getUniqueWindowId(): You can use this method to append the returned iFrame identifier string to the name you use to define a client data bag. This creates a client data bag that can only be accessed by a specific IFrame.
Figure 361: Client Eventing API
Namespaces: Compliant to W3C specification (RFC2141, RFC1630) reserved Namespaces SAP Core Development: urn:com.sap.* , urn:com.sapportals.* , urn:com.sapportals.portal.*
Provides the infrastructure for handling unsaved data in stateful applications. Preconditions for a portal application that wants to take advantage of the WorkProtect feature must maintain a special status: the “Dirty” flag EPCM.setDirty(flag) EPCM.getDirty() The Client Framework monitors the current “Dirty” state of all applications on the portal page. If one or more apps are marked as “Dirty” - navigation target is executed in a new window Navigation performed with browser links (Back/Forward, entering URL, etc.) always destroy the unsaved data. Navigation performed with browser lnhiks (Back/Forward/URL) always destroys the unsaved data because such links cannot be adapted. In a typical scenario, the application sets the “Dirty” flag when the user enters a new value in the entry field and resets the “Dirty”“ flag when The user saves it, i.e. clicks on the save/submit button in the portal application. Back, Forward, URL in the location bar always destroy the unsaved data. Links that use the doNavigate method are workprotect save. Links that open in a new window are save, but links with a target will lose the unsaved data.
Display the properties of that iView or Page Select and copy the PCD Location property value Replace the pcd: PREFIX with the PREFIX ROLES://
Figure 369: Start with NavigationTarget / Navigation by URL
Figure 370: Absolute Navigation
A navigation is considered to be absolte of the full path – starting from the navigation hierarchy root down to the navigation target, is known to the invoker of the navigation.
For navigation through the portal, when the absolute location of the navigation target is known. The function must get the navigation target parameter. All the rest of the parameters are optional.
Possibility to navigate to a location, relative to current location. For Example: < A HREF="myLink2" onclick="return EPCM.doRelativeNavigate('ROLES://portal_content/WebDynproTests/WebDynproRolle/Level1/Level2/Level3/Level4', 2, '{WebDynproPage}')">This is a portal link using doRelativeNavigate PCDUrl of the current node folder Levels up Name of the Page to which to navigate.