[MGNLUI-6375] Remove generic type of default value in ValueBoundProperty Created: 30/Oct/20  Updated: 18/Jun/21  Resolved: 10/May/21

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

Type: Bug Priority: Neutral
Reporter: Aleksandr Pchelintcev Assignee: Martin Haderka
Resolution: Fixed Votes: 0
Labels: VN-Testing
Remaining Estimate: Not Specified
Time Spent: 23m
Original Estimate: Not Specified

Issue Links:
causality
is causing MGNLFORM-336 Boolean fields set with String as def... Closed
dependency
depends upon MGNLUI-6374 Allow to configure the default value ... Closed
documentation
to be documented by MGNLUI-6713 DOC: Update class hierarchy for selec... Closed
supersession
supersedes MGNLUI-6603 defaultValue for preconfigured link f... Closed
supersedes MGNLUI-6755 defaultValue in TextField with type L... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[X]* Affected version filled
Release notes required:
Yes
Documentation update required:
Yes
Date of First Response:
Epic Link: Field default values
Sprint: UI FW 27, UI FW 28
Story Points: 5

 Description   

Currently the default value type in ValueBoundProperty is bound with the presentation type of the field (generic <T>), but it is typically something else (i.e. the model type).

E.g. presentation value of the JCR selects is the Node but the default value is specified as a string.

Symptoms

The problem is most prominent when there is a converter between the model and the presentation types is preset. E.g. this:

field: 
     $type: textField
     type: java.lang.Long
     converterClass: com.vaadin.data.converter.StringToLongConverter
     defaultValue: !!java.lang.Long 0

In the snippet above will cause a CCE for the following reasons:

  • SnakeYAML will read the number as hinted by the tag
  • Map2Bean will resolve the generic default value type (via getter/setter signature and BeanIntrospection)
  • M2B will consequently convert a number to a string and will feed it to the converter chain upon field initialisation, converter will fail.

Solution:

  • Be explicit about the type of the default value (by implementing MGNLUI-6374)?
  • Be more flexible when setting the default value? I.e. in FormPresenter - do not assume that the value is in "model" form, check if the value is already compatible with presentation form. Consider adding presetation type as [pre-configured] definition property? Do we have a use-case for model type property as well?


 Comments   
Comment by Viet Nguyen [ 24/Nov/20 ]

This issue is causing MGNLFORM-336 and also causing configured default value to a boolean value such as true/false does not work. Reference to customer comment in this link for more information.

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