How can I access messages bundle from java code to get message according to current locale?
I tried using @ManagedProperty like below:
@
In addition to BalusC's answer:
Since JSF 2.3 it is also possible to inject a resource bundle defined in faces-config.xml without the use of a producer method. There is a new annotation javax.faces.annotation.ManagedProperty (note it is in the ...annotation package, not the ...bean package) that works with @Inject:
// ...
import javax.faces.annotation.ManagedProperty;
// ...
@Named
@SessionScoped
public class UserBean implements Serializable {
// ...
@Inject
@ManagedProperty("#{msg}")
private ResourceBundle bundle;
// ...
}