[opencms-dev] Writing a CmsProperty that doesnt exist or is empty
Manuel Wallnoefer
manuel.wallnoefer at msk-informatik.at
Fri Jul 14 16:36:39 CEST 2006
Hi all,
in my code i have a CmsProperty object called "prop".
If the object is the null object I want to create a new one and write a
value into it.
But now the problem is that I always get Exception:
Error writing property "SchlagwortIds" on resource "/myresource/"
If I open the file manually and write a value into the property field it
works.
Also when I open the file properties manually an does't write a value in the
field it works too!
I'm very confused now!!
My code looks like this:
if (toDo.equalsIgnoreCase("add")) {
CmsObject cmsObj = cms.getCmsObject();
CmsResource r = cmsObj.readResource(file);
CmsProperty cmsProp =
cmsObj.readPropertyObject(r,"SchlagwortIds", false);
String ids = "";
if (cmsProp != CmsProperty.getNullProperty()) {
ids = cmsProp.getValue().toUpperCase();
StringBuffer buffer = new StringBuffer(ids);
buffer.append(schlagwort);
buffer.append("#");
ids = buffer.toString();
cmsProp.setValue(ids, "SchlagwortIds");
cmsObj.writePropertyObject(file, cmsProp);
} else {
StringBuffer buffer = new StringBuffer(ids);
buffer.append(schlagwort);
buffer.append("#");
ids = buffer.toString();
//out.println("ids:"+ids);
CmsProperty prop = new CmsProperty(null,
null,null, true);
prop.setName("SchlagwortIds");
prop.setStructureValue(ids);
prop.setAutoCreatePropertyDefinition(true);
prop.setValue(ids, "SchlagwortIds");
cmsObj.writePropertyObject(file, prop);
}
}
Thx for help !!!
~manuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20060714/5db6e53b/attachment.htm>
More information about the opencms-dev
mailing list