[opencms-dev] Creating categories from API and select them in CategoryWidget

Sandrine Prousteau s.prousteau at eurelis.com
Mon Nov 22 16:07:45 CET 2010


Hi all,

I've got a problem creating categories with API.

I want to create categories folders with java in jsp'code, with this :

String uri = "/_categories/onetheme/mycategory/";
if(!cmsAdmin.existsResource(uri,CmsResourceFilter.DEFAULT_FOLDERS)){
CmsResource folder = cmsAdmin.createResource(uri,0);
cmsAdmin.lockResource(uri);
cmsAdmin.writeResource(folder);
cmsAdmin.writePropertyObject(uri, new CmsProperty("Title", mytitle,
null));
}

The folder is created to /sites/default/_categories/onetheme/
mycategory/ with his title. Good.

I have a custom xmlcontent, with CategoryWidget fields pointing to the
category themes, with xsd like this :

<xsd:element name="OneThemeCategory" type="OpenCmsString"
minOccurs="0"/>
...
<layout element=" OneThemeCategory " widget="CategoryWidget" />

If I don't have creating category folders under the themes (the themes
are empty), I can select category themes in my xmlcontent. If I have
created category folder under themes, with or without publishing them, I
can't select themes categories anymore: The list of themes categories
appear, but when I select one, it says I've selected nothing and don't
want to register...

I don't understand.
Please help!



More information about the opencms-dev mailing list