org.jaffa.components.maint
Class MaintComponent2

java.lang.Object
  extended byorg.jaffa.presentation.portlet.component.Component
      extended byorg.jaffa.components.maint.MaintComponent2
All Implemented Interfaces:
IComponent, ICreateComponent, IDeleteComponent, IMaintComponent, IUpdateComponent

public abstract class MaintComponent2
extends Component
implements IMaintComponent

This is the base class for all Maintenance components created by using the object_maintenance_2_0 pattern. It has the following properties - 1- mode : Indicates if the component is in Create, Update or Delete mode. 2- refreshData : Indicates if the data needs to be refreshed. This happens when the data is modified by another user. 3- currentScreenCounter : A maintenance component may consist of more than one screen. This counter is used to identify the current screen being displayed. It will start with count=0 A Maintenance class will have to provide an implementation for the doPrevalidateCreate(), doCreate(), doPrevalidateUpdate(), doUpdate(), doDelete(), doRetrieve(), addScreens() methods.

Author:
GautamJ

Nested Class Summary
 class MaintComponent2.Screen
          A maintenance component may consist of more than one screen.
 
Field Summary
 
Fields inherited from interface org.jaffa.components.maint.IMaintComponent
MODE_CREATE, MODE_DELETE, MODE_UPDATE
 
Constructor Summary
MaintComponent2()
           
 
Method Summary
 void addCreateListener(ICreateListener listener)
          Adds a listener.
 void addDeleteListener(IDeleteListener listener)
          Adds a listener.
 void addDisplayOnlyField(String fieldName)
          This will mark a field as 'DisplayOnly'.
protected abstract  void addScreens(List screens)
          The Component should provide an implementation for this method to provide the screen information.
 void addUpdateListener(IUpdateListener listener)
          Adds a listener.
 void create()
          This will invoke the doCreate() method to create a new domain object.
 void delete(boolean performDirtyReadCheck)
          This will invoke the doDelete() method to delete the domain object.
 MaintComponent2.Screen determineAndSetNextScreen()
          This sets the currentScreenCounter to point to the next screen.
 MaintComponent2.Screen determineAndSetPreviousScreen()
          This sets the currentScreenCounter to point to the previous screen.
 MaintComponent2.Screen determineCurrentScreen()
          Getter for the current Screen.
static URL determineDefaultValuesUrl(Class componentClass)
          A helper routine to return the URL for the properties file containing default values for a component.
 FormKey determineFormKey()
          Getter for the current screen's FormKey.
 MaintComponent2.Screen determineNextScreen()
          Getter for the next Screen.
 MaintComponent2.Screen determinePreviousScreen()
          Getter for the previous Screen.
 FormKey display()
          Based on the mode and input parameters, this will either delete the domain object, or initialize the screen for updates, or bring up a blank screen.
protected abstract  void doCreate()
          The Component should provide an implementation for this method to create a domain object.
protected abstract  void doDelete(boolean performDirtyReadCheck)
          The Component should provide an implementation for this method to delete the domain object.
protected abstract  void doPrevalidateCreate()
          The Component should provide an implementation for this method to perform prevalidations before creating a domain object.
protected abstract  void doPrevalidateUpdate(boolean performDirtyReadCheck)
          The Component should provide an implementation for this method to perform prevalidations before updating a domain object.
protected abstract  void doRetrieve()
          The Component should provide an implementation for this method to retrieve the domain object.
protected abstract  void doUpdate(boolean performDirtyReadCheck)
          The Component should provide an implementation for this method to update the domain object.
protected  Collection getCreateListeners()
          Returns a Collection of ICreateListener objects.
 int getCurrentScreenCounter()
          Getter for property currentScreenCounter.
protected  Collection getDeleteListeners()
          Returns a Collection of IDeleteListener objects.
protected  HeaderDto getHeaderDto()
          Returns the HeaderDto.
 int getMode()
          Getter for property mode.
 MaintComponent2.Screen[] getScreens()
          Getter for the Screens.
protected  Collection getUpdateListeners()
          Returns a Collection of IUpdateListener objects.
