Skip to content

Add MessageResolver#15

Open
megascus wants to merge 1 commit into
eclipse-ee4j:mainfrom
megascus:main
Open

Add MessageResolver#15
megascus wants to merge 1 commit into
eclipse-ee4j:mainfrom
megascus:main

Conversation

@megascus

Copy link
Copy Markdown

This is regarding the issue I previously reported on the mailing list here:
https://www.eclipse.org/lists/mvc-dev/msg00108.html

Note: AI was used to assist with this fix.

Summary of Changes

I have modified krazo-thymeleaf to load messages.properties directly from the root of the classpath. The location can be customized using org.eclipse.krazo.thymeleaf.messages.basename.
megascus@9ef7efb#diff-0de5e3301051e2ddac61cc1ea8b2dcdaa84c4a4562197524afd487c89dfd26b2R50-R56

This behavior mimics the default behavior of Thymeleaf when integrated with Spring.
The only difference lies in how the Order is configured:
In Spring's MessageResolver, they overwrite the default StandardMessageResolver by not specifying any Order, and then call StandardMessageResolver internally from within Spring's MessageResolver. However, to avoid any potential licensing issues, I implemented this using a different approach.
https://github.com/thymeleaf/thymeleaf-spring/blob/3.1-master/thymeleaf-spring6/src/main/java/org/thymeleaf/spring6/messageresolver/SpringMessageResolver.java

Additionally, extra messages can now be loaded using CDI:
megascus@9ef7efb#diff-7d895401f3946256e9e81972a7e43f20f1e1f412f3e45f5aca5023a6c86b3cfaR59
megascus@9ef7efb#diff-e4949bcf610db73a23d092f64a98472ef44c99084ee3be2d402f93474f1e89b5

Future Considerations

Ideally, this logic should be integrated into Krazo's core resource access mechanism so that other view engines can access messages in a similar manner. However, I haven't gone that far with this implementation yet.

I would really appreciate it if you could review and merge this PR.

@pzygielo

This comment was marked as resolved.

@ivargrimstad

Copy link
Copy Markdown
Member

I updated the Jenkinsfile with the changes in the main branch. Please rebase your branch and see if the job runs

Provide how to change MessageResolver.
@megascus

Copy link
Copy Markdown
Author

Thanks for the fix. It's working now!

@megascus

Copy link
Copy Markdown
Author

Hi, I noticed that some constants are missing/unextracted.

In core Krazo, properties constants are defined in org.eclipse.krazo.Properties. However, since these are specific to Krazo core, adding extension-specific constants to this class doesn't seem like the best approach.

I would like to adopt one of the following options. Which one would be preferred?

  1. Create org.eclipse.krazo.ext.thymeleaf.Properties which extends org.eclipse.krazo.Properties
  2. Treat them as part of DefaultTemplateEngine behavior and define them in DefaultTemplateEngineProducer
  3. Localize them further, treating them as part of MessageResolver behavior and defining them in DefaultMessageResolverProducer

Personally, I prefer Option 1.

// And I noticed that I should change org.eclipse.krazo.thymeleaf.messages.basename property to org.eclipse.krazo.ext.thymeleaf.messages.basename .
// megascus@9ef7efb#diff-0de5e3301051e2ddac61cc1ea8b2dcdaa84c4a4562197524afd487c89dfd26b2R51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants