You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

This is a proposal 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">The background color to use for all pages</glast:preferences>
  <glast:preference name="maxTableSize">The maximum number of rows in tables before they paginate</glast:preferences>
</glast:preferences>
  • No labels