protected  void initDropDownCodes()
          The Component should override this method to retrieve the set of codes for dropdowns in a screen, if any are required.
protected  void initializeData()
          This method is invoked by the display() method when the component is run in the CREATE_MODE.
protected  void invokeCreateListeners()
          Invokes the createDone() method of the registered ICreateListener objects in the same thread.
protected  void invokeCreateListeners(EventObject eventObject)
          Invokes the createDone() method of the registered ICreateListener objects in the same thread.
protected  void invokeDeleteListeners()
          Invokes the deleteDone() method of the registered IDeleteListener objects in the same thread.
protected  void invokeDeleteListeners(EventObject eventObject)
          Invokes the deleteDone() method of the registered IDeleteListener objects in the same thread.
protected  void invokeUpdateListeners()
          Invokes the updateDone() method of the registered IUpdateListener objects in the same thread.
protected  void invokeUpdateListeners(EventObject eventObject)
          Invokes the updateDone() method of the registered IUpdateListener objects in the same thread.
 boolean isCreateMode()
          Returns true if this is create mode.
 boolean isDeleteMode()
          Returns true if this is delete mode.
 boolean isDisplayOnlyField(String fieldName)
          Returns a true if a field has been marked as 'DisplayOnly'.
 boolean isRefreshData()
          Getter for property refreshData.
 boolean isUpdateMode()
          Returns true if this is update mode.
 void prevalidateCreate()
          This will invoke the doPrevalidateCreate() method to perform prevalidations before creating a domain object.
 void prevalidateUpdate(boolean performDirtyReadCheck)
          This will invoke the doPrevalidateUpdate() method to perform prevalidations before updating a domain object.
 void quit()
          This clears the internal collection of listeners.
 boolean removeCreateListener(ICreateListener listener)
          Removes a listener.
 boolean removeDeleteListener(IDeleteListener listener)
          Removes a listener.
 boolean removeUpdateListener(IUpdateListener listener)
          Removes a listener.
 void retrieve()
          This will invoke the doRetrieve() method to retrieve the domain object.
 void setCurrentScreenCounter(int currentScreenCounter)
          Setter for property currentScreenCounter.
 void setMode(int mode)
          Setter for property mode.
protected  void setRefreshData(boolean refreshData)
          Setter for property refreshData.
protected  void uncacheWidgetModels()
          Clears the WidgetCache, removing all the WidgetModels.
 void update(boolean performDirtyReadCheck)
          This will invoke the doUpdate() method to update the domain object.
 
Methods inherited from class org.jaffa.presentation.portlet.component.Component
addChildComponent, addFormKeyChangeListener, getComponentDefinition, getComponentId, getContainerFormKey, getFormKeyChangeListeners, getReturnToFormKey, getToken, getUserSession, isActive, quitAndReturnToCallingScreen, reflectAndSetParms, removeFormKeyChangeListener, returnChildComponents, returnLastActivityDate, run, setContainerFormKey, setReturnToFormKey, setToken, updateLastActivityDate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jaffa.presentation.portlet.component.IComponent
addFormKeyChangeListener, getComponentDefinition, getComponentId, getContainerFormKey, getFormKeyChangeListeners, getReturnToFormKey, getToken, getUserSession, isActive, quitAndReturnToCallingScreen, removeFormKeyChangeListener, setContainerFormKey, setReturnToFormKey, setToken
 

Constructor Detail

MaintComponent2

public MaintComponent2()
Method Detail

getMode

public int getMode()
Getter for property mode.

Specified by:
getMode in interface IMaintComponent
Returns:
Value of property mode.

setMode

public void setMode(int mode)
Setter for property mode.

Specified by:
setMode in interface IMaintComponent
Parameters:
mode - New value of property mode.

isCreateMode

public boolean isCreateMode()
Returns true if this is create mode.

Specified by:
isCreateMode in interface IMaintComponent
Returns:
true if this is create mode.

isUpdateMode

public boolean isUpdateMode()
Returns true if this is update mode.

Specified by:
isUpdateMode in interface IMaintComponent
Returns:
true if this is update mode.

isDeleteMode

public boolean isDeleteMode()
Returns true if this is delete mode.

