I have just begun to implement the MVC design pattern in my projects. All of theese projects supports internationalization and I use ResourceBundles to meet that technique. Now my question is how I should handle theese bundles in an MVC environment? How do they do this in a real world application? I understand the basics so far conserning model, view and controller classes, but I am lost when it comes to internationalization and handling resource bundles. Do the requests to a bundle belong in a Model or a Controller-class and how would it look like in a code sample? Many thanks in advance and thank you for reading!
I see. I have used jsp and servlets before when speaking of web applications - not using jsf however. I am writing standalone applications using swing components though. But I see the point. My first assumption is to create a LanguageController class in which I load the proper locale for the currently selected ResourceBundle when the user hits the different menu items that represents a language, in my menubar. But I don't know how such an operation works in an MVC-wise manner.
In basic JSP/servlets, you'd do the same thing. You'd have a resource backing bean in Application or Session scope (session scope for per-user I18N). You'd still use EL on the View Template (JSP). I think you'd need a useBean tag to make it visible, though. So something like this:
Note that the "#" and "$" notations differ only in that "$" denotes a read-only property value whereas "#" is a property reference used for read/write. JSF, however, normally uses "#" regardless because of historical reasons and because "#" is a superset of "$" anyway.
I haven't done Swing in a while, but the concepts are similar except that since Swing doesn't have a templating facility you have to do it all in code. Android, of course, does that sort of stuff routinely so virtually any Android app will have been set up that way from the beginning.
Sources may include data from the Fakebook Research Foundation with support from Gargle University
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop