Building click-across messaging portlets  Building application portlets

Chapter 5: Advanced Portlet Creation

Creating messaging portlets

NoteThis discussion of click-across messaging portlets uses the Web element portlet type for examples. However, you can create click-across messaging portlets from any portlet type that has tabular data, a grid, or table structured output, and allows you to enter input parameters—JSP, XML, database, and Web services.

This section walks you through creating a click-across messaging portlet:

  1. Creating a subscriber portlet

  2. Creating a publisher portlet

  3. Defining broadcast events

  4. Assigning events to listeners

  5. Adding messaging portlets to a page

  6. Adding the click-across messaging portlets page to a page group

  7. Testing the messaging portlets

StepsCreating a subscriber portlet

  1. Select Build | Portlets from the Web Studio left pane.

  2. Click New to open the Portlet Builder.

  3. When the Portlet Builder opens, click Add to open the New Web Element window.

  4. In the Location text box, enter http://investor.stockpoint.com and click Find.

  5. In the Web page Quote field, enter “SY” and click Go to submit your search query.

  6. Click Next in the upper-right corner.

  7. On the next page, move the mouse around until the cursor is positioned over some text in the first column of the stock quote table. Click one of the row titles—such as Last or Open—once.

    You see a preview with several selections. Each selection contains more data from the captured table.

  8. Click Select next to the capture option you want to use, then click Next. Click Next until you bypass the Split Rules, Define, and Filter windows. Stop when see the window where you define or override CGI parameters.

  9. Click the Variable option next to the Symbol parameter and complete these options:

  10. In the Element Name field, enter a name for the captured data; for example, “Stock Quote.” Click Finish.

  11. In Portlet Builder, you see a working preview of the portlet.

  12. To test overriding the CGI parameter, type a different stock symbol into the Symbol text box and click Update. Some example stock symbols to use are:

  13. Click Save. You see the New Element Finish window. Complete these options:

    Accept the defaults for the remaining options.

  14. Click Finish to save the portlet.

StepsCreating a publisher portlet

  1. Select Build | Portlets from the Web Studio left pane.

  2. Click New to open the Portlet Builder.

  3. When the Portlet Builder opens, click Add to open the New Web Element window.

  4. In the Location text box, enter http://finance.yahoo.com and click Find.

  5. In the middle column of the Yahoo Finance Web page, beneath the Top Stories heading, click the “Most Actives” link.

  6. Click Next, then move the mouse around until the cursor is positioned over the Name column of the table. Click on the “Name” heading once to capture the table.

  7. Click Select next to the top captured table option, then click Next.

  8. On the Split page, click Next.

  9. On the Define page, click Next.

  10. On the Filter page, click Next.

  11. On the page where you define or override CGI parameters, do nothing. Click Next to continue.

  12. In the preview window, give the element a good name like “Most Actives” and click Finish.

  13. Click Save in Portlet Builder.

  14. In the Finish window, verify your save options and settings:

    Click Finish.

  15. Click Close to exit the Portlet Builder and return to the Web Studio main window.

StepsDefining broadcast events

NoteNot all portlet types can have events defined; the portlet must have tabular data, a grid, or table structured output. If you try to create an event and nothing seems to happen, try using a different portlet type. Web Studio does not always issue a warning if the portlet is not capable of having an event defined.

  1. Select Build | Portlets from the Web Studio left pane.

  2. On the Portlet Manager Status menu, click New to display, in the detail pane, new portlets to which you have access.

  3. Locate the two newly saved portlets (publisher and subscriber).

    NoteBy default, a portlet has the “New” status until you right-click the portlet in the detail pane, select Approval Status from the pop-up and select a different status.

  4. Right-click the Most Actives portlet and select Define Events from the pop-up.

    The Define Events wizard displays in a new window. Defining events is a three-step process. The first step shows you all grid, table, or list (structured) objects contained in the current portlet. You can define events only on structured (tables and lists) content.

  5. In the first wizard window, click Select to choose the top table listed and click Next. The next window allows you to define or edit an event.

    You can define an event for a row, a column, or any subset of rows and columns. You can also use the row and column number to identify a specific cell to define an event.

    Enter the keyword “all” for Row and Column to indicate all values in a row or column for an event.

    Event Name is a logical name that must be unique across the entire portal and you must have separate names for distinct events. You can reuse the name for different cells to have the same event generated.

    WARNING! Defining multiple events on the same data causes invalid HTML. In other words, column 1 can not have more than one event defined on it.

    The differences between the types of data that can be sent in an event are:

  6. Enter these values:

  7. Click Add to add the event to your events list. After a short time, the first column should turn blue, which indicates there is an event defined for that column.

  8. Click Next to save the new event.

  9. When the Preview page displays, click Finish.

  10. Back in the Web Studio, right-click the Most Actives portlet and select Approval Status | Approved.

