Deploying Siebel Web UI Dynamic Developer Kit (DDK) artifacts on... WebSphere, Part 2: Deploying artifacts as a portlet application
by user
Comments
Transcript
Deploying Siebel Web UI Dynamic Developer Kit (DDK) artifacts on... WebSphere, Part 2: Deploying artifacts as a portlet application
Deploying Siebel Web UI Dynamic Developer Kit (DDK) artifacts on IBM WebSphere, Part 2: Deploying artifacts as a portlet application Arundhati Bhowmick Hanumaiah Chowdary Hamdy T Eed Sinu Sekhar 19 December 2005 © Copyright International Business Machines Corporation 2005. All rights reserved. 1 Table of contents Introduction ............................................................................................................................ 2 A typical Web UI DDK to portlet scenario .............................................................................................................. 3 Prerequisites .......................................................................................................................................................... 3 Examine the Web UI DDK output .......................................................................................................................... 4 Converting artifacts using WebSphere Studio........................................................................ 5 Create a Basic Portlet project ................................................................................................................................ 5 Prepare the DDK artifacts for the portal environment............................................................................................ 9 Generate the Java proxy files .............................................................................................................................. 10 Modify the portlet code and JSP files .................................................................................................................. 11 Run the Web UI DDK portlet application ............................................................................................................. 16 Converting the artifacts using Application Developer ........................................................... 17 Create a Basic Portlet project .............................................................................................................................. 17 Prepare the artifacts for the portal environment .................................................................................................. 20 Generate the Java proxy files .............................................................................................................................. 21 Run the portlet application ................................................................................................................................... 22 Deploying the artifacts to WebSphere Portal ....................................................................... 23 Import the portlet application ............................................................................................................................... 23 Add the portlet to a page ..................................................................................................................................... 25 Viewing the portlet application results .................................................................................. 26 Conclusion ........................................................................................................................... 29 Download ............................................................................................................................. 30 Resources ............................................................................................................................ 30 About the authors................................................................................................................. 31 Introduction Development teams can use IBM Software and the Siebel Web UI Dynamic Developer Kit V7.8 (hereafter called Web UI DDK) to develop service-oriented architecture based composite applications. These Web applications can include data and functionality from multiple applications accessed through a single user interface. Siebel developers use the Web UI DDK to generate Java artifacts that access Siebel data. Portlet developers, using IBM IDE's, can convert these artifacts into portlet applications. This article walks you through how to use either IBM® WebSphere® Studio Application Developer V5.1.2 (hereafter called WebSphere Studio) or Rational® Application Developer V6.0(hereafter called Application Developer) to convert, test, and deploy Siebel Web UI DDK artifacts to run as a portlet application on IBM WebSphere Portal Server V5.x (hereafter called WebSphere Portal). 2 This is the second article in a two-part series. The first article described the Web UI DDK in more detail and explained how to deploy the artifacts as a Web application on WebSphere Application Server using either WebSphere Studio or Application Developer. Part 2 details the coding changes required to convert a Java application into a portlet application. Part 2 is for portlet developers who want to use Web UI DDK Java artifacts in portlets that run under WebSphere Portal. Before you begin, you might want to download the code samples. A typical Web UI DDK to portlet scenario To fully understand the artifacts to portlet conversion process, you need to become familiar with the roles of both the Siebel and portlet developers. The Siebel developer typically performs these tasks: 1. 2. 3. 4. 5. 6. Analyze Siebel data models and object models. Run the Web UI DDK wizard for a given view to generate JSPs and J2EE artifacts. Verify Integration Objects and Business Services in Siebel Tools. Verify Web services administration data. Compile the Siebel Repository File (SRF) with repository changes. Provide the Web UI DDK artifacts to the portlet developers. In this scenario, portlet developers would perform these tasks: 1. 2. 3. 4. 5. Import the Java artifacts into the appropriate folders in a Basic Portlet project. Remove html tags such as html, head, and body tags. Change the J2EE form actions to point to the portlet related actions, using createURI. Change the c:url tags to portletAPI:createURI tags, retaining the parameters. Replace all the Http related objects such as HttpServletRequest, Response, and Session to portlet specific objects. 6. Convert the Controller logic in the doView() method of the portlet. Prerequisites You need to complete the following in order to be able to convert Web UI DDK artifacts to a portlet application. 1. 2. 3. 4. 5. Install the Siebel Web Client, Siebel Tools, and the Siebel Server. Make sure the Siebel Gateway Name Server and the Siebel Server are started. Generate the DDK artifacts for the required Siebel View using Siebel Tools. Enable Custom Application Object Manager server component, and verify if it is online. Install a J2EE development environment (WebSphere Studio V5.1.2 or Application Developer 6.0). 3 Examine the Web UI DDK output After the Seibel developer has generated the Web UI DDK artifacts using the Siebel tool, he or she has a zip file containing the artifacts. In order to verify the contents, place this zip file in a suitable location (for example, C:\ddk_artifacts on Windows), and extract the contents, using the existing directories in the zip. The files extract subdirectories under a single directory (in this example, C:\ddk_artifacts\AllAccsViewDDK), as listed in Table 1. Table 1. Web UI DDK zip file contents lib src wsdl web readme base.txt ddk.log Contains the required Java jar files for the selected Siebel data view. Contains the Java source for form beans, services and utility classes. Contains the Siebel web services files and the build.xml file used to generate proxy classes from the WSDL files. Contains the JSPs, image and style sheet files. Provides basic instructions on how to deploy the Siebel J2EE artifacts using WebSphere Application Developer. Specifies the Siebel 7.8 release and version number. Includes any error messages if occur during generating the artifacts in Siebel tools. The directory structure should look similar to Figure 1. 4 Figure 1. Generated Web UI DDK zip file directory structure Converting artifacts using WebSphere Studio This section shows you how to convert the Siebel Web UI DDK artifacts into a portlet application using WebSphere Studio V5.1.2 in a Windows environment. Create a Basic Portlet project 1. Start WebSphere Studio by selecting Start => Programs => IBM WebSphere => WebSphere Application Developer 5.1.2. 2. Select File => New => Other. The New dialog displays. 3. In the left frame, select Portlet Development, and in the right frame, select Portlet Project. 4. Click Next. 5 5. In the New Portlet Project dialog, in the Project name field, type a name for your portlet project. For example, TestPortlet. 6. Choose the default Basic portlet. Make sure the Configure advanced options checkbox is selected. 6 7. Click Next. The J2EE Settings Page dialog is displayed. 8. Make sure the J2EE level 1.3/WebSphere Portal 5.0 radio button is selected. You need to set the J2EE level to 1.3 due because the DDK artifacts are created using the Siebel Tools which use J2EE 1.3 level in the web deployment descriptor file. 9. Click Next. 7 10. Click Next on all subsequent screens to accept the defaults, or click Finish. The Portlet perspective is displayed. 8 Prepare the DDK artifacts for the portal environment Follow these steps to prepare the portlet application you created in Create a Basic Portlet project by copying the output of the DDK artifacts into the appropriate folders in the portlet project. 1. Using Windows Explorer, open the project folder. 2. Copy the Java source files from the src folder of the DDK artifacts folder to the JavaSource folder in the portlet project. Only the contents of the src folder need to be copied. You will see some errors due to a Web Services dependency, but these will be resolved in a later step. 3. Copy the jar files from the lib folder of the DDK output folder to the WEB-INF/lib folder in the portlet project. 4. Copy the wsdl folder of the DDK output folder to the new portlet project folder. The files under this folder will be used to generate proxy classes for the Web Service calls. 5. Copy the JSP files from the /web/<View Name for DDK>/ to the /WebContent/<portlet_name>/jsp/html folder. Only the contents of the web directory need to be copied. 6. Copy the attached jar httpreq.jar to the shared/app folder under PortalServer runtime. The runtime path would look like <Installation folder for Application Developer or WebSphere Studio>/runtimes/portal_v50/shared/app. This jar file contains the wrapper class for retrieving HttpServletRequest from PortletRequest object. This is required because the DDK generated front-end JSPs are dependant on HttpServletRequest object. 9 7. Go back to WebSphere Studio workbench, right click on the portlet project and select Refresh from the popup menu. You should see a few errors under JavaSource folder, which can be ignored at this point as they will be corrected when the proxy classes are generated. Generate the Java proxy files Next, you use the ANT build script (build.xml) to generate proxy classes from WSDL files. 1. Right-click on build.xml, and select Run Ant. 2. In the Modify attributes and launch window, click the Run button. The Java proxy source files are generated in the JavaSource folder. 3. Right-click the portlet project, and select Refresh. There should be no errors at this point. 10 Modify the portlet code and JSP files The following steps explain how to change the portlet code as well as the JSP tags as per the requirements of Portal runtime. 1. Copy the functions in the Action.jsp file to the portlet class. 2. Change all input parameters for the copied functions from: HttpServletRequests to PortletRequests HttpServletResponse to PortletResponse 3. Import httpreqpool.*; in the portlet class. This will import the classes in httpreq.jar, which is used to retrieve HttpServletRequest from the PortletRequest object. 4. Add a line in the beginning of every function to get an Httprequest object from PortletRequest object, as shown in this code example: //Retrieve Http Request HttpServletRequest httpReq = GlobalRequest.getHttpServletRequest(request); 5. Remove references to the Response objects in the copied functions because it is never used in the portlet application. (That is, if a response object is passed to any other functions within the functions you just copied, then remove it; although it is passed, it is not used in those classes. You also need to go into the appropriate class and remove the response object from the signature). 6. Assuming that you have instantiated the httpReq object (as shown above), now, throughout the portlet, change: request.getSession to httpReq.getSession request.setAttribute to httpReq.setAttribute If the HttpServletRequest object is passed to any of the JavaBeans in the project: 1. 2. 3. 4. 5. Duplicate the function which accepts HttpServletRequest. Change the HttpServletRequest to PortletRequest. Overload the function with a different argument. Change the return path as shown in Listing 1. Make this path change for all the functions which are copied from Action.jsp. 11 Listing 1. Change the View JSP path // Change the return path from: "/<View Name>/" + "<JSP Name>" // Change the return path to: "/<portlet project name>/jsp/ " + "<JSP Name>" Next, you need to move the controller logic from Controller.jsp to the doView() function in the portlet. The algorithm is as follows. Retrieve the parameter 1 from Request Object. Check it for null and for a particular value. If parameter 1 matches specifications then Get PortletConfig and then PortletContext, and include a JSP based on the return from the function associated with the parameter. Else Check for another Value for the parameter and Include the JSP, and so on. The code representation for the algorithm is shown in Listing 2. Listing 2. Change the portlet controller to render the account list view //Invoke the JSP to render if ((request.getParameter("action")) != null&& (request.getParameter("action")).equals("Login")) getPortletConfig().getContext().include(Account_List_Applet_OpenNew(request, response),request,response); else if ((request.getParameter("action")) != null&& (request.getParameter("action")).equals("Account_List_Applet_Drilldown")) getPortletConfig().getContext().include(Account_List_Applet_Drilldown(request, response), request,response); […] 12 Important: Make sure there is a call to super.init(config) in the init method of the portlet. This call is mandatory for retrieving the config object by a call to getPortletConfig() from the portlet, as shown below. public void init(PortletConfig portletConfig) throws UnavailableException { super.init(portletConfig); } Now you need to change the html tags in the JSP files to confirm to the portlet tags. 1. Remove html tags such as <html>, <head>, and <body> from all JSPs. 2. Copy only the content under the <body> tag. 3. Add portlet reference headers to all the JSPs, as shown below. <%@ page session="false" contentType="text/html" import="java.util.*, ddkportlet.*"%> <%@ taglib uri="/WEB-INF/tld/portlet.tld" prefix="portletAPI" %> <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %> <portletAPI:init/> 4. Replace page tags in all the JSPs as shown below. From: <%@ page contentType="text/html;charset=UTF-8" %> <%@ page language="java" %> To: <%@ page language="java" contentType="text/html; charset=ISO-88591" pageEncoding="ISO-8859-1" session="false"% > 5. Change c:url tags to portletAPI:createURI tags, retaining the parameters, as shown below. 13 From: <c:url var="url" value="Controller.jsp"> <c:param name="srcPage" value="Account_List_AppletDetail.jsp"/> <c:param name="pagePath" value="${requestScope.pagePath}"/> <c:param name="action" value="Account_List_Applet_OpenQuery"/> </c:url> <a href="<c:out value='${url}'/>" class=buttonLink>Query</a> To: <a href='#' class=buttonLink onClick="query()">Query</a> <form name="searchAccount" action="<portletAPI:createURI > <portletAPI:URIAction name='Account_List_Applet_OpenQuery'/> </portletAPI:createURI> <input type="hidden" name="action" value="Account_List_Applet_OpenQuery"/> <input type="hidden" name="srcPage" value="Account_List_AppletDetail.jsp"/> <input type="hidden" name="pagePath" value="<c:out value="${requestScope.pagePath}"/>"/> </form> <script > function query() { document.searchAccount.submit(); } </script > As you can see, the < c:param > tags are converted to hidden variables in a form, and a JavaScript function has been added to make the form submission. The action of the form is pointing to the createURI tag of WebSphere Portal, which generates the portal link; the action will 14 have the same name as the action in DDK artifacts. This change is needed because you cannot refer to individual JSPs in a portal using URLs as you can in a J2EE application. Important: You need to make similar changes for all the links in all the JSPs which use a c:url tag, except the links with Logout action value, which is done in a different way (shown later). Make sure that you create unique names for the JavaScript function names and form names. 6. Change the form actions to point to the portal action using portletAPI:createURI as shown below: From: <FORM METHOD="POST" ACTION="Controller.jsp"> To: <FORM method="POST" action="<portletAPI:createURI</portletAPI:createURI>"> 7. In PagePath.java, search and replace HttpServletRequest with PortletRequest. The PagePath class stores the parameters in the request object, and the portal parameters are stored in PortletRequest. 8. Also in PagePath.java, search and replace HttpServletResponse with PortletResponse. 9. Change the sign out links in the DDK JSPs: From: <c:url var="url" value="Controller.jsp"> <c:param name="action" value="Logout"/> </c:url> <a class=tableLinkSmall href="<c:out value='${url}'/>">Sign Out</a> To: <a class=tableLinkSmall> <href='<portletAPI:createURI><portletAPI:URIAction> <name="Logout"/><portletAPI:URIParameter name="action" > <value="Logout"/> </portletAPI:createURI'>Sign Out</a> 15 Important: See the portlet source code in the download to look at the conversion done for Accounts View for Siebel. Run the Web UI DDK portlet application To run the Web UI DDK portlet application: 1. Right-click on the portlet project, and select Rebuild Project. 2. Right-click on the login.jsp file in the ../WebContent/All_Account_List_View/ folder, and select Run on Server. The Server Selection window displays. 3. Select WebSphere Portal v5.0 Test Environment, and click Finish. The logon screen displays. 4. Enter a valid user id and password. For the logon credentials, use your Siebel application login such as CallCenter, Sales, or contact your Siebel administrator 5. Click the Sign In button. The Siebel View displays. In our example the All Accounts List View displays. To see the expected output for our example, please refer to section Viewing the portlet application results. 16 Converting the artifacts using Application Developer This section shows you how to convert the Siebel Web UI DDK artifacts into a portlet application using Application Developer V6.0 in a Windows environment. Create a Basic Portlet project 1. Start Application Developer by going to Start => Programs => IBM Rational => Rational Application Developer v6.0 => Rational Application Developer. 2. Select File => New => Project. 3. Select Portlet Project and click Next. 4. In the Name field of the New Portlet Project window, enter a name for your portlet project. 5. Click on the Show Advanced button. 6. Make sure the Servlet version field is set to 2.3. By default, Application Developer selects servlet version 2.4. You need to change it to 2.3 because the DDK artifacts use servlet version 2.3 in the web deployment descriptor. 7. In the Target server field, select WebSphere Portal v5.0. 17 8. Click Next. 9. Select Basic Portlet. 18 10. Click Finish. In the project explorer, a portlet project should now display under the Dynamic Web Projects folder. 19 Prepare the artifacts for the portal environment Now, you prepare the portlet application you created in section Create a Basic Portlet project by copying the output of the DDK artifacts into the appropriate folders in the portlet project. 1. Copy the Java source files from the src folder of the DDK artifacts folder to the JavaSource folder in the portlet project. You will see some errors due to a Web Services dependency, but it will be resolved in a later step. 2. Copy the jar files from the lib folder of the DDK output folder to the WEB-INF/lib folder in the portlet project. 20 3. Copy the wsdl folder of the DDK output folder to the new portlet project. 4. Copy the JSP files from the /web/<View Name for DDK>/ to the /WebContent/<portlet_name>/jsp/html folder. 5. Copy the httpreq.jar (from the download) to the shared/app folder under PortalServer for runtime. 6. The workspace directory structure should now resemble that shown in the figure below. 7. Go back to the Application Developer workbench, right-click on the portlet project, and select Refresh. You should see a few errors, which you can ignore for now. Generate the Java proxy files Next, you use the ANT build script (build.xml) to generate proxy classes from WSDL files. 1. Right-click on build.xml, and select Run Ant. 2. In the Modify attributes and launch window, click Run. 21 3. The Java proxy source files are generated in the JavaSource folder. 4. Right-click the portlet project, and select Refresh. There should be no errors at this point. Perform the steps described in Modify the portlet code and JSP files. Run the portlet application To run the Web UI DDK portlet application. 1. Right-click on the portlet project, and select Rebuild Project. 2. Right-click on the login.jsp file in the ../WebContent/All_Account_List_View/ folder, and select Run on Server. The Server Selection window displays. 3. Select WebSphere Portal v5.0 Test Environment, and click Finish. The logon screen displays. 4. Enter a valid user id and password. For the logon credentials please, use your Siebel application login such as CallCenter, Sales, or contact your Siebel administrator. 22 5. Click Sign In. The Siebel View should displays. In our example the All Accounts List View is displayed. To see the expected output of our example, please refer to section Viewing the portlet application results. Deploying the artifacts to WebSphere Portal Now that you have created and tested the portlet application in the development environment, you are ready to deploy the artifacts as a portlet in a portal using WebSphere Portal V5.x. In the following steps, you export the artifacts as a WAR file from your development test environment (WebSphere Studio or Application Developer), and then you deploy it onto an external portal server. Import the portlet application 1. In the development environment project explorer, select the DDK artifacts portlet project. 2. Right-click on the project, and select Export => WAR file, as shown below. 3. In the WAR Export window, provide a destination folder where you want the WAR file to be created. If there is already a file in this location, you need to check Overwrite existing file. If you want the source to be exported as well, select Export source files. 23 4. Click Finish. 5. Start WebSphere Portal Server 5.x in Windows, by selecting Start => Programs => IBM WebSphere => WebSphere Portal v5.1 => Start the server. It might take a few minutes for WebSphere Portal to start, depending on the speed of your machine. 6. Once the server starts, go to the default portal with this URL: http://localhost:portnumber/wps/myportal 7. Enter the userid and password to log in.(This is the userid and password used when you installed WebSphere Portal. ) 8. Click on the Administration Link in the top right corner. 24 9. In the left navigation pane, select on Portlet Management => Web Modules. 10. Click Install. 11. Browse for the war file you exported from your development environment and select it. 12. Click Next. 13. Verify the portlets which are bundled in the war file, and click Finish. 14. After some time, the portal server will come up with a message that the Web Module was installed successfully. Add the portlet to a page 1. Select Portal User Interface => Manage Pages. 25 1. Select (Edit Layout) button on any page under My Portal for adding the portlet. The selected page displays for editing/adding portlets. 2. Click on the Add Portlet button. 3. Search for the portlet you just installed, then select it, and click Ok. 4. Click Done. 5. Click on My Portal link on the top right corner to go back to Portal pages. 6. Navigate to the page where the portlet was added 7. At this point the logon screen should be displayed. Viewing the portlet application results This section illustrates the results that the user would see once he or she logs into the DDK portlet application in the test environment. The figure below shows the application running in WebSphere Studio Application Developer test environment. It shows the Account List details screen. If you are using Rational Application Developer as your test environment you should see a very similar looking screen. 26 Figure 2. Web UI DDK account list details view The figure below illustrates the All Accounts View details in the Siebel CallCenter application. The highlighted buttons and links such as Query , Menu let you query the highlighted account, and Save, Delete, and Modify a single account details using the Menu dropdown list. If you update any of the account records the changes are reflected immediately in the Siebel CallCenter application. 27 Figure 3. All Accounts list view When you click on a link for a single account in the All Account View details (for example, account1), the details of that account display, as shown below. 28 Figure 4. Siebel Call Center Account details view Conclusion You can use the instructions and attached files to help you set up your environment. You can test your own Siebel Web UI DDK artifacts as a portlet application, using either WebSphere Studio Application Developer or Rational Application Developer test environment. Finally, you deploy the DDK Web application on an external WebSphere Portal server as a portlet application. 29 The artifacts generated by the DDK tool require no knowledge of Siebel application, or meta-data, and it generates all the required Web services code to connect to a Siebel back-end system. Therefore, developers can quickly and easily gain access to Siebel data through Web services. Download To download the code samples, see the cover page for this article: http://www.ibm.com/developerworks/websphere/library/techarticles/0512_chowdary/0512_chowdary. html Resources Deploying Siebel Web UI Dynamic Developer Kit (DDK) artifacts as a WebSphere application: Part 1. Deploying artifacts in a web application http://www.ibm.com/developerworks/websphere/library/techarticles/0510_chowdary/0510_chowdary.html developerWorks WebSphere Portal zone http://www.ibm.com/developerworks/websphere/zones/portal/ developerWorks WebSphere Studio zone http://www.ibm.com/developerworks/websphere/zones/studio/ Rational Application Developer for WebSphere Software technical resources http://www.ibm.com/developerworks/rational/products/rad/ Press Release: Siebel Systems and IBM Reach Milestone in Joint Plan to Deliver Service-Oriented Architecture-Based Composite Applications http://www.siebel.com/news-events/press_releases/2005/050628_milestone.shtm Rational Application Developer V6 trial software http://www.ibm.com/developerworks/downloads/r/rad/?S_TACT=105AGX10&S_CMP=ART Siebel product documentation, Siebel Bookshelf. Click on product documentation in the left navigation pane. http://supportweb.siebel.com/ WebSphere trial software http://www.ibm.com/developerworks/websphere/downloads/?S_TACT=105AGX10&S_CMP=ART 30 About the authors Arundhati Bhowmick is a Certified IT Specialist, focused on portal application development, deployment, and integration. She was one of the key developers in the XML Parser development team in IBM. Currently she is a Senior IT Specialist for the IBM Business Partner Technical Enablement team. She has more than 10 years of experience in IBM. Hanumaiah Chowdary is a Certified IT Specialist in Business Partner Technical Enablement within IBM's Software Group. Hanumaiah has been an Enablement Architect at Siebel, working with WebSphere Portal and Application Server enablement, integration, and interoperability-related activities. He has an extensive knowledge of the Siebel family of products and releases, as well as Java, J2EE, WebSphere Portal, WebSphere Application Server, JSF, SOA, and Web services. He has published many internal and external documents. Hamdy Eed is a consulting IT specialist for IBM AIM Services in the San Francisco bay area. He has worked on a multitude of WebSphere Application Server products at IBM at the Research Triangle Park in North Carolina. He joined IBM Global Services in Millville, New Jersey as an IT Specialist in 1998. Sinu Sekhar is an IBM certified Solution Developer/System Administrator (WebSphere Portal V5.0,V5.1/WebSphere Application Server V5.0) with extensive experience in Java, WebSphere Application Server, WebSphere Portal, WebSphere Studio Application Developer, Rational Application Developer, VisualAge for Java, and DB2 Universal Database. Trademarks • • • • DB2, IBM, Lotus, Tivoli, Rational, and WebSphere are trademarks or registered trademarks of IBM Corporation in the United States, other countries, or both. Windows and Windows NT are registered trademarks of Microsoft Corporation in the United States, other countries, or both. Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. Other company, product, and service names may be trademarks or service marks of others. IBM copyright and trademark information: http://www.ibm.com/legal/copytrade.phtml 31