< Previous | Next >

Adding a snippet to assign the getQuoteInput variable

Create a snippet to retrieve the stock information from the list in the portfolio and then store it. This is completed based on a counter value that corresponds to a unique index in the list of business objects that represent stocks.

To add a snippet to assign the getQuoteInput variable to the process:
  1. Get the stock information using the counter as an index:
    1. In the process editor, click Snippet icon on the palette.
    2. Click inside the WhileLoop activity. The Snippet activity was added.
    3. Rename Snippet to Assign getQuoteInput by typing over the highlighted text.
    4. In the Properties view, click Details.
    5. Drag the existing InputStockPortfolio variable from the tray onto the canvas. Click on the label, then selectInputStockPortfolio > stockInfoList.
    6. Drag the existing counter variable from the tray onto the canvas.
    7. Click Java icon on the palette. The Select a Java Visual Snippet window opens.
    8. In the Specify a type (? = any character, * = any String) field, type java.util.List.
    9. Click List.
    10. Click get(int) and click OK.
    11. Click on the InputStockPortfolio.stockInfoList figure to add the get activity and connect the two figures.
    12. Connect the counter figure to the get figure.
    13. Drag the existing stockInfo variable from the tray and onto the canvas.
    14. Connect the get figure to the stockInfo figure.
      Get the selected stock information
  2. With the stock information now contained in stockInfo, we must assign the stock symbol to getQuoteInput:
    1. Drag the existing stockInfo variable from the tray onto the canvas. Click on the label and select stockInfo > symbol.
    2. Drag the existing getQuoteInput variable from the tray over the stockInfo.symbol figure on the canvas. A connection is created between both figures.
      Assign a stock symbol to getQuoteInput
The visual snippet should now look like this:
Completed snippet

Now that we have assigned the stock symbol to the getInputQuote variable, next we will use it as an identifier to obtain the stock quote with the web service.

Feedback
(C) Copyright IBM Corporation 2005, 2006. All Rights Reserved.
< Previous | Next >