net.sf.click.util
Class SessionMap

java.lang.Object
  extended bynet.sf.click.util.SessionMap
All Implemented Interfaces:
Map

public class SessionMap
extends Object
implements Map

Provides a Map adaptor for HttpSession objects. A SessionMap instance is available in each Velocity page using the name "session".

For example suppose we have a User object in the session with the attribute name "user" when a user is logged on. We can display the users name in the page when the are logged onto the system.

 #if ($session.user)
   $session.user.fullname you are logged on.
 #else
   You are not logged on.
 #end 
The ClickServlet adds a SessionMap instance to the Velocity Context before it is merged with the page template.

The SessionMap supports FlashAttribute which when accessed via get(Object) are removed from the session.

Author:
Malcolm.Edgar

Nested Class Summary
 
Nested classes inherited from class java.util.Map
Map.Entry
 
Field Summary
protected  HttpSession session
          The internal session attribute.
 
Constructor Summary
SessionMap(HttpSession value)
          Create a HttpSession Map adaptor.
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
          This method is not supported and will throw UnsupportedOperationException if invoked.
 Set entrySet()
           
 Object get(Object key)
          If the stored object is a FlashObject this method will return the FlashObject value and then remove it from the session.
 boolean isEmpty()
           
 Set keySet()
           
 Object put(Object key, Object value)
           
 void putAll(Map map)
           
 Object remove(Object key)
           
 int size()
           
 Collection values()
          This method is not supported and will throw UnsupportedOperationException if invoked.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

session

protected HttpSession session
The internal session attribute.

Constructor Detail

SessionMap

public SessionMap(HttpSession value)
Create a HttpSession Map adaptor.

Parameters:
value - the http session
Method Detail

size

public int size()
Specified by:
size in interface Map
See Also:
Map.size()

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map
See Also:
Map.isEmpty()

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map
See Also:
Map.containsKey(Object)

containsValue

public boolean containsValue(Object value)
This method is not supported and will throw UnsupportedOperationException if invoked.

Specified by:
containsValue in interface Map
See Also:
Map.containsValue(Object)

get

public Object get(Object key)
If the stored object is a FlashObject this method will return the FlashObject value and then remove it from the session.

Specified by:
get in interface Map
See Also:
Map.get(Object)

put

public Object put(Object key,
                  Object value)
Specified by:
put in interface Map
See Also:
Map.put(Object, Object)

remove

public Object remove(Object key)
Specified by:
remove in interface Map
See Also:
Map.remove(Object)

putAll

public void putAll(Map map)
Specified by:
putAll in interface Map
See Also:
Map.putAll(Map)

clear

public void clear()
Specified by:
clear in interface Map
See Also:
Map.clear()

keySet

public Set keySet()
Specified by:
keySet in interface Map
See Also:
Map.keySet()

values

public Collection values()
This method is not supported and will throw UnsupportedOperationException if invoked.

Specified by:
values in interface Map
See Also:
Map.values()

entrySet

public Set entrySet()
Specified by:
entrySet in interface Map
See Also:
Map.entrySet()