Continuous capture versus server-side click-across  Creating events

Chapter 1: Developer Features

Creating server-side click-across portlets

This section describes how to create the three portlets needed for the server-side click-across example. You set up a master “parent” portlet and two “child,” or drill-down portlets, using database elements that extract data from sampledb. The three portlets are:

The completed example lets you click the department name to display a list of that department’s employees, and click the manager’s name to display information about the manager.

You extend the functionality by assigning a server-side click-across event that lets you click on an employee name to display details about that employee.

StepsCreating the SSCA Master portlet

Define the SSCA Master portlet that displays a list of departments within an organization. The portlet has two columns—one for department name, and one for department manager data.

  1. Log in to Web Studio.

  2. Select Portlets from the Build menu in the left pane, then click New to launch Portlet Builder.

  3. Click the arrow to the right of the Add button and select Database Element.

  4. In the Database Elements Definition window, enter Java Database Connection (JDBC) information. The JDBC connection allows the master portlet to access a database and extract specific database information.

    1. Select the JDBC URL option.

    2. Complete these options:

      • Username – enter dba, which is the user name used to access the database.

      • Password – enter SQL, which is the password used to access the database.

      • JDBC Connect URL – enter the URL used by JDBC to connect to the database:

        jdbc:sybase:Tds:localhost:4747?ServiceName=sampledb
        
      • JDBC driver – enter the JDBC driver used to connect to the database; in this case:

        com.sybase.jdbc2.jdbc.SybDriver
        
      • SQL Query String – enter the following SQL code to select department heads for each department from sampledb:

        select d.dept_name as 'Dept Name', e.emp_fname + ' ' + e.emp_lname as 'Dept Head' from department d, employee e where d.dept_head_id = e.emp_id
        
      • UI XSLT – leave this field empty.

  5. Click Preview. A two column table showing Dept Name and Dept Head displays in the Preview panel.

    Dept Name

    Dept Head

    R & D

    David Scott

    Sales

    Judy Snow

    Finance

    Mary Anne Shea

    Marketing

    Scott Evans

    Shipping

    Jose Martinez

  6. Click Next. When you see the Split window, click Next to bypass these options.

  7. When the Define window display, complete these options:

    Click Next.

  8. When the Filter window displays, click Next.

  9. When the window displays where you define variables, click Next to bypass the page. This example does not use variables.

    The Window Preview displays.

  10. Enter SSCA Master for the Element Name. Under Window Preview, notice the grid showing Dept Name and Dept Head.

    Click Next.

  11. In the Continuous Capture Page window, click Finish.

  12. When you return to the Portlet Builder, click Save.

  13. In the Finish window, complete the fields or options on each tab:

    Content tab:

    1. Name – enter SSCA Master.

    2. Content Type, Charset, Content Cache Interval – accept the defaults shown.

    3. Parameter, Secure – leave these options unselected.

    4. In Context – this option is selected by default.

    Roles tab: click Add All to add all of the available roles to the assigned roles list, which specifies that only users with these roles can access this portlet.

    Presentation tab: select No Popup and accept the defaults for the remaining options and fields.

    Administration tab: accept the defaults shown.

  14. Click Finish.

  15. When you see a message stating that the portlet was successfully saved, click OK.

  16. Click Close to exit the Portlet Builder.

  17. When you return to the Web Studio main window, select New from the Portlet Builder Status menu. The SSCA Master portlet displays in the detail pane.

  18. Right-click the SSCA Master portlet and select Approval Status | Approved.

  19. When the message displays that the portlet was saved successfully, click OK.

  20. Select Approved from the Portlet Manager Status menu. You see your newly approved SSCA Master portlet.

StepsCreating the SSCA Department portlet

Define one of the drill-down portlets—SSCA Department—that displays a list of a department’s employees. The portlet uses an @OP tag to dynamically select rows from the database and replace the Dept Name parameter.

  1. In Web Studio, select Portlets from the Build menu in the left pane, then click New to launch Portlet Builder.

  2. Click the arrow to the right of the Add button and select Database Element.

  3. In the Database Elements Definition window, enter Java Database Connection (JDBC) information. The JDBC connection allows the master portlet to access a database and extract specific database information.

    1. Select the JDBC URL option.

    2. Complete these options:

      • Username – enter dba, which is the user name used to access the database.

      • Password – enter SQL, which is the password used to access the database.

      • JDBC Connect URL – enter the URL used by JDBC to connect to the database:

        jdbc:sybase:Tds:localhost:4747?ServiceName=sampledb
        
      • JDBC driver – enter the JDBC driver used to connect to the database; in this case:

        com.sybase.jdbc2.jdbc.SybDriver
        
      • SQL Query String – enter the following SQL code to select department heads for each department from sampledb:

        select e.emp_fname + ' ' + e.emp_lname as Employee 
        from employee e, department d 
        where e.dept_id = d.dept_id 
        and '@OP["Dept Name"="Shipping"]' = d.dept_name
        

        Notice the @OP tag. This indicates that the portlet uses a parameter (Dept Name) to replace the tag at run time. If the parameter is not defined, the @OP tag is replaced by the default value, Shipping. This ensures that previews, when parameters are not explicitly defined, result in returning some valid data.

      • UI XSLT – leave this field empty.

  4. Click Preview. A one column table displays the Employee list in the Preview panel.

  5. Click Next. When you see the Split window, click Next to bypass these options.

  6. When the Define window display, complete these options:

    Click Next.

  7. When the Filter window displays, click Next.

  8. When the window displays where you define variables, specify the @OP tag as a portlet parameter and define Dept Name as the default value. Complete these options and fields:

  9. Click Next. The Window Preview displays.

  10. Enter SSCA Department for the Element Name, then click Next.

  11. In the Continuous Capture Page window, click Finish.

  12. When you return to the Portlet Builder, click Save.

  13. In the Finish window, complete the fields or options on each tab:

    Content tab:

    1. Name – enter SSCA Department.

    2. Content Type, Charset, Content Cache Interval – accept the defaults shown.

    3. Parameter, Secure – leave these options unselected.

    4. In Context – this option is selected by default.

    Roles tab: click Add All to add all of the available roles to the assigned roles list, which specifies that only users with these roles can access this portlet.

    Presentation tab: select No Popup and accept the defaults for the remaining options and fields.

    Administration tab: accept the defaults shown.

  14. Click Finish.

  15. When you see a message stating that the portlet was successfully saved, click OK.

  16. Click Close to exit the Portlet Builder.

  17. When you return to the Web Studio main window, select New from the Portlet Builder Status menu. The SSCA Department portlet displays in the detail pane.

  18. Right-click the SSCA Department portlet and select Approval Status | Approved.

  19. When the message displays that the portlet was saved successfully, click OK.

  20. Select Approved from the Portlet Manager Status menu. You see your newly approved SSCA Department portlet.

