cancel
Showing results for 
Search instead for 
Did you mean: 

Widgets: How to retrieve a property on a pointed object?

promanov_
Star Contributor
Star Contributor

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.

8 REPLIES 8

Anahide_Tchertc
Elite Collaborator
Elite Collaborator

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.

Hi,

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...

thanks, that's exactly what I need. However, it doesn't seem to be working, got nothing displayed.

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.

OK for the EL syntax, thanks.

promanov_
Star Contributor
Star Contributor

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 elements: the first works and the second doesn't. "layoutValue" from your example ddn't work, "data" instead works fine on the simple first binding.

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.