Specified by:
isDeleteMode in interface IMaintComponent
Returns:
true if this is delete mode.

isRefreshData

public boolean isRefreshData()
Getter for property refreshData.

Returns:
Value of property refreshData.

setRefreshData

protected void setRefreshData(boolean refreshData)
Setter for property refreshData.

Parameters:
refreshData - New value of property refreshData.

getCurrentScreenCounter

public int getCurrentScreenCounter()
Getter for property currentScreenCounter.

Returns:
Value of property currentScreenCounter.

setCurrentScreenCounter

public void setCurrentScreenCounter(int currentScreenCounter)
Setter for property currentScreenCounter.

Parameters:
currentScreenCounter - New value of property currentScreenCounter.

getScreens

public MaintComponent2.Screen[] getScreens()
Getter for the Screens.

Returns:
the screens.

determineCurrentScreen

public MaintComponent2.Screen determineCurrentScreen()
Getter for the current Screen.

Returns:
the current screen.

determineNextScreen

public MaintComponent2.Screen determineNextScreen()
Getter for the next Screen. This takes into account the mode and if the following screen is available in create or update modes. A null will be returned in case no appropriate next screen is available.

Returns:
the next screen.

determineAndSetNextScreen

public MaintComponent2.Screen determineAndSetNextScreen()
This sets the currentScreenCounter to point to the next screen. This takes into account the mode and if the following screen is available in create or update modes. A null will be returned in case no appropriate next screen is available.

Returns:
the next screen.

determinePreviousScreen

public MaintComponent2.Screen determinePreviousScreen()
Getter for the previous Screen. This takes into account the mode and if the previous screen is available in create or update modes. A null will be returned in case no appropriate previous screen is available.

Returns:
the previous screen.

determineAndSetPreviousScreen

public MaintComponent2.Screen determineAndSetPreviousScreen()
This sets the currentScreenCounter to point to the previous screen. This takes into account the mode and if the previous screen is available in create or update modes. A null will be returned in case no appropriate previous screen is available.

Returns:
the previous screen.

determineFormKey

public FormKey determineFormKey()
Getter for the current screen's FormKey.

Returns:
the FormKey for the current screen.

addDisplayOnlyField

public void addDisplayOnlyField(String fieldName)
This will mark a field as 'DisplayOnly'.

Parameters:
fieldName - The field to be marked as 'DisplayOnly'.

isDisplayOnlyField

public boolean isDisplayOnlyField(String fieldName)
Returns a true if a field has been marked as 'DisplayOnly'.

Parameters:
fieldName - The field to be checked.
Returns:
a true if a field has been marked as 'DisplayOnly'

addCreateListener

public void addCreateListener(ICreateListener listener)
Adds a listener.

Specified by:
addCreateListener in interface ICreateComponent
Parameters:
listener - the listener.

removeCreateListener

public boolean removeCreateListener(ICreateListener listener)
Removes a listener.

Specified by:
removeCreateListener in interface ICreateComponent
Parameters:
listener - the listener.
Returns:
true if the listener was removed.

addUpdateListener

public void addUpdateListener(IUpdateListener listener)
Adds a listener.

Specified by:
addUpdateListener in interface IUpdateComponent
Parameters:
listener - the listener.

removeUpdateListener

public boolean removeUpdateListener(IUpdateListener listener)
Removes a listener.

Specified by:
removeUpdateListener in interface IUpdateComponent
Parameters:
listener - the listener.
Returns:
true if the listener was removed.

addDeleteListener

public void addDeleteListener(IDeleteListener listener)
Adds a listener.

Specified by:
addDeleteListener in interface IDeleteComponent
Parameters:
listener - the listener.

removeDeleteListener

public boolean removeDeleteListener(IDeleteListener listener)
Removes a listener.

Specified by:
removeDeleteListener in interface IDeleteComponent
Parameters:
listener - the listener.
Returns:
true if the listener was removed.

display

public FormKey display()
                throws ApplicationExceptions,
                       FrameworkException
Based on the mode and input parameters, this will either delete the domain object, or initialize the screen for updates, or bring up a blank screen.

