[opencms-dev] Modify container page programatically

Dudu Zoltan dzoltan at gmail.com
Fri Aug 22 17:19:08 CEST 2014


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: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20140822/0151cb3f/attachment.htm>


More information about the opencms-dev mailing list