Dashboard > Java > ... > Profile System > Simple User Preferences System for Web Applications
  Java Log In View a printable version of the current page.  
  Simple User Preferences System for Web Applications
Added by Tony Johnson, last edited by Massimiliano Turri on Apr 06, 2007  (view change)
Labels: 
(None)

This is the documentation for a simple user preferences system for use with GLAST (Java) web applications.

Oracle Table

The system would use a single oracle table with the following columns

Column Type Use
Application String Name of the application, or NULL for global
User String Username of user for which these preferences apply
Name String Name for these preferences (normally preferences)
Data CLOB XML representing user preferences for the specified application

How to use in an web application

Create an JavaBean with the preferences you need as bean properties. They can be of any type supported by Java. E.g.

UserPreferences.java
package org.glast.pipeline.web;
import java.swt.Color;

class UserPrefences
{
   private int maxTableSize = 50;
   private Color backgroundColor = Color.WHITE;

   // getter and setters go here
}

The login filter already used with most applications would create this object in the session whenever a new session is created (it would initially have the default values). When the user logs in the the UserPreferences would be updated from the database (or left at their default value if the user had not set them).

Using user preferences in code

Since the UserPreferences object always exists in the session it is very easy to use it in a JSP page

Example.jsp
<body bgcolor="${session.preferences.backgroundColor}">

Setting user preferences

The application developer would provide a "User Preferences" page where the user could update the preferences. Standard utilities would be provided for storing the bean into the database (using JavaBean XML serialization this is easy, and supports "schema evolution" automatically).

Possibly there could be a default JSP page which would display all of the properties of the bean to reduce the need to write code.

Preferences.jsp
Please set your user preferences.
<glast:preferences bean="${session.preferences}>
  <glast:preference name="backgroundColor" title="The background color to use for all pages" />
  <glast:preference name="maxTableSize" title="The maximum number of rows in tables before they paginate" />
</glast:preferences>

Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.8 Build:#814 Oct 02, 2007) - Bug/feature request - Contact Administrators