Portlet Factory, Version 6.1.2
Using repeated regions in a web application
When you are using this builder to duplicate a section of a page for each element in a list, provide three items of information: the section of the page to be repeated, the list to repeat over, and a loop variable. At run time, the loop variable is a placed in the Variables section where each element will be stored, one at a time, as the block is repeated. You can view the Variables section in the IBM® WebSphere Portlet Factory Designer by clicking the WebApp view. Then, in the middle pane select WebApp > Variables. Under Variables, select the name of the loop variable. Its value at run time is displayed in the right pane.
Consider this example: Assume you have the following XML list, which you have obtained through a Service Call (perhaps a database query) and you have used an assignment operation to store in a variable named Result.
<Result> <User> <Name>Fred Flintstone</Name> <Address>55 Slate Way</Address> <City>Bedrock</City> </User> <User> <Name>Wilma Flintstone</Name> <Address>55 Slate Way</Address> <City>Bedrock</City> </User> </Result>The following HTML page is used:
<BODY> <H2>Users:</H2> <UL> <LI name="RepeatSection"> <SPAN name="userName" style="font-weight:bold">name goes here</SPAN> <BR> <SPAN name="userAddress">address goes here</SPAN> <BR> <SPAN name="userCity">City goes here</SPAN> <BR><BR> </LI> </UL> </BODY>The builder uses the HTML tag of the control, which is the outermost part of the repeat. In this example, it is the <LI> tag that is being repeated. If you don't have a convenient tag for repeating, place a SPAN in your HTML and use that to demarcate the repeated area.
When specifying the Loop Variable, the prefix Variables/ is optional. If you specify Inputs/Name as a variable, then you will end up with the value Variables/Inputs/Name.
In the Repeated Region builder dialog, you would specify Variables/Result as the list, and you might select theUser as the loop variable. The example HTML page shown above provides a bullet list of the names and addresses.
Note: In the imported HTML, there is only a single bullet item. You want to repeat this entire section, once for each element in the list. To put the data in the repeated section, create Text builders which operate on the SPAN sections.
The first Text builder would be userName, and it would specify as its input Variables/theUser/Name. Note how the entire first list element (the portion within the User tag) has been put into the variable Variables/theUser. The first time this block is duplicated on the page, this variable contains the value "Fred Flintstone." The second time, it contains the value "Wilma Flintsone." After you add Text builders for userAddress and userCity, the final page, when rendered, resembles the following:
USERS:
- Fred Flintstone
55 Slate Way
Bedrock NH
- Wilma Flintstone
55 Slate Way
Bedrock NH
Parent topic: Repeated Region builder
Library | Support |