[MGNLUI-6936] Unable to convert String to Long in select fields Created: 03/Nov/21  Updated: 09/Nov/21  Resolved: 09/Nov/21

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

Type: Bug Priority: Major
Reporter: Chris Jennings Assignee: Unassigned
Resolution: Not an issue Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File image-2021-11-03-15-29-20-971.png     Text File stacktrace.txt    
Issue Links:
causality
is causing MGNLUI-6937 DOC: Note for 'type' field property a... Closed
relation
is related to MGNLUI-5471 Allow select fields non-string values... Closed
supersession
is superseded by MGNLUI-6937 DOC: Note for 'type' field property a... 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   

Steps to reproduce

  1.  Define a select field (tested with ComboBoxfield, listSelectField and radioButtonGroupField with an optionListDatasource using longs for option values.
    Example:
comboSelect: 
          label: Select
          $type: comboBoxField
          type: java.lang.Double
          converterClass: com.vaadin.data.converter.StringToDoubleConverter
          datasource: 
            $type: optionListDatasource
            options: 
              - name: one
                label: One
                value: 1
              - name: two
                label: Two
                value: 2
  1. Attempt to make a selection using the dialog

Expected results

The dialog can be saved and the JCR contains Long properties.
The documentation for these fields makes reference to property type and converterClass configuration.

Actual results

On selection, Admin Central shows an error bar and the attached stack trace is logged.

Workaround

None. Dialog can only save string properties.



 Comments   
Comment by Roman Kovařík [ 03/Nov/21 ]

Any reason to define the values as Integers and then using String -> Double conversion instead of:

comboSelect: 
 $type: comboBoxField
 type: java.lang.Double
 datasource: 
 $type: optionListDatasource
   options: 
     - name: one
       value: 1.0
     - name: two
       value: 2.0

?

Comment by Luke Trueman [ 03/Nov/21 ]

Hi rkovarik - I just tried that and it worked. It states in the documentation that you need the converter class though: https://docs.magnolia-cms.com/product-docs/6.2/Templating/Dialog-definition/Field-definition/List-of-fields/Combobox-field.html#_common_simple_field_properties

Should this be updated or have I misunderstood? 

 

Comment by Roman Kovařík [ 04/Nov/21 ]

Good point,

the common properties docu is inherited into all field types but I think this applies only to different text fields. cc akhamis

E.g. in this example:

The optionListDatasource uses OptionLinkConverter by default so we can't use a StringToNumberConverter as there is no String but an Option

Comment by Roman Kovařík [ 09/Nov/21 ]

MGNLUI-6937

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