This 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:
Creating a subscriber portlet
Creating a publisher portlet
Defining broadcast events
Assigning events to listeners
Adding messaging portlets to a page
Adding the click-across messaging portlets page to a page group
Testing the messaging portlets
Creating a subscriber
portlet
Select Build | Portlets from the Web Studio left pane.
Click New to open the Portlet Builder.
When the Portlet Builder opens, click Add to open the New Web Element window.
In the Location text box, enter http://investor.stockpoint.com
and click
Find.
In the Web page Quote field, enter “SY” and click Go to submit your search query.
Click Next in the upper-right corner.
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.
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.
Click the Variable option next to the Symbol parameter and complete these options:
Symbol – select this option to create parameters for the stock quote.
Default Value – enter “SY”.
Type – select “Text Field.”
Required – select this option.
Click Next to see a preview of the captured data.
Verify that you have entered the “SY” default
value for the Symbol parameter. Parameters without default values
may not work.
In the Element Name field, enter a name for the captured data; for example, “Stock Quote.” Click Finish.
In Portlet Builder, you see a working preview of the portlet.
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:
Sybase: SY
Microsoft: MSFT
Oracle: ORCL
Cisco: CSCO
PeopleSoft: PSFT
Click Save. You see the New Element Finish window. Complete these options:
Portlet Name – enter “My Stock Quote”.
Active, Iframe, No Popup, Editable – select all of these options. Leave the remaining options unselected.
Messaging portlets must have the Iframe option selected.
Content Type – select “text/html.”
Assigned Roles – click Add All to move all roles from the Available Roles list to the Assigned Roles list.
Accept the defaults for the remaining options.
Click Finish to save the portlet.
Creating a publisher portlet
Select Build | Portlets from the Web Studio left pane.
Click New to open the Portlet Builder.
When the Portlet Builder opens, click Add to open the New Web Element window.
In the Location text box, enter http://finance.yahoo.com
and
click Find.
In the middle column of the Yahoo Finance Web page, beneath the Top Stories heading, click the “Most Actives” link.
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.
Click Select next to the top captured table option, then click Next.
On the Split page, click Next.
On the Define page, click Next.
On the Filter page, click Next.
On the page where you define or override CGI parameters, do nothing. Click Next to continue.
In the preview window, give the element a good name like “Most Actives” and click Finish.
Click Save in Portlet Builder.
In the Finish window, verify your save options and settings:
Portlet Name – enter “Most Actives”.
Active, Iframe, No Popup, Editable – select all of these options.
Messaging portlets do not work unless Iframe is selected.
Content Types – select “text/html.”
Assigned Roles – click Add All to move all roles from the Available Roles list to the Assigned Roles list.
Accept the defaults for the remaining options.
Click Finish.
Click Close to exit the Portlet Builder and return to the Web Studio main window.
Defining broadcast events
Not 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.
Select Build | Portlets from the Web Studio left pane.
On the Portlet Manager Status menu, click New to display, in the detail pane, new portlets to which you have access.
Locate the two newly saved portlets (publisher and subscriber).
By 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.
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.
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:
Dynamic – sends the text you click on as the event data.
Static – sends a constant value you specify in the text box to the right of the drop-down list as the event data.
HREF – if the text for which you are defining the event is a link, the underlying URL is sent as the event data.
Enter these values:
Row – the word “all”.
Column – “1” (the number one).
Event Name – “Stock_Click” (note the underscore).
Select “Dynamic Value” from the drop-down list
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.
Click Next to save the new event.
When the Preview page displays, click Finish.
Back in the Web Studio, right-click the Most Actives portlet and select Approval Status | Approved.
Defining 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.
On the Status Menu, click New, then right-click the Stock Quote portlet and select Define Listeners.
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.”
Select Auto Submit to have the publisher of the event call this listener and have the portlet re-execute immediately.
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.
In the Web Studio, right-click Stock Quote portlet and select Approval Status | Approved.
Adding 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.
In Web Studio, select Build | Pages from the left pane.
Click New on the Page Manager toolbar.
In the Page Builder window, click Add.
In the Search window that displays, click Search.
You must have already given the portlets the Approved
status; otherwise, the portlets do not display in the search results.
In the Results pane, hold down the Ctrl key and select the Most Actives and Stock Quote portlets. When both are selected, click Add.
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:
Invisible – lets you hide a specific portlet from the end user. For example, you could set the display status of an portlet to invisible because the portlet is performing a server-side lookup operation; for example, transforming city names to postal codes.
Active – when this option is selected, which it is by default, the associated portlet is marked as active. Only portlets marked active and approved display in Portal Interface.
Click Save As to save the page. Complete these fields:
Name – enter “My Stock Quotes”.
Type – select Default.
Active – this option is selected by default.
Roles – click Add All to assign all the available roles to the page.
Click OK to save the page.
After a dialog box tells you the page has been saved, click OK, then click Close to exit the Page Builder.
On the Page Manager Status menu, click New to locate the new page.
Right-click the My Stock Quotes page in the detail pane, and select Status | Approved.
Adding the click-across
portlets page to a page group
Add the new page that contains the click-across messaging portlets to a page group.
In Web Studio, select Build | Page Groups.
Click the New button on the Page Groups Manager toolbar.
When the Page Group Builder displays, click Add.
When the Search window appears, click Search.
In the Results pane, select the My Stock Quotes page and click Add.
In the Page Group Builder, click Save As.
When the Save Page Group window appears, complete the fields as follows:
Name – enter “My Stock Quotes”.
Type – select Default.
Pages must be of the same type as the page group to
which you add them. For example, if you create a “default” type
page group, you can only add pages to that page group that are also
the “default” type.
Navigation Style – accept the default.
Active – verify that this option is selected.
Assigned Roles – hold down the Ctrl key, select PortalAdmin and PortalUser, then click Add to move those roles to the Assigned Roles list.
Click OK to save the page group, and click OK again when a prompt verifies that the page group has been saved.
Click Close to exit the Page Group Builder.
Select New from the Page Group Manager Status menu in the Web Studio main window.
Right-click the new page group, and select Status | Approved from the pop-up. Click OK when the page group saved confirmation displays.
Select Approved from the Status menu.
Right-click the My Stock Quotes page group select Update Users.
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.
Click Logout to exit Web Studio.
Testing the messaging
portlets
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
Log in using an existing account or create a new account using the Join Now link.
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.
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. |
![]() |