Hi, this is on TS 6.7.1 on Solaris:
I have a container with combination="or" and a number of sub-containers.
One specific sub-container has to be present always, only its position among all the sub-containers should be maintained by the user. Therefore the parent container has min="1" and the first sub-container is this specific one. Also this specific container must not be present more than once:
<container name="CONTENT">
<container name="SIDEBAR" min="1" max="10">
<container name="subcontainer1"> // this is the one that always has to be present
...
</container>
<container name="subcontainer2">
...
</container>
<container name="subcontainer3">
...
</container>
</container>
</container>
I registered two ItemHandlers for the parent container, one "onReplicantAdded", one "onReplicantDelete". The "onReplicantDelete" handler checks whether the container-to-delete is my specific one and if so, it displays a message and returns false, so the container does not get deleted. This handler works fine.
The "onReplicantAdded" handler is supposed to check which sub-container was added. If it is my specific container the "deleteInstance()" function should be used to delete the just added instance.
However, the deleteInstance() function always returns false (even if I hard-coded try to delete instance 1, which is always present).
For the above DCT structure my JS code looks like this:
function checkForSpecificSubcontainer(item) {
var itemName = item.getName();
var itemIndex = itemName.replace(/.*\[([0-9]+)\]/, "$1") // this returns the index of the currently added replicant instance
var parentItemName = itemName.replace(/(.*)\[.*\]/, "$1"); // this removes the "[****]" from the end of the current item name, so "/CONTENT/SIDEBAR[1]" will be shortened to "/CONTENT/SIDEBAR", which is my actual replicant container
var subtype = item.getChildren()[0].getName(); // get the full xpath of the currently added sub-container
subtype = subtype.replace(/.*\/([^\/]+)/, "$1"); // obtain the name of the currently added sub-container
if (subtype == 'subcontainer1') {
alert("This element must not be present more than once.");
var deleteResult = IWDatacapture.getItem(parentItemName).deleteInstance(itemIndex);
}
}
IWEventRegistry.addItemHandler("/CONTENT/SIDEBAR", "onReplicantAdded", checkForSpecificSubcontainer);
Does anyone have a clue what I am missing?
Thanks.