[opencms-dev] creating instances of structured content programmatically
Paul-Inge Flakstad
flakstad at npolar.no
Wed Jan 5 15:53:32 CET 2011
Hi Eel,
An XPath is used for identifying an XML element.
A property is not part of any XML element (although a mapping may exist, telling the system to copy the XML element's value into a property), so an XPath is not something you should consider for this task.
Instead, try writing your property value simply by using CmsObject:
http://www.opencms.org/javadoc/core/org/opencms/file/CmsObject.html#writePropertyObject(java.lang.String,%20org.opencms.file.CmsProperty)
I hope this helps you! :)
Cheers,
Paul
> -----Original Message-----
> From: opencms-dev-bounces at opencms.org
> [mailto:opencms-dev-bounces at opencms.org] On Behalf Of eelboy at aol.com
> Sent: 4. januar 2011 17:30
> To: opencms-dev at opencms.org
> Subject: Re: [opencms-dev] creating instances of structured
> content programmatically
>
> Harald,
>
> Do you know of a way to also set property values using the Helper
> object? I've been trying to find out what the XPath parameter might
> look like... and I've tried a few things, but it doesn't seem to work.
>
> thanks for any help (again!)
> eelboy
>
> On 12/22/2010 7:03 AM, Brabenetz, Harald wrote:
> > 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]/InputFieldIt
> em[1]/FieldItemText[1]", "Item text");
> >
> helper.setValue("InputFieldBlock/InputField/InputFieldItem/Fie
> ldItemValue", "DummyValue");
> > // create 4 nested Content nodes
> > for (int i = 0; i< 4; i++) {
> > String node =
> helper.addNestedContent("InputFieldBlock[2]/InputField[1]/Inpu
> tFieldItem");
> > 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.
> >
> > _______________________________________________
> > 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
More information about the opencms-dev
mailing list