Widgets: How to retrieve a property on a pointed object?
Hello all,
May be my question has an obvious answer I did overlooked:
In Case Management model CaseLink object points the owner Case document by storing it's Id (caseDocumentId attribute). In the listing widget of case links in Inbox mailbox, I'd like to retrieve and display a property coming from the owner Case.
Can I achieve this in XML using the Id of the Case? Or do I need code a custom widget for that?
Thanks in advance.
Hi,
You'll need some logic to retrieve the document from its id (taking example on the document suggestion widget templates for instance) and then you'll be able to retrieve the property.
From 5.6, it's possible to use EL expressions in “field” XML elements, so the answer is yes. If you're using a lower version, you'll probably have to use a custom widget template.
Anyway you can use something like: <pre> <code> <field>#{docSuggestionActions.getDocumentWithId(layoutValue.theSchema.theFieldHoldingTheId).theOtherSchema.thePropToDisplay}</field> </code> </pre>
Layout doc is at http://doc.nuxeo.com/x/OoAO but i still need to add a chapter about field bindings…
we're actually using jboss EL (that adds features to call methods with parameters) but that's pretty straight-forward once you know EL.
other than that, we just defined a custom EL resolver for documents so that we can use a syntax #{doc.schema.field} to easily retrieve property values from documents.
the doc i need to write will explain how information given in the "field" tag is transformed into an EL expression. if you're already using an EL expresion as value, there will be no transformation.
Thanks Anahide for your support and the detailed answers. However, I still cannot make it work:
Here is my layout contrib:
<extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager" point="layouts">
<layout name="cm_inbox_caselink" override="true">
<templates>
<template mode="any">
/layouts/layout_listing_ajax_template.xhtml
</template>
</templates>
<properties mode="any">
<property name="showListingHeader">true</property>
<property name="showRowEvenOddClass">true</property>
</properties>
<columns>
<column>
<properties mode="any">
<property name="useFirstWidgetLabelAsColumnHeader">true</property>
</properties>
<widget>listing_reference</widget>
</column>
...
Here is the widget definition:
<widget name="listing_reference" type="text">
<labels>
<label mode="any">label.casemanagement.document.reference</label>
</labels>
<translated>true</translated>
<fields>
<field>data.cslk.caseDocumentId</field>
<field>#{docSuggestionActions.getDocumentWithId(data.cslk.caseDocumentId).case.reference}</field>
</fields>
</widget>
I put here both
case.reference is a new property I've added overriding case schema, but I've also tested with dc.title, no difference. I've made a handful of tests, tested to retrieve the pointed CaseItem object instead of Case etc.. There is no error / java exception raised but the result is empty.
Please see what I'm doing wrong.