java - How can I read contents from Spring Messagesource within a Enum? -


I have an anime that has three different status types These conditions should be displayed and displayed in emails sent to users String with occurrences is stored in messages. Read the properties (using the spring class org.springframework.context.messageSource's implementation). It works well in the normal spring controller. However, I like to receive the "performance status" within the enum (containing the logic in one place).

However, message resources in the form of the following code do not seem to automatically wiring, to work, the source is always empty as a message.

  public enum InitechStatus {OPEN ("open"), closed ("off"), broken ("broken"); The name of the public last string; @ Removed private message source message source; InitechStatus (string name) {this.name = name; } @ Override public string toasting () {String display StatusString = messageSource.getMessage ("Page. Systemadministration.broadcastmail.status." + This.name, null, Locale.ENGLISH); ReturnStatusStatusString; }}  

How can I use an Auto Wired Processor (or is there any other way of achieving this) within an ammunition?

I got a solution from this answer: SO:

This is my java.util. To use ResourceBundle, read the message in this way:

  Public Enumen Intextatus {Open ("Open"), Off ("Closed"), Broken ("Broken"); Private Static Resources Bundle ResourcesBandle = ResourceBundle.getBundle ("Message", Local. NGLIISH); The name of the public last string; @ Removed private message source message source; InitechStatus (string name) {this.name = name; } @ Override public string toasting () {String display StatusString = resourceBundle.getString ("Page. Systemadministration.broadcastmail.status." + This.name); ReturnStatusStatusString; }}  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -