Nested Servlet Beans and Referencing Parameters
Suppose, in the previous example, you wanted to display both the product's name and corresponding skus from the inner ForEach. You could do something like this:
<droplet bean="/atg/dynamo/droplet/ForEach">
<param name="array" VALUE="/myBean.products">
<oparam name="output">
<droplet bean="/atg/dynamo/droplet/ForEach">
<param name="array" VALUE="param:element.skus">
<p> <valueof param="..element.name"></valueof>
has the SKUs
has the SKUs
<valueof param ="element"></valueof>.
</oparam>
</droplet>
</oparam>
</droplet>
In the first VALUEOF tag, ..element refers to the element parameter of the outer ForEach. In the second VALUEOF tag, element refers to the element parameter of the inner ForEach. The resulting HTML is:
<p>Samsung Galaxy has the SKUS Samsung Galaxy B7510 .
<p>Samsung Galaxy has the SKUS Samsung Galaxy pop s5570
<p>Samsung Galaxy has the SKUS Samsung Galaxy pop i559
<p>Nokia has the SKUS Nokia Lumia 800
<p>Nokia has the SKUS Nokia X2
<p>Nokia has the SKUS Nokia C5
<p>Nokia has the SKUS Nokia Lumia 800
<p>Nokia has the SKUS Nokia X2
<p>Nokia has the SKUS Nokia C5
You can use this dot notation with multiple levels of nesting.
Parameters preceded by two dots refer to the servlet bean one level up; parameters preceded by three dots refer to the servlet bean two levels up; and so on. You can also use a single dot to refer to a parameter at the current level, but this is not necessary.
Parameters preceded by two dots refer to the servlet bean one level up; parameters preceded by three dots refer to the servlet bean two levels up; and so on. You can also use a single dot to refer to a parameter at the current level, but this is not necessary.
Another approach is to use the setvalue tag to define another parameter in the outer servlet bean, and set it to the value of the parameter you want to refer to from within the inner servlet bean. The following example uses this approach, and produces that same results as the example above.See the screen shot below.
Comments
Post a Comment