Discussion:
[opencms-dev] Modify container page programatically
Dudu Zoltan
2014-08-22 15:19:08 UTC
Permalink
Hi All,
I am trying to change a structure content in a container page via class.
I can change the Uri target to the new structured content path but the
structured content's UUID does not change.

what is the proper way of doing such a thing?

this is currently my way:

CmsResource res = cmsObject.readResource(resourcePath);
CmsFile file = cmsObject.readFile(res);
CmsXmlContent xmlContent = CmsXmlContainerPageFactory.unmarshal(cmsObject,
file);
List<I_CmsXmlContentValue> containers = xmlContent.getValues("Containers",
locale);
for (I_CmsXmlContentValue container : containers) {
I_CmsXmlContentValue containerType =
xmlContent.getValue(container.getPath() + "/Type", locale);
String containerTypeName = containerType.getStringValue(cmsObject);
if (containerTypeName.equals("mycont")) {
I_CmsXmlContentValue uri = xmlContent.getValue(container.getPath() +
"/Elements/Uri", locale);
uri.setStringValue(cmsObject, newResource.getRootPath());
}
}

thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20140822/0151cb3f/attachment.html>
Loading...