Specified by:
display in interface IComponent
Specified by:
display in class Component
Returns:
The FormKey.
Throws:
ApplicationExceptions - Indicates some functional error.
FrameworkException - Indicates some system error.

quit

public void quit()
This clears the internal collection of listeners. It then invokes the quit() method of the base class.

Specified by:
quit in interface IComponent
Overrides:
quit in class Component

prevalidateCreate

public void prevalidateCreate()
                       throws ApplicationExceptions,
                              FrameworkException
This will invoke the doPrevalidateCreate() method to perform prevalidations before creating a domain object.

Throws:
ApplicationExceptions - This will be thrown in case any invalid data has been set.
FrameworkException - Indicates some system error.

create

public void create()
            throws ApplicationExceptions,
                   FrameworkException
This will invoke the doCreate() method to create a new domain object. It will then invoke all the Create Listeners.

Throws:
ApplicationExceptions - Indicates some functional error.
FrameworkException - Indicates some system error.

prevalidateUpdate

public void prevalidateUpdate(boolean performDirtyReadCheck)
                       throws ApplicationExceptions,
                              FrameworkException
This will invoke the doPrevalidateUpdate() method to perform prevalidations before updating a domain object.

Parameters:
performDirtyReadCheck - this will determine if the Dirty Read check if to be performed prior to an update.
Throws:
ApplicationExceptions - This will be thrown in case any invalid data has been set.
FrameworkException - Indicates some system error.

update

public void update(boolean performDirtyReadCheck)
            throws ApplicationExceptions,
                   FrameworkException
This will invoke the doUpdate() method to update the domain object. It will then invoke all the Update Listeners.

Parameters:
performDirtyReadCheck - this will determine if the Dirty Read check if to be performed prior to an update.
Throws:
ApplicationExceptions - Indicates some functional error.
FrameworkException - Indicates some system error.

delete

public void delete(boolean performDirtyReadCheck)
            throws ApplicationExceptions,
                   FrameworkException
This will invoke the doDelete() method to delete the domain object. It will then invoke all the Delete Listeners.

Parameters:
performDirtyReadCheck - this will determine if the Dirty Read check if to be performed prior to a delete.
Throws:
ApplicationExceptions - Indicates some functional error.
FrameworkException - Indicates some system error.

retrieve

public void retrieve()
              throws ApplicationExceptions,
                     FrameworkException
This will invoke the doRetrieve() method to retrieve the domain object.

Throws:
ApplicationExceptions - Indicates some functional error.
FrameworkException - Indicates some system error.

getCreateListeners

protected Collection getCreateListeners()
Returns a Collection of ICreateListener objects.

Returns:
a Collection of ICreateListener objects.

getUpdateListeners

protected Collection getUpdateListeners()
Returns a Collection of IUpdateListener objects.

Returns:
a Collection of IUpdateListener objects.

getDeleteListeners

protected Collection getDeleteListeners()
Returns a Collection of IDeleteListener objects.

Returns:
a Collection of IDeleteListener objects.

invokeCreateListeners

protected void invokeCreateListeners()
Invokes the createDone() method of the registered ICreateListener objects in the same thread.


invokeCreateListeners

protected void invokeCreateListeners(EventObject eventObject)
Invokes the createDone() method of the registered ICreateListener objects in the same thread.

Parameters:
eventObject - The EventObject which will probably contain the component itself.

invokeUpdateListeners

protected void invokeUpdateListeners()
Invokes the updateDone() method of the registered IUpdateListener objects in the same thread.


invokeUpdateListeners

protected void invokeUpdateListeners(EventObject eventObject)
Invokes the updateDone() method of the registered IUpdateListener objects in the same thread.

Parameters:
eventObject - The EventObject which will probably contain the component itself.

invokeDeleteListeners

protected void invokeDeleteListeners()
Invokes the deleteDone() method of the registered IDeleteListener objects in the same thread.


invokeDeleteListeners

protected void invokeDeleteListeners(EventObject eventObject)
Invokes the deleteDone() method of the registered IDeleteListener objects in the same thread.

