Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Nested iw_iterate only processes 1st item
krauseke
I have a fairly simple DCT that has a replicant field with an "or" container. Each "or" container has several items to be filled out. The DCT generates a nested DCR for each form element. But when I parse it using the iw_iterate it only parses the first or container in the list. I need it to loop through the outer element then for each of those loop in the inner element and perform the iw_ifcase based on the inner element value. I've posted both the DCT and the TPL as well as the DCR and resultant generated XML file. Any help would be appreciated.
Find more posts tagged with
Comments
krauseke
TPL
Summary.rptdesign
krauseke
DCR
Migrateduser
Please let us know what version of TeamSite (including SPs) you are using. Thanks.
lissa
krauseke
Version: 5.5.2 22887 20030728
bturns
Hey Ken,
I can't quite tell from the DCR whether the OR selection is within FormElement or the FormElements. If the OR is within the FormElement then you need to change your code to something like this:
<iw_iterate var="outer" list="dcr.FormElements" >
<iw_iterate var="inner" list="outer.FormElement" >
<iw_iterate list='inner.*' var='item'>
<iw_ifcase name='item'>
<iw_case type="TextBox">
This needs to happen because there are multiple "FormElement" values and within each FormElement there are also a possiblity of multiple values.
I took the "label" and "iteration" elements out because I wasn't quite sure what they were for.
Thanks,
Brian
krauseke
Thanks for the response. I've gotten it to iterate both items, but the second (and third...) have blank values in them. (i.e. it will print out the info for a text box, then print out the text area entry, but with no iw_value(s) in it.)
I've tried several different iterations and slices of it. When I print out the iteration counts, I get the following:
outer:0
inner:0
<process first element>
outer:1
inner:0
<process next element - empty values>
Not sure why it thinks it is on the second element, but tries to pull the iw_value from inner:0 instead of inner:n
Here's the TPL:
<iw_iterate var="outer" list="dcr.FormElements">
<iw_iterate var="inner" list="outer.FormElement">
<iw_iterate var="item" list="inner.*">
<iw_ifcase name="item">
<iw_case type="TextBox">
<![CDATA[
<label text="<iw_value name='dcr.FormElements.FormElement.TextBox.LabelText'/>">
<textinput message="<iw_value name='dcr.FormElements.FormElement.TextBox.LabelText'/>: <iw_value name='dcr.FormElements.FormElement.TextBox.ErrorMsg'/>" name="<iw_value name='dcr.FormElements.FormElement.TextBox.FieldName'/>" required="<iw_value name='dcr.FormElements.FormElement.TextBox.Required'/>" type="text"/>
</label>]]>
</iw_case>
<iw_case type="TextArea">
<![CDATA[
<label text="<iw_value name='dcr.FormElements.FormElement.TextArea.LabelText'/>">
<textarea name="<iw_value name='dcr.FormElements.FormElement.TextArea.FieldName'/>" required="<iw_value name='dcr.FormElements.FormElement.TextArea.Required'/>" />
</label>]]>
</iw_case>
</iw_ifcase>
</iw_iterate>
</iw_iterate>
</iw_iterate>
Here's the DCT:
<item name="FormElements">
<replicant max="30">
<container name="FormElement" combination="or">
<label>Form Element</label>
<container name="TextBox">
<label>Text Box</label>
<item name="LabelText" rowcontinue="t">
<label>Label Text</label>
<description>Label Text</description>
<text required="t" maxlength="75"/>
</item>
<item name="FieldName">
<label>Field Name</label>
<description>Name to be strored with data</description>
<text required="t" maxlength="75"/>
</item>
<item name="DataType" colspan="4">
<label>Data Type</label>
<description>Data Type</description>
<radio required="t">
<option selected="t" label="Text" value="Text" />
<option label="Numeric" value="Numeric" />
<option label="Date" value="Date" />
</radio>
</item>
<item name="Required" colspan="4">
<label>Required</label>
<description>Required</description>
<radio required="t">
<option label="Yes" value="true" />
<option selected="t" label="No" value="false" />
</radio>
</item>
<item name="ErrorMsg" colspan="4">
<label>Error Message</label>
<description>Message to be displayed on bad data entry</description>
<text maxlength="150" size="75"/>
</item>
</container>
<container name="TextArea">
<label>Text Area</label>
<item name="LabelText" rowcontinue="t">
<label>Label Text</label>
<description>Label Text</description>
<text required="t" maxlength="75"/>
</item>
</container>
</container>
</replicant>
</item>
Adam Stoller
note-1:
You can get rid of the CDATA tags if you change the iwpt tag at the top of the PT to being an empty element rather than an opening tag with a closing tag at the bottom -- I'm leaving them out because they're annoying to me.
note-2:
When you're nesting an iw_value tag within another tag - use the curly-brace format (as shown below) rather than the angle-bracket format since the latter is theoretically invalid XML code (as distinct from not-well-formed).
note-3:
When you create variables with iterate loops - you should use those variables -- this is probably where you're getting messed up right now.
I suggest trying the following:
<iw_iterate var="outer" list="dcr.FormElements">
<iw_iterate var="inner" list="outer.FormElement">
<iw_iterate var="item" list="inner.*">
<iw_ifcase name="item">
<iw_case type="TextBox">
<label text="
{
iw_value name='
inner
.TextBox.LabelText'/
}
">
<textinput message="
{
iw_value name='
inner
.TextBox.LabelText'/
}
:
{
iw_value name='
inner
.TextBox.ErrorMsg'/
}
"
name="
{
iw_value name='
inner
.TextBox.FieldName'/
}
"
required="
{
iw_value name='
inner
.TextBox.Required'/
}
" type="text"/>
</label>
</iw_case>
<iw_case type="TextArea">
<label text="
{
iw_value name='
inner
.TextArea.LabelText'/
}
">
<textarea name="
{
iw_value name='
inner
.TextArea.FieldName'/
}
"
required="
{
iw_value name='
inner
.TextArea.Required'/
}
" />
</label>
</iw_case>
</iw_ifcase>
</iw_iterate>
</iw_iterate>
</iw_iterate>
You might be able to use
item
in there too - I'm not entirely sure I've followed the DCT structure and such - but hopefully the above will help you along your way.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
krauseke
That was the trick - the missing inner.x.x tags in the values. Thanks for the help!