Convert currentDocumentIncomingRelations into DocumentModel


I've created a new type of document in Studio to store a set of pictures. To store these pictures I simply create relations between my documents and the pictures. I'd like to display the thumbnails of the pictures referenced but I don't know how to pass the variable.

Here's what I tried :

<h:dataTable var="statement"
    rowClasses="dataRowEven, dataRowOdd"
    columnClasses="relationPredicateColumn, relationObjectColumn, relationCommentColumn, relationCommentColumn, relationCommentColumn, relationActionsColumn">

        <f:facet name="thumbnail">
            <h:outputText value="image" />
            value="#{nxd:fileUrl('downloadPicture', statement , 'Thumbnail:content', currentDocument.dublincore.modified)}" />

Of course I get an error

Cannot convert org.nuxeo.ecm.platform.relations.web.StatementInfoImpl@a23ec4 of type class org.nuxeo.ecm.platform.relations.web.StatementInfoImpl to interface org.nuxeo.ecm.core.api.DocumentModel

Do you know how I could display the thumbnails of the pictures relations ?

Thank you


0 votes

2 answers



The “statement” variable represents the relation. As you're displaying incoming relations, you probably want to use the statement subject instead of its object (that should be a representation of the current document). So you can try something like:

<h:graphicImage value="#{nxd:fileUrl('downloadPicture', statement.subjectInfo.documentModel, 'Thumbnail:content', 'image title here')}" />

Be careful if you also display outgoing relations: the statement object might not represent a document (as relations can also point to a literal, or an URI that does not represent a document). There is API on the node to check for that, there is also another API to check that the document can be accessed by the current user.

Also note that the JSF function nxd:fileUrl is waiting for the image title as a last argument, so using a date with expression currentDocument.dc.modified is not a good idea.

Taking example on default templates displaying relations might help, see and also

1 votes

This works fine.

Thank you very much for your answer.

0 votes