• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to load a properties file from JSP  RSS feed

 
Gopinadh Upadhyayula
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using JPF controllers. Already, i am loading a properties file in the controller(using annotations @Jpf.Controller(messageBundles = { @Jpf.MessageBundle(bundlePath = "validation.validator.Messages") },). I have a problem. Depending on one of the request variables, i need to load different properties files. All these property files have same keys, but with different messages. I need to take the user to different sites(though internally, the backend logic remains same...Look and feel of the front end along with messages to be shown change to make the users feel they are being directed to a different site).

I am thinking of loading the properties file from the JSP when the user logs in first time from login page so that these properties are available until the session expires & not read the properties file in Controller. What is the best way to do it?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66260
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no idea what JPF is, but whatever it is, loading things in a JSP is not the right answer. JSPs are for generating views, not processing and not business.
 
Gopinadh Upadhyayula
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jpf.Controller is an annotation used by netui pageflow. This can be treated like our regular servlets.
 
Gopinadh Upadhyayula
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found an alternative to fix this issue. It is kind of a hack to Internationalization feature.

In the JSP, use a Locale object (using language constructor  Locale locale = new Locale(“TEST”)) to be put in session.

<%
Locale locale = new Locale(“TEST”);
request.getSession().setAttribute(“locale”, locale);
%>

Have the page flow controller use the below annotation to mention about properties file.

@Jpf.Controller(messageBundles = { @Jpf.MessageBundle(bundlePath = "com.validator.Messages") })

When reading the errors using netui tag, mention the session attribute name for the locale (This tag looks for session attribute only using the locale name).
<netui:errors locale="locale"/>

And have the proper message resource properties file name Messages_TEST.properties in the com.validator path under “src” in the web project.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!