Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not possible to use Spring to override the default RichTextDataConverter #94

Open
willprice76 opened this issue Apr 10, 2018 · 1 comment

Comments

@willprice76
Copy link
Contributor

In order to work around issue #93 we attempted to define our own CustomRichTextDataConverter with the @primary and @component annotations. However, due to the way in which the DXA 2.0 loads the data converters into the GenericSemanticModelDataConverter (using @Autowired on the setConverters method) our custom converter is always overridden by the default.

The setConverters method should reverse sort the set before applying the converters, ensuring that lower priority converters are set first and then overridden by any higher priority converters later.

willprice76 pushed a commit to willprice76/dxa-web-application-java that referenced this issue Apr 10, 2018
…onid_init to develop

* commit 'ad66465765f665deed9a9c79cfa1292eacb908a5':
  TSI-3145 Moved SESSIOND ID initialization to DXA framework
willprice76 added a commit to willprice76/dxa-web-application-java that referenced this issue Apr 10, 2018
…iority is respected when setting data converters
@willprice76
Copy link
Contributor Author

willprice76 commented Sep 6, 2018

Dirty hack while waiting for this fix is to add an onApplicationEvent for context refresh in your custom RichTextDataConvertor:

@Component
@Primary
public class MyRichTextDataConverter extends RichTextDataConverter implements ApplicationListener<ContextRefreshedEvent> {

    public void onApplicationEvent(ContextRefreshedEvent event) {
        GenericSemanticModelDataConverter dataConverter = getContext().getBean(GenericSemanticModelDataConverter.class);
        Set<SemanticModelConverter<?>> converters = new HashSet<>();
        converters.add(this);
        dataConverter.setConverters(converters);
    }
}

alebastrov added a commit that referenced this issue Apr 23, 2021
…rter-overrides

Issue #94: Ensure Spring priority is respected when setting data converters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants