cancel
Showing results for 
Search instead for 
Did you mean: 

Access a property of type d:content

laurent1050
Champ in-the-making
Champ in-the-making
Hi,

I've created an aspect with a property of type d:content.
I've applyed this aspect to all my folders, and I'm now able in Share to add an html description to all my folders. Great !

<aspect name="poste:descriptionable">
   <title>Rich description of a folder</title>
   <properties>
      <property name="poste:richDescription">
         <title>Rich description</title>
         <description>Rich description of a folder</description>
         <type>d:content</type>
         <protected>false</protected>
         <mandatory>false</mandatory>               
      </property>
   </properties>
</aspect>

Now I want to access this property in a webscript :

var currentFolder = search.findNode(currentNodeRef);
if (currentFolder.hasAspect("poste:descriptionable")) {
   model.desc = currentFolder.properties["poste:richDescription"];
}

In my ftl, when I try ${desc}, the result is org.alfresco.repo.jscript.ScriptNode$ScriptContentData@1f8c9e8, but I don't know how to access the content of this property.

How can I show the content of my property "poste:richDescription" (it's an HTML description) in my ftl ?

Any help is welcome,

Laurent
3 REPLIES 3

laurent1050
Champ in-the-making
Champ in-the-making
I've tried :
${desc.content} return ""
${desc.url} return "http://localhost:8080/alfresco/d/d/workspace/SpacesStore/47fd50fd-074c-443a-8523-ae654da5f4a4/201104..."
This url return in FireFox

The node's content is missing: 
   node: workspace://SpacesStore/47fd50fd-074c-443a-8523-ae654da5f4a4
   reader: null 
Please contact your system administrator.

I've now tried "http://localhost:8080/alfresco/d/d/workspace/SpacesStore/47fd50fd-074c-443a-8523-ae654da5f4a4/201104..." in FireFox and I get the content of my property poste:richDescription  :shock:

So my webscript became
var currentFolder = search.findNode(currentNode);
if (currentFolder.hasAspect("poste:descriptionable")) {
   model.desc = currentFolder.content;
}

But what will happened if I've two properties of type d:content for on the same folder ????

laurent1050
Champ in-the-making
Champ in-the-making
Finally, the problem comes from : org.alfresco.repo.forms.processor.node.ContentModelFormProcessor.processPropertyPersist()

If the property is of type cm:content, processContentPropertyPersist is called :
else if (propDef.getDataType().getName().equals(DataTypeDefinition.CONTENT))
{
    processContentPropertyPersist(nodeRef, fieldData, propsToPersist, data);
}
And in processContentPropertyPersist(), a writer is opened on the current node :
this.contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true)
But there is no use of the QName of the property calculated in processPropertyPersist(…)
String qNamePrefix = m.group(1);
String localName = m.group(2);
QName fullQName = QName.createQName(qNamePrefix, localName, namespaceService);
So every property of type d:content is saved at the same place despite the QName of the property.

Finally, I've used a property d:text instead of d:content, and it's correct.

I hope it's clear….

Laurent

laurent1050,

Did you ever try using the property type d:any?

I'm in a situation where I need to store more data than d:text will allow (apparently a constraint imposed by database implemented).  Tried d:content in vain.  Just about to give d:any a go.

I'll let you know what I find.

Ben