Open JannikBirn opened 5 months ago
Why not do this in a @WebListener somewhere?
Field objectMapperFld = JsonUtils.class.getDeclaredField( "objectMapper" );
objectMapperFld.setAccessible( true );
ObjectMapper objectMapper = (ObjectMapper) objectMapperFld.get( null );
Describe your motivation
I'm using the new
ReactAdapterComponent
and wan't to read the sate of a value. The type of the field is an object with some optional fields. I would like to represent these optional fields withjava.util.Optional
in the Java class representation. Because theReactAdapterComponent
usescom.vaadin.flow.internal.JsonUtils
im unable to register the necessaryJdk8Module
fromcom.fasterxml.jackson.datatype:jackson-datatype-jdk8
to theObjectMapper
used to deserialize the JSON.Describe the solution you'd like
The best solution would be to make the
com.vaadin.flow.internal.JsonUtils
ObjectMapper
somehow accessible so it would be possible to add Custom Modules. In the Hilla docs is a section about how to access theObjectMapper
in Hilla applications the same solution could be applied to Flow (https://vaadin.com/docs/latest/hilla/lit/reference/type-conversion#json-object-mapper).An alternative solution would be to make the
protected static <T> T readFromJson
insideReactAdapterComponent
non-static to easily override the method and redirect the parsing to my ownObjectMapper
.Describe alternatives you've considered
The alternative for me would be a workaround where i have to implement basically all methods of the
ReactAdapterComponent
myself.Additional context
I'm currently using the Vaadin Flow 24.5.0.alpha4, but i think that this problem is already existing in the 24.4.3 release.