StepsCreating the SSCA Employee portlet

Define the second drill-down portlet, SSCA Employee.

  1. In Web Studio, select Portlets from the Build menu in the left pane, then click New to launch Portlet Builder.

  2. Click the arrow to the right of the Add button and select Database Element.

  3. In the Database Elements Definition window, enter Java Database Connection (JDBC) information. The JDBC connection allows the master portlet to access a database and extract specific database information.

    1. Select the JDBC URL option.

    2. Complete these options:

      • Username – enter dba, which is the user name used to access the database.

      • Password – enter SQL, which is the password used to access the database.

      • JDBC Connect URL – enter the URL used by JDBC to connect to the database:

        jdbc:sybase:Tds:localhost:4747?ServiceName=sampledb
        
      • JDBC driver – enter the JDBC driver used to connect to the database; in this case:

        com.sybase.jdbc2.jdbc.SybDriver
        
      • SQL Query String – enter the following SQL code to select department heads for each department from sampledb:

        select 1 as ID, 'Employee ID' as Item, 
        convert(varchar(255), emp_id) as Data from employee 
        where '@OP["Emp Name"="Fran Whitney"]' = emp_fname + ' ' + emp_lname
        
        UNION
        
        select 2 as ID, 'Employee Name', emp_fname + ' ' + emp_lname from employee e where '@OP["Emp Name"="Fran Whitney"]' = e.emp_fname + ' ' + e.emp_lname
        
        UNION
        
        select 3 as ID, 'Manager Name', e2.emp_fname + ' ' + e2.emp_lname 
        from employee e, employee e2 
        where e2.emp_id = e.manager_id and '@OP["Emp Name"="Fran Whitney"]' = e.emp_fname + ' ' + e.emp_lname
        
        UNION
        
        select 4 as ID, 'Dept Name', d.dept_name 
        from employee e, department d 
        where e.dept_id = d.dept_id and '@OP["Emp Name"="Fran Whitney"]' = e.emp_fname + ' ' + e.emp_lname
        
        UNION
        
        select 5 as ID, 'Birthdate', convert(varchar(255), birth_date) 
        from employee e 
        where '@OP["Emp Name"="Fran Whitney"]' = e.emp_fname + ' ' + e.emp_lname
        
        order by 1
        

        This includes the @OP tag “Emp Name”, which sets the default value to Fran Whitney. You define the default value later to complete the process.

      • UI XSLT – leave this field empty.

  4. Click Preview. A table showing Employee ID, Employee Name, Manager Name, Dept Head and Birthdate displays in the Preview panel.

  5. Click Next. When you see the Split window, click Next to bypass these options.

  6. When the Define window display, complete these options:

    Click Next.

  7. In the Filter window, define a filter that excludes column (field) 1.

    Click Next.

  8. When the window displays where you define variables, specify the @OP tag as a portlet parameter and define Emp Name as the default value. Complete these options and fields:

  9. Click Next. The Window Preview displays.

  10. Enter SSCA Employee for the Element Name, then click Next.

  11. In the Continuous Capture Page window, click Finish.

  12. When you return to the Portlet Builder, click Save.

  13. In the Finish window, complete the fields or options on each tab:

    Content tab:

    Roles tab: click Add All to add all of the available roles to the assigned roles list, which specifies that only users with these roles can access this portlet.

    Presentation tab: select No Popup and accept the defaults for the remaining options and fields.

    Administration tab: accept the defaults shown.

  14. Click Finish.

  15. When you see a message stating that the portlet was successfully saved, click OK.

  16. Click Close to exit the Portlet Builder.

  17. When you return to the Web Studio main window, select New from the Portlet Builder Status menu. The SSCA Employee portlet displays in the detail pane.

  18. Right-click the SSCA Employee portlet and select Approval Status | Approved.

  19. When the message displays that the portlet was saved successfully, click OK.

  20. Select Approved from the Portlet Manager Status menu. You see your newly approved SSCA Employee portlet.





Copyright © 2004. Sybase Inc. All rights reserved. Creating events

View this book as PDF