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.

0 votes

2 answers




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.

1 votes

Hi, Thanks for the quick answer. Yes, I'm using 5.6. Could you please give me a sample or refer to the doc?

On second thought, it would be wiser to define a widget template anyway, so that you can handle use cases where target document is not found, undefined, etc…

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…


thanks, that's exactly what I need. However, it doesn't seem to be working, got nothing displayed. How can I debug such a call (docSuggestionActions.getDocumentWithI() )? Thanks.

how can I learn moe about the syntax of EL expressions? haven't found much in the Nuxeo EP doc. Is that the part you are still to add?

if you're not acquainted with standard EL, reading standard doc is a start.

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.


OK for the EL syntax, thanks. It's rather the layout context variables use like layoutValue, data, document etc.. that is not clear for me.

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">
        <template mode="any">
      <properties mode="any">
        <property name="showListingHeader">true</property>
        <property name="showRowEvenOddClass">true</property>
          <properties mode="any">
            <property name="useFirstWidgetLabelAsColumnHeader">true</property>

Here is the widget definition:

<widget name="listing_reference" type="text">
            <label mode="any">label.casemanagement.document.reference</label>

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.

0 votes