< Previous | Next >

Adding a while loop activity to the canvas

Create the while loop activity to contain activities that get each stock quote, grab the stock information and store the data in a business object.

We need to add a while loop activity and also define a boolean expression for it to ensure that the activities within the scope of the loop only obtain information for each stock once. This expression will compare the current counter to the number of symbols in the stock portfolio, and return either true or false.

To add the while activity to the PortfolioEvaluatorProcess process, follow these steps:

  1. In the process editor, click Choice icon on the palette and then WhileLoop icon, which is the WhileLoop icon.
  2. Click the connection between Initialize variables and Reply. The WhileLoop activity was added.
  3. Now that the activity is in the business process, we must add the boolean expression. If the value returned from the expression happens to be true, the loop will continue. However, if the value is false, the loop will terminate and the process will advance to the Reply activity. To make this expression, follow these steps:
    1. In the Properties view, click Details.
    2. From the Expression language list, click Java.
    3. Remove the existing false and return figures from the canvas. After that, drag the existing counter and numberOfSymbols variables from the tray onto the canvas.
    4. Click Standard icon on the palette. The Add a Standard Visual Snippet window opens.
    5. In the navigation tree, click math > less than and then click OK. Click the canvas to add the activity.
    6. Click Return icon on the palette, which is the Return icon, and click the canvas to add the activity.
    7. Connect the counter and numberOfSymbols figures to the less than figure.
    8. Connect the less than figure to the return figure to complete the expression, as shown in the following figure:
      Return the result of the conditional statement
Now that we have a WhileLoop activity to contain the business logic responsible for updating the stock portfolio, next we can initialize the variables that store stock quote information.

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