Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User preferences in Java EE application

I have a growing web application which now needs to be able to store user and system preferences / settings. In the past I've always rolled my own preferences system for web applications but I was wondering what other people do to solve this problem? Are there any preference libraries for web applications that people could recommend?

Ideally user preferences should have a default value which the user can then override. Not all preferences should be exposed to the user though as some will be for things such as the last position of a dialog box.

If I go the roll-my-own route I think it will be a separate preferences table with all the preferences stored as strings converted to their true, primitive, data type as required. e.g. a table something like key,user_key,setting_name,setting_value. I favour this approach to a column per data type because it stops a setting from accidently ending up with two values and the consumer of a setting should know what data type they want.

like image 465
wobblycogs Avatar asked Jun 24 '10 11:06

wobblycogs


People also ask

What are user preferences?

To specify settings that can be customized for a particular user, configure user preferences. A set of DefaultPreferences is assigned to each user of the Cúram application. A user preferences editor is available in the web client. This editor allows each user to update values for the preferences.

What are preferences in Java?

The Java Preferences API provides a systematic way to handle program preference configurations, e.g. to save user settings, remember the last value of a field etc. Preferences are key / values pairs where the key is an arbitrary name for the preference. The value can be a boolean, string, int of another primitive type.

Where Java preferences are stored?

The user preferences are typically stored at user-home/. java/. userPrefs . The user preferences location can be overridden by setting the system property java.


1 Answers

One approach we use is:

  • all non-mandatory properties have defaults in code
  • deliver a properties file with the web application in which we define the technical oriented properties
  • query a SQL table on application startup to load mainly functional oriented properties

The properties from the database have a higher priority than those from the included property file. If your requirement is to prevent functional managers from changing techical properties you can add a context column to the properties table which is checked in the management UI.

All the application code gets to see is one globally used properties collection.

like image 193
rsp Avatar answered Oct 12 '22 03:10

rsp