Parameters:
eventObject - The EventObject which will probably contain the component itself.

uncacheWidgetModels

protected void uncacheWidgetModels()
Clears the WidgetCache, removing all the WidgetModels. It also resets the flags.


getHeaderDto

protected HeaderDto getHeaderDto()
Returns the HeaderDto. This can be used for passing the header info to the Tx, where required.

Returns:
the HeaderDto.

initializeData

protected void initializeData()
                       throws ApplicationExceptions,
                              FrameworkException
This method is invoked by the display() method when the component is run in the CREATE_MODE. It sets the default values in the component by reading them from the ComponentDefaultValues.properties file. This file should be in the base package of the component.

Throws:
ApplicationExceptions - This will be thrown in case any invalid data has been set.
FrameworkException - Indicates some system error.

initDropDownCodes

protected void initDropDownCodes()
                          throws ApplicationExceptions,
                                 FrameworkException
The Component should override this method to retrieve the set of codes for dropdowns in a screen, if any are required.

Throws:
ApplicationExceptions - This will be thrown in case any invalid data has been set.
FrameworkException - Indicates some system error.

doPrevalidateCreate

protected abstract void doPrevalidateCreate()
                                     throws ApplicationExceptions,
                                            FrameworkException
The Component should provide an implementation for this method to perform prevalidations before creating a domain object.

Throws:
ApplicationExceptions - This will be thrown in case any invalid data has been set.
FrameworkException - Indicates some system error.

doCreate

protected abstract void doCreate()
                          throws ApplicationExceptions,
                                 FrameworkException
The Component should provide an implementation for this method to create a domain object.

Throws:
ApplicationExceptions - This will be thrown in case any invalid data has been set.
FrameworkException - Indicates some system error.

doPrevalidateUpdate

protected abstract void doPrevalidateUpdate(boolean performDirtyReadCheck)
                                     throws ApplicationExceptions,
                                            FrameworkException
The Component should provide an implementation for this method to perform prevalidations before updating a domain object.

Parameters:
performDirtyReadCheck - this will determine if the Dirty Read check if to be performed prior to an update.
Throws:
ApplicationExceptions - This will be thrown in case any invalid data has been set.
FrameworkException - Indicates some system error.

doUpdate

protected abstract void doUpdate(boolean performDirtyReadCheck)
                          throws ApplicationExceptions,
                                 FrameworkException
The Component should provide an implementation for this method to update the domain object.

Parameters:
performDirtyReadCheck - this will determine if the Dirty Read check if to be performed prior to an update.
Throws:
ApplicationExceptions - This will be thrown in case any invalid data has been set.
FrameworkException - Indicates some system error.

doDelete

protected abstract void doDelete(boolean performDirtyReadCheck)
                          throws ApplicationExceptions,
                                 FrameworkException
The Component should provide an implementation for this method to delete the domain object.

Parameters:
performDirtyReadCheck - this will determine if the Dirty Read check if to be performed prior to a delete.
Throws:
ApplicationExceptions - This will be thrown in case any invalid data has been set.
FrameworkException - Indicates some system error.

doRetrieve

protected abstract void doRetrieve()
                            throws ApplicationExceptions,
                                   FrameworkException
The Component should provide an implementation for this method to retrieve the domain object.

Throws:
ApplicationExceptions - This will be thrown in case any invalid data has been set.
FrameworkException - Indicates some system error.

addScreens

protected abstract void addScreens(List screens)
The Component should provide an implementation for this method to provide the screen information.

Parameters:
screens - The component should add MaintComponent2.Screen objects to this list.

determineDefaultValuesUrl

public static URL determineDefaultValuesUrl(Class componentClass)
A helper routine to return the URL for the properties file containing default values for a component. The properties file is assumed to be in the base package of the component with the name ComponentDefaultValues.properties'. This method will try to locate the file on the filesystem. This allows the application to pick up any changes to the file. However, if the file is part of a jar, then it'll be loaded by the classloader. A null will be returned if no file is found.

Parameters:
componentClass - The component class.
Returns:
the URL for the properties file containing default values for a component.


Copyright © 2002-2004 JAFFA Project.