[opencms-dev] creating instances of structured content programmatically

Brabenetz, Harald harald.brabenetz at bearingpointconsulting.com
Wed Dec 22 13:03:58 CET 2010


There are small HelperClasses on sourceforge (Version 1.0):
http://bp-cms-commons.sourceforge.net/m2site/infonova/modules/at.infonova.opencms.modules.commons/1.0/

-----------------------------------------------------
// create a Cms File.
 CmsFile file = XmlContentEditorHelper.createFile(
      getCmsObject(), "/test/testHappyPath.xml", "onlineForm");

 // create Helper
 XmlContentEditorHelper helper = new XmlContentEditorHelper(getCmsObject(), file, locale);

 // edit XML Content
 helper.setValue("Title", "Some test Message");
 helper.setValue("InputFieldBlock[1]/Headline", "A Dummy Headline");
 helper.setValue("InputFieldBlock[1]/InputField[1]/InputFieldItem[1]/FieldItemText[1]", "Item text");
 helper.setValue("InputFieldBlock/InputField/InputFieldItem/FieldItemValue", "DummyValue");
 // create 4 nested Content nodes
 for (int i = 0; i < 4; i++) {
     String node = helper.addNestedContent("InputFieldBlock[2]/InputField[1]/InputFieldItem");
     helper.setValue(node + "/FieldItemText", "Item text " + i);
     helper.setValue(node + "/FieldItemValue", "DummyValue " + i);
 }

 // save XML-Content.
 helper.writeContent();
-----------------------------------------------------

Best regards,
Harald

-----Original Message-----
From: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Paul-Inge Flakstad
Sent: Mittwoch, 22. Dezember 2010 03:40
To: The OpenCms mailing list
Subject: Re: [opencms-dev] creating instances of structured content programmatically

Hey Eel,

Sebastian Himberger has made available some example code for manipulating structured content programatically: http://goo.gl/VA6Wx

I'm sure you'll find it very useful. Although his blog post is a couple of years old by now, the code should still be applicable.

Best regards,
Paul
________________________________________
Fra: opencms-dev-bounces at opencms.org [opencms-dev-bounces at opencms.org] på vegne av eelboy at aol.com [eelboy at aol.com]
Sendt: 21. desember 2010 16:41
Til: The OpenCms mailing list
Emne: [opencms-dev] creating instances of structured content    programmatically

Hi,

Does anyone have any examples (or know of any online documentation) of
how I might be able to generate instances of structured xml content via
java code?

Thanks,
eelboy

_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev

_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev

INFONOVA GmbH
Sitz: Unterpremstätten bei Graz
Firmenbuchgericht: Landesgericht für ZRS Graz
Firmenbuchnummer: FN 44354b

The information in this email is confidential and may be legally privileged. If you are not the intended recipient of this message, any review, disclosure, copying, distribution, retention, or any action taken or omitted to be taken in reliance on it is prohibited and may be unlawful. If you are not the intended recipient, please reply to or forward a copy of this message to the sender and delete the message, any attachments, and any copies thereof from your system.


More information about the opencms-dev mailing list