Adding initial elements for an occurrence

Here is an extension to the Loop tag, that enables
an initial number of occurrences to be inserted.

I’m not sure what the best package name to use is,
so feel free to change it to whatever suits you.

Here is the entry you need to add in the .tld:


loop
econtract.taglib.customdisplay.Loop
Custom Loop Tag that has the ability to insert an initial number of nodes

module
true


select
true


extselect
false


iterate
false


targetbase
true


document
false


base
false


pagesize
false


initialsize
false

If some of these occurrences need to be removed
(because they were not populated) before the document is committed, the following
code can be used:

public void removeEmptyOccurrences
(BusinessDocument doc, SessionContext sc)
throws InvalidXPathException,
BusinessDocumentException
{
Page page = sc.getPage(“<path_to_occurrence>/xapp:seq()”);

if (page instanceof BusinessNodePage) {
BusinessNodePage bPage =(BusinessNodePage) page;
for (int i=bPage.size()-1; i >=0; i–) { BusinessNode entry = bPage.get(i);

String entry = entry.getDescendant(“<node_to_check>”).getValue();
if (entry.length() == 0) { bPage.remove(i);
}
}
}
}
Loop.java (1.19 KB)