SPT Core API

com.sptci.echo
Class Listener<V extends View>

java.lang.Object
  extended by com.sptci.echo.Listener<V>
All Implemented Interfaces:
Serializable, EventListener, ActionListener
Direct Known Subclasses:
DirectoryListener

public abstract class Listener<V extends View>
extends Object
implements ActionListener

An abstract base class for action listeners. Provides common error checking methods and also methods to process annotations to automate field checking.

Copyright 2006 Sans Pareil Technologies, Inc.

Version:
$Id: Listener.java 4853 2009-08-10 21:10:14Z rakesh $
Author:
Rakesh Vidyadharan 2006-11-23
See Also:
Serialized Form

Field Summary
protected static Logger logger
          The logger to use to log errors/messages to.
 
Constructor Summary
Listener()
           
 
Method Summary
protected  boolean checkText(String text)
          Check the specified string to ensure that it is not null and not empty.
protected  boolean checkTextComponent(Object obj, Constraints constraints)
          Check the specified component if it is a text component to ensure that the input value matches the annotated constratints.
protected  boolean checkView(V view)
          Check the specified view to ensure that mandatory components have been assigned values.
protected  Application getApplication()
          Convenience method to return the application instance for the session.
protected  V getView(ActionEvent event)
          Return the parent view from which the action event was triggered.
protected  void processFatalException(String message, Throwable t)
          A global handler for exceptions encountered while updating the display.
protected  void processFatalException(Throwable t)
          A global handler for exceptions encountered while updating the display.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface nextapp.echo.app.event.ActionListener
actionPerformed
 

Field Detail

logger

protected static final Logger logger
The logger to use to log errors/messages to.

Constructor Detail

Listener

public Listener()
Method Detail

getView

protected V getView(ActionEvent event)
Return the parent view from which the action event was triggered. This method assumes that the parent view implements the View marker interface.

Parameters:
event - The action event that was triggered.
Returns:
The parent view component.

checkView

protected boolean checkView(V view)
Check the specified view to ensure that mandatory components have been assigned values. The default implementation processes Constraints annotations on the view to determine whether all mandatory components have been assigned values. This method processes only the following types of components at present:

Parameters:
view - The view that is to be checked.
Returns:
Return true if the default checks pass.
See Also:
checkTextComponent(Object, com.sptci.echo.annotation.Constraints), checkListComponent(Object, com.sptci.echo.annotation.Constraints)

checkTextComponent

protected boolean checkTextComponent(Object obj,
                                     Constraints constraints)
Check the specified component if it is a text component to ensure that the input value matches the annotated constratints.

Parameters:
obj - The component that is to be checked.
constraints - The annotated constraints.
Returns:
Return true if the object is not a text component or if it matches all the constraints.

getApplication

protected Application getApplication()
Convenience method to return the application instance for the session.

Returns:
The application instance from Application.getApplication()
Since:
2007-11-13

processFatalException

protected void processFatalException(Throwable t)
A global handler for exceptions encountered while updating the display.

Parameters:
t - The fatal exception
See Also:
Application.processFatalException( Throwable )

processFatalException

protected void processFatalException(String message,
                                     Throwable t)
A global handler for exceptions encountered while updating the display.

Parameters:
message - The message to display in the ErrorPane.
t - The fatal exception
See Also:
Application.processFatalException( String, Throwable )

checkText

protected boolean checkText(String text)
Check the specified string to ensure that it is not null and not empty. Strings that are composed entirely of spaces are also treated as empty.

Parameters:
text - The text that is to be checked.
Returns:
Return true if the string specified is not null or empty.

SPT Core API