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

Add an optional 'prefix' property to DefaultMessageCodesResolver [SPR-2875] #7562

Closed
spring-issuemaster opened this issue Nov 25, 2006 · 2 comments
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Nov 25, 2006

Chris Lee opened SPR-2875 and commented

Add an optional 'prefix' property to DefaultMessageCodesResolver that allows for a system-enforced convention for validation failure messages codes. This is important on large i18n projects (with thousands of message codes) for providing grouping / context.

To extend the example provided in DefaultMessageCodesResolver (using a prefix of 'validation'):

*  1. try "validation.typeMismatch.user.age"
* 2. try "validation.typeMismatch.age"
* 3. try "validation.typeMismatch.int"
* 4. try "validation.typeMismatch" 

I've attached a sample of how we have accomplished this - having the prefix property would be simpler/cleaner.

Another option to consider would be refactoring the code construction into overridable methods (buildCode(errorCode,objectName,field) and buildCode(errorCode,field), which opens up possibilities beyond the simple addition of a prefix.


Affects: 2.0.1

Attachments:

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Nov 25, 2006

Chris Lee commented

Sample subclass for adding prefix to message codes

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jan 1, 2007

Juergen Hoeller commented

Thanks for the suggestion! I've added a "prefix" property and a "postProcessMessageCode" template method to DefaultMessageCodesResolver.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.