Question
Last activity: 22 Feb 2016 10:17 EST
Looping in HTML
Hi ,
I want to Loop two Page-List properties in HTML, can you please suggest me the syntax.
Thanks
Suresh Chella
Hi John,
Thanks for you reply. My problem is a bit different.
I have a nested loop where I have to compare property value from outer loop with another value in the inner loop. If it matches, then I need to print the value on the screen. So far I am unable to find a way to store and retrieve the property from outer loop in a local variable that I can use to compare with the value in inner loop.
Thanks
Suresh
Accepted Solution
You might want to look at using the 'scratchpad' mechanism available for Pega Tags: where you can stash/retrieve values for later use.
I haven't tried this with 'dynamic' values, but it might be something to look into ? (Also: the help seems to suggest this works by using Javascript (clientside) so this also might not suit your requirement...)
The example usage in the help is:
To save:
<pega:save name="company" value="Pegasystems Inc."/>
To retrieve/reference:
<pega:reference name="$save(company)"/>
See:
prhelp/procomhelpmain.htm#jsp/save/jspsave.htm
prhelp/procomhelpmain.htm#jsp/referencingproperties.htm
Additionally: maybe you could create a third data structure : and populate this based on the match of the 'inner' and 'outer' values. Using a Data Transform to produce the third structure ?
Then you could simplify your HTML output just to loop through the third-structure you built in the DT ?
Hi Suresh,
Thanks - just to be clear: which approach did you opt for ? Using the PegaTags 'save' option or the Data Transform option ?
Cheers
John
Hi jhon,
Can you please help on me the following case.
i know the syntax for exact match condition
<pega:when test=".Color == 'RED' " ></pega:when >
What is the syntax for "Contains or Like " ??
Hi Suresh,
Please start a new post for this question to get more specific responses!
Regards,
Lochan | Online Community Moderator | Pegasystems Inc.
To loop through complex PRPC Property/Page Types in an HTML rule - you can use the 'forEach' Pega Tag.
See this post here for an example of doing this: Re: Generate pdf dynamically with specific values from Pega UI
For convenience here's an example of the 'forEach' tag in use from that post:
If you need to iterate through two complex types: you can nest the tags.
See the help sections entitled: "Stream processing of JSP tags" and "JavaServer Pages tags" for more information on using Pega Tags.
Cheers
John