01-26-2017 12:15 PM
I am facing some problems and questions with facets.
I have defined a schema called 'InvoiceSchema' and a facet called 'InvoiceFacet' and assigned the schema to the facet, like this:
I enabled the facet for the document type 'File'
and I change the edit and view layout to display the fields:
Back in the JSF UI and after the update, the fields get displayed in the view and edit layouts. However, when I edit the value, they don't get stored.
This is the view layout after saving the document. The confirmation message tells me that saving was successful, and values that I enter in other fields get updated just fine. Only the fields of my InvoiceSchema don't get saved.
When I export the file as xml, I only see this in it:
<facet>InvoiceFacet</facet>
but I don't see the fields that I defined for my InvoiceSchema (like Amount, InvoiceDate, RecordId) anywhere in the xml.
Interestingly, if I don't use a facet that has my schema assigned, but add the schema directly to the File type, the problem does not exist and the values get saved. Looks like a bug to me?! Unfortunately I don't have a Jira account yet in order to submit it.
Hello Bertrand,
thanks for your reply. I understood the explanation you gave above about the registry as well as the xml extension points. Not sure though where I am supposed to define the schema itself (in my case, the 'InvoiceSchema').
Did I do it right via "Studio > Content Model > Schemas" or should I register the schema via "Studio > Settings > Registries > Document Schemas", or both. When I register the schema via the latter as well (additionally to having it defined under the Content Model > Schemas menu), then I get some validation errors like this:
saying "Invalid name 'InvoiceSchema' for a schema: this schema already exists in the default application". So I removed the schema from the registry again. (From what I understand, I shouldn't need to register the schema in the registry anyway, since what I define under "Content Model" should be known both by my local Nuxeo instance (since it's part of my package) as well as the Studio.)
So, I assume it's sufficient to just define it under the "Studio > Content Model > Schemas":
I tried it out and deployed that package. But still the properties don't get stored when I save the document.
Looking at my package jar that I deployed, the xml extension and the schema including the properties are all included.
Checking the log, I see this:
2017-01-30 18:19:59,277 WARN [http-bio-0.0.0.0-8080-exec-17] [org.nuxeo.ecm.platform.el.DocumentModelResolver] org.nuxeo.ecm.core.api.model.PropertyNotFoundException: InvoiceSchema:InvoiceDate 2017-01-30 18:19:59,277 WARN [http-bio-0.0.0.0-8080-exec-17] [org.nuxeo.ecm.platform.el.DocumentModelResolver] org.nuxeo.ecm.core.api.model.PropertyNotFoundException: InvoiceSchema:Amount 2017-01-30 18:19:59,278 WARN [http-bio-0.0.0.0-8080-exec-17] [org.nuxeo.ecm.platform.el.DocumentModelResolver] org.nuxeo.ecm.core.api.model.PropertyNotFoundException: InvoiceSchema:RecordId
Let's say I have a facet that is not assigned to all documents (= not as described in problem 1), but only to some, for example when the facet gets assigned dynamically via an automation, and the facet has a schema with some additional property fields assigned. How can I show these fields in the view and edit layout based on whether the document has this facet or not? I cannot find this option in the Studio. In Studio, I can only define the view and edit layouts fixed for a certain document type, but I cannot give any conditions, such as 'if the document has facet x applied'. How to solve this?
01-30-2017 08:34 AM
Hello Mathias,
Problem #1: To add a facet and use it in Studio, there are two things to do:
You did step #2. That means Studio will behave as if the facet exists in Nuxeo Platform, which is why everything works smoothly until you deploy your config. But as you are missing step #1, the facet doesn't actually exist in Nuxeo Platform!
To fix this, in Nuxeo Studio you need to declare the facet in the Advanced Settings > XML Extensions menu (make sure to replace with the appropriate facet and schema values of course):
<!-- This makes my facet available in Nuxeo Platform, then I can declare it in the registries -->
<extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
<facet name="MyFacet">
<schema name="MySchema"/>
</facet>
</extension>
The reason Nuxeo Studio does not create the corresponding extension automatically when declaring a facet in the registries is because it could be contributed from somewhere else: another bundle or Studio project for instance. However, an improvement could be to better inform users and / or offer to do it => I'll create a ticket for that.
Problem #2:
In a layout, a widget's mode (edit, read only, hidden) can be changed depending on a custom condition. I may advise you to have a look at the documentation explaining how to control the display mode of a widget.
In your example, the condition to use should be something like:
#{currentDocument.hasFacet('MyFacet') ? 'edit' : 'hidden'}
The currentDocument variable relates to a DocumentModel object, so you can easily add further conditions and not only check for the facet.
-- edit -- Improvement ticket created: https://jira.nuxeo.com/browse/NXS-3810 Thanks for the feedback! 🙂
01-30-2017 08:34 AM
Hello Mathias,
Problem #1: To add a facet and use it in Studio, there are two things to do:
You did step #2. That means Studio will behave as if the facet exists in Nuxeo Platform, which is why everything works smoothly until you deploy your config. But as you are missing step #1, the facet doesn't actually exist in Nuxeo Platform!
To fix this, in Nuxeo Studio you need to declare the facet in the Advanced Settings > XML Extensions menu (make sure to replace with the appropriate facet and schema values of course):
<!-- This makes my facet available in Nuxeo Platform, then I can declare it in the registries -->
<extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
<facet name="MyFacet">
<schema name="MySchema"/>
</facet>
</extension>
The reason Nuxeo Studio does not create the corresponding extension automatically when declaring a facet in the registries is because it could be contributed from somewhere else: another bundle or Studio project for instance. However, an improvement could be to better inform users and / or offer to do it => I'll create a ticket for that.
Problem #2:
In a layout, a widget's mode (edit, read only, hidden) can be changed depending on a custom condition. I may advise you to have a look at the documentation explaining how to control the display mode of a widget.
In your example, the condition to use should be something like:
#{currentDocument.hasFacet('MyFacet') ? 'edit' : 'hidden'}
The currentDocument variable relates to a DocumentModel object, so you can easily add further conditions and not only check for the facet.
-- edit -- Improvement ticket created: https://jira.nuxeo.com/browse/NXS-3810 Thanks for the feedback! 🙂
01-30-2017 10:31 AM
Hello Bertrand,
01-30-2017 01:43 PM
[Bertrand Chauvin](https
02-08-2017 12:41 PM
I spawned a new Nuxeo docker container and the problem with the properties of my custom facet not being saved is gone. Basically using the same project configuration from the Studio. Maybe something was broken with the initial instance.
02-08-2017 01:22 PM
[Bertrand Chauvin](https
02-08-2017 01:27 PM
Nevermind, "Generic" is the correct widget to use... got it working now. Thanks for your help.
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.