StepsDefining listeners

This step lets you define a listener for the event to which a portlet is going to subscribe and listen. You can register a portlet to listen for one or more events. Each event to which a portlet listens must be assigned a portlet input parameter. You must remember the name of the event to which you want a portlet to listen.

  1. On the Status Menu, click New, then right-click the Stock Quote portlet and select Define Listeners.

  2. In the Event Name field, type “Stock_Click”—the name of the event you defined for the My Actives portlet—then make sure that Listener Param is set to “Symbol.”

  3. Select Auto Submit to have the publisher of the event call this listener and have the portlet re-execute immediately.

  4. Click the plus sign to the right of Listener Param to add the listener event to the portlet. Once the plus turns into a check mark, click OK to save your changes. If you make an error, click the X icon to delete the Listener Param association, and repeat steps 1 and 2.

  5. In the Web Studio, right-click Stock Quote portlet and select Approval Status | Approved.

StepsAdding messaging portlets to a page

To test the event you defined, you must add the new portlets to a new page that can be viewed in Portal Interface.

  1. In Web Studio, select Build | Pages from the left pane.

  2. Click New on the Page Manager toolbar.

  3. In the Page Builder window, click Add.

  4. In the Search window that displays, click Search.

    NoteYou must have already given the portlets the Approved status; otherwise, the portlets do not display in the search results.

  5. In the Results pane, hold down the Ctrl key and select the Most Actives and Stock Quote portlets. When both are selected, click Add.

  6. Click and drag the boxes in the right preview until the Most Actives portlet is on the left and the Stock Quote portlet is on the right.

    The options for each portlet in the left pane are:

  7. Click Save As to save the page. Complete these fields:

    Click OK to save the page.

  8. After a dialog box tells you the page has been saved, click OK, then click Close to exit the Page Builder.

  9. On the Page Manager Status menu, click New to locate the new page.

  10. Right-click the My Stock Quotes page in the detail pane, and select Status | Approved.

StepsAdding the click-across portlets page to a page group

Add the new page that contains the click-across messaging portlets to a page group.

  1. In Web Studio, select Build | Page Groups.

  2. Click the New button on the Page Groups Manager toolbar.

  3. When the Page Group Builder displays, click Add.

  4. When the Search window appears, click Search.

  5. In the Results pane, select the My Stock Quotes page and click Add.

  6. In the Page Group Builder, click Save As.

  7. When the Save Page Group window appears, complete the fields as follows:

  8. Click OK to save the page group, and click OK again when a prompt verifies that the page group has been saved.

  9. Click Close to exit the Page Group Builder.

  10. Select New from the Page Group Manager Status menu in the Web Studio main window.

  11. Right-click the new page group, and select Status | Approved from the pop-up. Click OK when the page group saved confirmation displays.

  12. Select Approved from the Status menu.

  13. Right-click the My Stock Quotes page group select Update Users.

  14. When you see the message that the operation succeeded, click OK. Because the My Stock Quotes page group is the “default” type, all registered Portal Interface users can access this page group after the update operation.

  15. Click Logout to exit Web Studio.

StepsTesting the messaging portlets

  1. Start Portal Interface by entering:

    http://HOSTNAME.PORTALDOMAIN:8080/onepage/index.jsp
    

    If you are using the EP Demo version, enter:

    http://demo.sybase.com:4040/onepage/index.jsp
    
  2. Log in using an existing account or create a new account using the Join Now link.

  3. Select My Stock Quotes from the page group drop-down list on the far right of the Portal Interface window. You see the messaging portlets.

  4. To test the click-across messaging portlets, select one of the stock symbols in the Most Actives portlet. The My Stock Quote Symbol input field updates with the stock symbol that you clicked on and updated stock information for the new symbol appears.





Copyright © 2004. Sybase Inc. All rights reserved. Building application portlets

View this book as PDF