< Previous | Next >

Adding the required elements to the custom visual snippet

When you have finished defining the inputs and output for the custom visual snippet, you must add the required elements.

In this topic, you learn how to add the required elements to the IsDisplayArticle custom visual snippet. When you have finished adding the elements, the visual snippet editor should resemble the following figure:


Picture of the visual snippet editor with the required elements added

Picture of the visual snippet editor with the required elements added

To add the required elements to the custom visual snippet:

  1. Add the false expression:
    1. In the palette, click the Expression icon Picture of the Expression icon.
    2. Click the canvas in the upper left corner. The new expression is added to the canvas.
    3. In the expression, type false.
    Note: Expressions pass a variety of user-defined values to custom visual snippets. An expression can be visually composed using the expression builder.
  2. Add the isDisplayArticle expression:
    1. In the palette, click the Expression icon Picture of the Expression icon.
    2. Click the canvas under the false expression. The new expression is added to the canvas.
    3. In the expression, type isDisplayArticle.
  3. Add the symbols variable:
    1. Right-click the canvas under the isDisplayArticle expression.
    2. From the pop-up menu, select Add Existing > symbols.
    3. Under the isDisplayArticle expression, click the canvas to add the symbols variable.
  4. Add the IsListEmpty standard visual snippet:
    1. In the palette, click the Standard icon Picture of the Standard icon. The Add a Standard Visual Snippet window opens.
    2. In the Standard Visual Snippets list, expand the logic folder and select IsListEmpty.
    3. Click OK.
    4. Click the canvas under the symbols variable. The IsListEmpty standard visual snippet is added to the canvas.
    Note: Standard visual snippets are comprised of predefined visual snippets from the visual snippets library plus user-defined custom visual snippets. When you add a standard visual snippet to the visual snippet editor canvas, you will find that you cannot edit a predefined visual snippet from the visual snippets library but you can edit a user-defined custom visual snippet by double-clicking it.
  5. Add the Choice control structure:
    1. In the palette, click the Choice icon Picture of the Choice icon.
    2. Click the canvas under the IsListEmpty standard visual snippet. The Choice control structure is added to the canvas.
  6. Add the true expression to the if true section of the Choice control structure:
    1. In the palette, click the Expression icon Picture of the Expression icon.
    2. Click inside the if true section of the Choice control structure. The new expression is added.
    3. In the expression, type true.
  7. Add the isDisplayArticle variable to the if true section of the Choice control structure:
    1. In the if true section of the Choice control structure, right-click the canvas directly under the true expression.
    2. From the pop-up menu, select Add Existing > isDisplayArticle. (If isDisplayArticle does not appear as a menu item, briefly connect the output terminal of the false expression to the input terminal of the isDisplayArticle expression, then right-click the new link between the two expressions and select Delete. This will cause the isDisplayArticle menu item to appear when you re-invoke the pop-up menu.)
    3. In the if true section of the Choice control structure, click the canvas directly under the true expression. The isDisplayArticle variable is added.
  8. Add the symbols variable to the otherwise section of the Choice control structure:
    1. In the otherwise section of the Choice control structure, right-click the canvas.
    2. From the pop-up menu, select Add Existing > symbols.
    3. In the otherwise section of the Choice control structure, click the canvas to add the symbols variable.
  9. Add the iterator Java visual snippet to the otherwise section of the Choice control structure:
    1. In the visual snippet editor palette, click the Java icon Picture of the Java icon. The Select a Java Visual Snippet window opens.
    2. In the Specify a type (? = any character, * = any String) field, type java.util.list.
    3. In the Matching types list, select List.
    4. In the Qualifier list, select java.util - installDir/runtimes/bi_v6/java/jre/lib/core.jar (where installDir is the install path of WebSphere Integration Developer).
    5. In the Select a visual snippet list, scroll down and select iterator().
    6. Click OK.
    7. In the otherwise section of the Choice control structure, click the canvas under the symbols variable. The iterator Java visual snippet is added.
    Note: You can add a Java visual snippet directly to the visual snippet editor canvas or you can add it to an existing element in the visual snippet editor canvas.
  10. Add the it expression to the otherwise section of the Choice control structure:
    1. In the palette, click the Expression icon Picture of the Expression icon.
    2. In the otherwise section of the Choice control structure, click the canvas under the iterator Java visual snippet. The expression is added.
    3. In the expression, type it.
  11. Add the While control structure to the otherwise section of the Choice control structure:
    1. In the palette, click the While icon Picture of the While icon.
    2. In the otherwise section of the Choice control structure, click the canvas under the it expression. The While true control structure is added.
  12. Add the it variable to the condition area of the While true control structure:
    1. In the condition area (upper section) of the While true control structure, right-click the canvas.
    2. From the pop-up menu, select Add Existing > it. (If it does not appear as a menu item, briefly connect the output terminal of the iterator Java visual snippet to the input terminal of the it expression, then right-click the new link and select Delete. This will cause the it menu item to appear when you re-invoke the pop-up menu.)
    3. In the condition area (upper section) of the While true control structure, click the canvas. The it variable is added.
  13. Add the hasNext Java visual snippet to the condition area of the While true control structure:
    1. In the visual snippet editor palette, click the Java icon Picture of the Java icon. The Select a Java Visual Snippet window opens.
    2. In the Specify a type (? = any character, * = any String) field, type java.util.Iterator.
    3. In the Matching types list, select Iterator.
    4. In the Qualifier list, select java.util - installDir/runtimes/bi_v6/java/jre/lib/core.jar (where installDir is the install path of WebSphere Integration Developer).
    5. In the Select a visual snippet list, scroll down and select hasNext().
    6. Click OK.
    7. In the condition area (upper section) of the While true control structure, click the canvas under the it variable. The hasNext Java visual snippet is added.
  14. Add the hasMoreSymbols expression to the condition area of the While true control structure
    1. In the palette, click the Expression icon Picture of the Expression icon.
    2. In the condition area (upper section) of the While true control structure, click the canvas under the hasNext Java visual snippet. The expression is added.
    3. In the expression, type hasMoreSymbols.
  15. Add the hasMoreSymbols && isDisplayArticle == false expression to the condition area of the While true control structure:
    1. In the palette, click the Expression icon Picture of the Expression icon.
    2. In the condition area (upper section) of the While true control structure, click the canvas under the hasMoreSymbols expression. The expression is added.
    3. In the expression, type hasMoreSymbols && isDisplayArticle == false.
  16. Add the it variable to the body of the While true control structure:
    1. In the body (lower section) of the While true control structure, right-click the canvas.
    2. From the pop-up menu, select Add Existing > it.
    3. In the body (lower section) of the While true control structure, click the canvas. The it variable is added.
  17. Add the next Java visual snippet to the body of the While true control structure:
    1. In the visual snippet editor palette, click the Java icon Picture of the Java icon. The Select a Java Visual Snippet window opens.
    2. In the Specify a type (? = any character, * = any String) field, type java.util.Iterator.
    3. In the Matching types list, select Iterator.
    4. In the Qualifier list, select java.util - installDir/runtimes/bi_v6/java/jre/lib/core.jar (where installDir is the install path of WebSphere Integration Developer).
    5. In the Select a visual snippet list, scroll down and select next().
    6. Click OK.
    7. In the body (lower section) of the While true control structure, click the canvas under the it variable. The next Java visual snippet is added.
  18. Add the symbol expression to the body of the While true control structure:
    1. In the palette, click the Expression icon Picture of the Expression icon.
    2. In the body (lower area) of the While true control structure, click the canvas under the next Java visual snippet. The expression is added.
    3. In the expression, type symbol.
  19. Add the article variable to the body of the While true control structure:
    1. In the body (lower section) of the While true control structure, right-click the canvas under the symbol expression.
    2. From the pop-up menu, select Add Existing > article.
    3. In the body (lower section) of the While true control structure, click the canvas under the symbol expression. The article variable is added.
    4. Click inside the article variable. A pop-up list is displayed.
    5. In the pop-up list, expand article : NewsArticleBO and select title : nillable:string. The article variable is now named article.title.
  20. Add the symbol variable to the body of the While true control structure:
    1. In the body (lower section) of the While true control structure, right-click the canvas under the article.title variable.
    2. From the pop-up menu, select Add Existing > symbol (not symbols). (If symbol does not appear as a menu item, briefly connect the output terminal of the next Java visual snippet to the input terminal of the symbol expression, then right-click the new link and select Delete. This will cause the symbol menu item to appear when you re-invoke the pop-up menu.)
    3. In the body (lower section) of the While true control structure, click the canvas under the article.title variable. The symbol variable is added.
  21. Add the indexOf Java visual snippet to the body of the While true control structure:
    1. In the visual snippet editor palette, click the Java icon Picture of the Java icon. The Select a Java Visual Snippet window opens.
    2. In the Specify a type (? = any character, * = any String) field, type java.lang.String.
    3. In the Matching types list, select String.
    4. In the Qualifier list, select java.util - installDir/runtimes/bi_v6/java/jre/lib/core.jar (where installDir is the install path of WebSphere Integration Developer).
    5. In the Select a visual snippet list, scroll down and select indexOf(String).
    6. Click OK.
    7. In the body (lower section) of the While true control structure, click the canvas under the symbol variable. The indexOf Java visual snippet is added.
  22. Add the index expression to the body of the While true control structure:
    1. In the palette, click the Expression icon Picture of the Expression icon.
    2. In the body (lower section) of the While true control structure, click the canvas under the indexOf Java visual snippet. The expression is added.
    3. In the expression, type index.
  23. Add the index > -1 expression to the body of the While true control structure:
    1. In the palette, click the Expression icon Picture of the Expression icon.
    2. In the body (lower section) of the While true control structure, click the canvas under the index expression. The expression is added.
    3. In the expression, type index > -1.
  24. Add the Choice control structure to the body of the While true control structure:
    1. In the palette, click the Choice icon Picture of the Choice icon.
    2. In the body (lower section) of the While true control structure, click the canvas under the index > -1 expression. The Choice control structure is added to the canvas.
  25. Add the true expression to the if true section of the newly created Choice control structure:
    1. In the palette, click the Expression icon Picture of the Expression icon.
    2. Click inside the if true section of the new Choice control structure. The new expression is added.
    3. In the expression, type true.
  26. Add the isDisplayArticle variable to the if true section of the newly created Choice control structure:
    1. In the if true section of the new Choice control structure, right-click the canvas under the true expression.
    2. From the pop-up menu, select Add Existing > isDisplayArticle.
    3. In the if true section of the new Choice control structure, click the canvas under the true expression. The isDisplayArticle variable is added.
  27. Add the isDisplayArticle variable to the empty canvas:
    1. At the very bottom of the visual snippet editor canvas (and outside the control structures), right-click the canvas.
    2. From the pop-up menu, select Add Existing > isDisplayArticle.
    3. At the very bottom of the visual snippet editor canvas (and outside the control structures), click the canvas. The isDisplayArticle variable is added.
  28. Add the return activity to return the result for the custom visual snippet:
    1. In the palette, click the Return icon Picture of the Return icon.
    2. Click the canvas under the newly added isDisplayArticle variable. The return activity is added to the canvas.
  29. Press Ctrl-S to save your changes.
The required elements have now been added to the custom visual snippet. The elements will be marked with warning and error symbols, but these symbols will disappear when you connect the elements in the next topic.

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