to.etc.domui.state
Class UIContext

java.lang.Object
  extended by to.etc.domui.state.UIContext

public class UIContext
extends java.lang.Object

A class which allows access to the page's context and related information. This is experimental. The PageContext is the root for all navigational information, and interfaces the pages and the server. This would usually be the task of the RequestContext, but that's an interface and I want the primary accessor to be in the same class.

Author:
Frits Jalvingh Created on Jun 22, 2008

Constructor Summary
UIContext()
           
 
Method Summary
static javax.servlet.http.Cookie createLoginCookie(long l)
           
static ConversationContext getCurrentConversation()
           
static Page getCurrentPage()
           
static IUser getCurrentUser()
          Return the currently-known logged in user, or null if unknown/not logged in.
static IUser getLoggedInUser()
          This returns the currently logged in user.
static IRequestContext getRequestContext()
           
static void internalClear()
          This CLEARS all "current state" threadlocals.
static IUser internalGetLoggedInUser(IRequestContext rx)
          UNSTABLE INTERFACE.
static void internalSet(IRequestContext rc)
          Called when a new request is to be made current, or when the request has ended.
static void internalSet(Page pg)
           
static boolean login(java.lang.String userid, java.lang.String password)
          Logs in a user.
static void logout()
          Logs out a user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UIContext

public UIContext()
Method Detail

getRequestContext

public static IRequestContext getRequestContext()

internalSet

public static void internalSet(@Nonnull
                               IRequestContext rc)
                        throws java.lang.Exception
Called when a new request is to be made current, or when the request has ended.

Parameters:
rc -
Throws:
java.lang.Exception

internalClear

public static void internalClear()
This CLEARS all "current state" threadlocals.


internalSet

public static void internalSet(Page pg)

getCurrentPage

public static Page getCurrentPage()

getCurrentConversation

public static ConversationContext getCurrentConversation()

getCurrentUser

@Nullable
public static IUser getCurrentUser()
Return the currently-known logged in user, or null if unknown/not logged in. FIXME Should be named findCurrentUser().

Returns:

getLoggedInUser

@Nonnull
public static IUser getLoggedInUser()
This returns the currently logged in user. If the user is not logged in this throws a login exception which should cause the user to log in.

Returns:

internalGetLoggedInUser

public static IUser internalGetLoggedInUser(IRequestContext rx)
                                     throws java.lang.Exception
UNSTABLE INTERFACE. This tries to retrieve an IUser context for the user. It tries to retrieve a copy from the HttpSession. The AppSession is not used; this allows a login to persist when running in DEBUG mode, where AppSessions are destroyed when a class is changed.

Parameters:
rci -
Returns:
Throws:
java.lang.Exception

login

public static boolean login(java.lang.String userid,
                            java.lang.String password)
                     throws java.lang.Exception
Logs in a user. If he was logged in before he is logged out.

Parameters:
userid -
password -
Returns:
Throws:
java.lang.Exception

logout

public static void logout()
                   throws java.lang.Exception
Logs out a user.

Throws:
java.lang.Exception

createLoginCookie

public static javax.servlet.http.Cookie createLoginCookie(long l)
                                                   throws java.lang.Exception
Throws:
java.lang.Exception