Replicatable Datum and external parameter

Posted: 8 October 2009 in Components, CSSDK, External, Java, Pages, SitePublisher, Sites, Teamsite
Tags: , , , , , , ,

When you have an external in a SitePublisher component and the Datum parameter has a replicatable attribute set to yes, the parameter that gets passed to the external is the ReplicantSourceID made of comma separated list of the values of the replicants.

<External>
 <Parameters>
 <Datum Type="String" ID="dcrDir" Name="dcrDir" Replicatable="true" ReplicantSourceID="dcrDir">/templatedata/acme/article/data/</Datum>
 <Datum Type="String" ID="dcrDir-0" Name="dcrDir" Replicatable="true" ReplicantSourceID="dcrDir">/templatedata/acme/author/data/</Datum>
 </Parameters>
 <Object Scope="local">com.acme.SomeClass</Object>
 <Method>someMethod</Method>
</External>

Only thing, there’s a space before the comma and [] around the lot, so make sure to trim() the string after the split and remove the []!

String[] dcrDirs = context.getParameterString("dcrDir").split(",");
for (String dcrDir : dcrDirs) {
  String fullDcrDir = fileDal.getRoot() + dcrDir.trim();
  fullDcrDir = fullDcrDir.replace("[","");
  fullDcrDir = fullDcrDir.replace("]","");
  ...
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s