[MGNLUI-2902] Stacktrace in dialog by failed Long converting when field is required Created: 15/May/14  Updated: 13/Jan/18  Resolved: 13/Jan/18

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

Type: Bug Priority: Major
Reporter: Frank Sommer Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File long-required.png    
Issue Links:
duplicate
duplicates MGNLUI-3753 When a required for field encounters ... Closed
relation
is related to MGNLUI-1855 Default converter doesn't work with L... 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:
Visible to:
Oliver Emke, Rainer Blumenthal

 Description   

You can see the stacktrace in a dialog with the following requirements:

  1. text field marked as required and of type Long
  2. open the dialog and type some characters into the field
  3. on saving a stacktrace will be shown in the dialog

See screenshot



 Comments   
Comment by Roman Kovařík [ 16/May/14 ]
Caused by: com.vaadin.data.util.converter.Converter$ConversionException: Could not convert value to Long
	at com.vaadin.ui.AbstractField.convertToModel(AbstractField.java:748)
	at com.vaadin.ui.AbstractField.convertToModel(AbstractField.java:725)
	at com.vaadin.ui.AbstractField.setValue(AbstractField.java:508)
	... 103 more
Caused by: com.vaadin.data.util.converter.Converter$ConversionException: Could not convert 'dwa' to java.lang.Long
	at com.vaadin.data.util.converter.AbstractStringToNumberConverter.convertToNumber(AbstractStringToNumberConverter.java:83)
	at info.magnolia.ui.form.field.factory.AbstractFieldFactory$StringToLongConverter.convertToModel(AbstractFieldFactory.java:318)
	at info.magnolia.ui.form.field.factory.AbstractFieldFactory$StringToLongConverter.convertToModel(AbstractFieldFactory.java:313)
	at com.vaadin.data.util.converter.ConverterUtil.convertToModel(ConverterUtil.java:156)
	at com.vaadin.ui.AbstractField.convertToModel(AbstractField.java:745)
	... 105 more

Comment by Federico Grilli [ 18/Aug/14 ]

solved by MGNLUI-1855

Comment by Jaroslav Simak [ 13/Jan/18 ]

This is still an issue (at least on 5.6+). Haven't tried 5.5 or older.
Reason why this exception occurs only if field is required is because fields are set to commit invalid data to the datasource.info.magnolia.ui.form.field.factory.AbstractFieldFactory#setConstraints.

        // Set Required
        if (definition.isRequired()) {
            field.setInvalidCommitted(true); //  this is the culprit
            field.setRequired(true);
            field.setRequiredError(definition.getRequiredErrorMessage());
        }

field.setInvalidCommitted(true); - errors are gone after setting it to false in my custom field.

EDIT: issue that caused the this regression: MGNLUI-2774

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