org.davesag.generica.controller
Class AbstractUserProfileController

java.lang.Object
  extended byorg.davesag.generica.controller.AbstractController
      extended byorg.davesag.generica.controller.AbstractActionController
          extended byorg.davesag.generica.controller.AbstractHibernateController
              extended byorg.davesag.generica.controller.AbstractUserProfileController
All Implemented Interfaces:
ActionController, Controller, FormController, Presenter, Saver, Summariser

public abstract class AbstractUserProfileController
extends AbstractHibernateController
implements FormController, Saver, Summariser, Presenter

AbstractUserProfileController is a base implementation that populates a Generic Form with details from the supplied user object and vice-verca, and performs the necessary summary/presentation logic required that is special for users above other kinds of business objects.

Extend this class and be sure to call super.populateWith and super.populateFrom to implement logic for your specific user types.
IMPORTANT: if you extend this class for use in editing a user that is not you, you must be sure to overwrite the prepare(java.util.Map) and summarise(java.lang.Object) methods accordingly. by default they assume that you are editing yourself as a logged in user.

Since:
Generica 1.0
Version:
CVS Revision $Id: AbstractUserProfileController.java,v 1.7 2004/04/06 15:40:40 davesag Exp $
Author:
Dave Sag http://www.davesag.com

Field Summary
 
Fields inherited from class org.davesag.generica.controller.AbstractActionController
theAction
 
Fields inherited from class org.davesag.generica.controller.AbstractController
theForm, theRequest, theResponse, theSession
 
Constructor Summary
AbstractUserProfileController()
           
 
Method Summary
 Object populateFromForm(Object o)
          Populates the supplied user from the Controller's form.
 void populateWith(Object o)
          Populates the Controller's form with specific information from the supplied object.
 void prepare(Map params)
          pull the subscriber summary out of the request and put the subscriber back into the session where it belongs.
 Object save(Object o)
          Saves a generic user.
 Summary summarise(Object o)
          The summary in this case just contains the actual user object as it is the job of the presenter to put this back into the session.
 
Methods inherited from class org.davesag.generica.controller.AbstractHibernateController
getHibernateSession
 
Methods inherited from class org.davesag.generica.controller.AbstractActionController
getAction, getMessages, setAction
 
Methods inherited from class org.davesag.generica.controller.AbstractController
getApplication, getForm, getLocale, getRequest, getResponse, getSession, setForm, setRequest, setResponse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.davesag.generica.controller.Controller
setForm, setRequest, setResponse
 
Methods inherited from interface org.davesag.generica.controller.ActionController
setAction
 

Constructor Detail

AbstractUserProfileController

public AbstractUserProfileController()
Method Detail

populateWith

public void populateWith(Object o)
Populates the Controller's form with specific information from the supplied object.

Specified by:
populateWith in interface FormController
Parameters:
o - The Object to use to populate this form.

save

public Object save(Object o)
            throws Exception
Saves a generic user. you may override this to save your specific user object, but for most cases this method should do the job as long as your specific user extends User.

Specified by:
save in interface Saver
Parameters:
o - The user object to save.
Returns:
the saved user object.
Throws:
Exception - probably a hibernate exception if something goes wrong.

populateFromForm

public Object populateFromForm(Object o)
Populates the supplied user from the Controller's form. If the required form fields,"password" or "email" are not present this method will do what it can and log and error. If you see unexpected results, check the logs.

Specified by:
populateFromForm in interface FormController
Parameters:
o - The Object to populate with data from the from.
Returns:
The populated object.

summarise

public Summary summarise(Object o)
                  throws Exception
The summary in this case just contains the actual user object as it is the job of the presenter to put this back into the session. This is a special case for users as they are always in the session.

Specified by:
summarise in interface Summariser
Parameters:
o - the object to sumarise.
Returns:
a summary of the object.
Throws:
Exception - if something went wrong.

prepare

public void prepare(Map params)
pull the subscriber summary out of the request and put the subscriber back into the session where it belongs.

Specified by:
prepare in interface Presenter
Parameters:
params - - unused here.


Dave Sag Generica API version 0.5.9 - (prerelease) Copyright 2003 - 2004 Dave Sag.