[MGNLUI-4193] Conflict between jcrName and setNodeName() Created: 18/Apr/17  Updated: 08/Mar/21  Resolved: 08/Mar/21

Status: Closed
Project: Magnolia UI
Component/s: None
Affects Version/s: 5.7
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Jan Haderka Assignee: Unassigned
Resolution: Won't Fix Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
causality
caused by MGNLUI-4081 readOnly checkbox doesn't appear in J... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

When setting names of the newly created nodes programatically there is a conflict if jcrName is also configured (e.g. you want to show your editors real name of the node, but in read only mode so that they can't change it and it is set according to predefined rules).

To reproduce (in contacts app):
#1 observe that upon creation of new contact, node is saved with name consisting of first letter of first name and full last name
#2 in editor form add extra text field with name=jcrName
#3 try to create new contact leaving newly created jcrName field empty
#4 observe failure to save the dialog (btw save button stays blocked even after correcting the error. not very nice)
#5 try to create new contact filling newly created jcrName field with some value (different than normally autogenerated value for contact node name)
#6 observe that upon saving of the contact, value set in jcrName field is discarded and replaced with autogenerated value.

Expected behavior:
Either autogeneration always wins and thus it should not be required to fill such field with a value
or
existence of field (in rw mode) takes precedence over generated value and thus should not be overwritten.

In RO mode on the other hand (i.e. when field has set readOnly==true) it's value should be only displayed and not considered when saving the dialog at all (i.e. autogenerated node name mechanism wins).

Also when saving fails, it fails with very counterproductive error:

info.magnolia.ui.api.action.ActionExecutionException: javax.jcr.PathNotFoundException: firstName
	at info.magnolia.ui.form.action.SaveFormAction.execute(SaveFormAction.java:92)
	at info.magnolia.ui.api.action.AbstractActionExecutor.execute(AbstractActionExecutor.java:62)
        ....


 Comments   
Comment by Mikaël Geljić [ 19/Apr/17 ]
  • AbstractJcrAdapter#updateProperties skips read-only properties upon saving
  • since MGNLUI-4081, properties are only marked read-only if the underlying datasource is not writable (e.g. if node is a version); no longer according to the field definition. If the field definition is read-only, then only the field is made read-only, not the property.

Ignoring "jcrName" property in the aforementioned adapter method is not an option, as this would break rename dialogs.
(on the other hand, one could say rename dialogs should not use adapters, but a simpler Vaadin form—likely w/ PropertysetItem on V7—plus a specific save-action explicitly doing a JCR session#move—instead of relying on adapters for that).

Generated at Mon Feb 12 09:14:12 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.