1
votes

I'm attempting to display the values of a multi-value field as an unordered list on my XPage. Unfortunately, when doing this with documents which do not already have the bound field, I'm informed 'rowData' not found for my itemValueArray. I had created a document prior to these machinations that has values in the field, so that one still opens for me.

Where have I gone wrong?

<xp:div style="display:none;">
    <xp:inputText id="linkages" value="#{poDoc.Linkages}" multipleTrim="true" multipleSeparator=";">
    </xp:inputText>
</xp:div>
<ul>
    <xp:repeat id="linkagesDisplayRepeat" rows="30" var="rowData">  
        <xp:this.value><![CDATA[#{javascript:var linkages = poDoc.getItemValueArray("Linkages");
return linkages;}]]></xp:this.value>
        <li>
            <xp:text escape="true" id="computedField7">
                <xp:this.value><![CDATA[#{javascript:rowData;}]]>
                </xp:this.value>
            </xp:text>
        </li>
    </xp:repeat>
</ul>
3

3 Answers

1
votes

Error 'rowData' not found is caused by non-existing item "Linkages".

Render the ul-repeat-block only if item "Linkages" is in document

   <xp:panel rendered="#{javascript: poDoc.hasItem('Linkages')}">
      <ul>
         <xp:repeat
            ...
         </xp:repeat>
      </ul>
   </xp:panel>

As an alternative you could set a default value to document's item "Linkages" on beforePageLoad event:

   <xp:this.beforePageLoad><![CDATA[#{javascript:
         if (!poDoc.hasItem("Linkages")) {
            poDoc.replaceItemValue("Linkages", "defaultValue");
         }
   }]]></xp:this.beforePageLoad>
1
votes

similar to knut's second idea, you could test for a value during data binding. if there is no value, return a default array (e.g., ["data missing"]). otherwise, return the field's value(s). this way you don't have to force a value into the otherwise empty or absent field...unless that is what you want.

1
votes

You can use simple EL for hide the repeat:

<xp:repeat id="linkagesDisplayRepeat" rows="30" var="rowData"
    rendered="#{not empty poDoc.Linkages}">