SPT Core API

com.sptci.echo.binding
Class ViewInitialiser<V>

java.lang.Object
  extended by com.sptci.echo.binding.ViewInitialiser<V>
Type Parameters:
V - The class name of the view component being initialised.

public class ViewInitialiser<V>
extends Object

An updater used to update UI containers with data from JavaBean objects.

Copyright 2006 Sans Pareil Technologies, Inc.

Version:
$Id: ViewInitialiser.java 4856 2009-08-11 15:22:46Z rakesh $
Author:
Rakesh Vidyadharan 2006-02-07

Field Summary
protected  Field controller
          The controller associated with the view.
protected  V view
          The object that is being initialised.
 
Constructor Summary
ViewInitialiser(V view)
          Create a new instance for the specified view.
 
Method Summary
 void init()
          Initialise all the components declared in view that may be automatically initialised.
protected  ActionListener initActionListener(Field field)
          Return an action listener instance based upon the annotation for the specified field.
protected  void initButton(String name, Field field)
          Initialise a Button component along with its style and action listener.
protected  void initLabel(String name, Field field)
          Create and configure a Label component for associating with the specified field.
protected  void initListBox(String name, Field field)
          Initialise a SelectField component.
protected  void initListModel(Field field, AbstractListComponent component)
          Initialise the ListModel for the specified list component.
protected  void initSelectField(String name, Field field)
          Initialise a ListBox component.
protected  void initTable(String name, Field field)
          Initialise a Table component along with its associated TableModel and a TableNavigation component if appropriate.
protected  void initTextArea(String name, Field field)
          Initialise a TextArea component along with its associated style if any.
protected  void initTextField(String name, Field field)
          Initialise TextField component along with its associated action listener if any.
protected  boolean isPrimitive(String name)
          Check the specified class name to see if it represents a primitive type.
protected  void setStyle(Component component, String name, Field field)
          Set the style for the specified component based upon annotations provided.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

view

protected V view
The object that is being initialised.


controller

protected Field controller
The controller associated with the view.

Constructor Detail

ViewInitialiser

public ViewInitialiser(V view)
Create a new instance for the specified view.

Parameters:
view - The view to use.
Method Detail

init

public void init()
          throws BindingException
Initialise all the components declared in view that may be automatically initialised.

Throws:
BindingException - If errors are encountered while initialising the components.

initButton

protected void initButton(String name,
                          Field field)
                   throws Throwable
Initialise a Button component along with its style and action listener.

Parameters:
name - The name of the field in view that is to be initialised.
field - The field in the view that is to be initialised.
Throws:
Throwable - If errors are encountered while initialising the button.

initLabel

protected void initLabel(String name,
                         Field field)
                  throws Throwable
Create and configure a Label component for associating with the specified field. If the label component is marked as mandatory, then the Default.Bold.Label style name is assigned, otherwise the behaviour of Utilities.createLabel( String, String ) is maintained.

Note: This method depends upon naming convention. It is expected that the label field is named with a Label suffix to the component the label is associated with. This convention is used to fetch localised properties based on the name of the associated component and not the label itself. Following this convention also enables annotation only the associated component and not the label also.

Parameters:
name - The name of the field.
field - The field corresponding to the name parameter in view.
Throws:
Throwable - Propogates any exceptions encountered up the chain.

initSelectField

protected void initSelectField(String name,
                               Field field)
                        throws Throwable
Initialise a ListBox component.

Parameters:
name - The name of the field in view that is to be initialised.
field - The field in the view that is to be initialised.
Throws:
Throwable - If errors are encountered while initialising the listBox field.
See Also:
initListModel(java.lang.reflect.Field, nextapp.echo.app.list.AbstractListComponent)

initListBox

protected void initListBox(String name,
                           Field field)
                    throws Throwable
Initialise a SelectField component.

Parameters:
name - The name of the field in view that is to be initialised.
field - The field in the view that is to be initialised.
Throws:
Throwable - If errors are encountered while initialising the listBox field.
See Also:
initListModel(java.lang.reflect.Field, nextapp.echo.app.list.AbstractListComponent)

initTable

protected void initTable(String name,
                         Field field)
                  throws Throwable
Initialise a Table component along with its associated TableModel and a TableNavigation component if appropriate.

Parameters:
name - The name of the field in view that is to be intialised.
field - The field repesenting the component to tbe initialised.
Throws:
Throwable - If errors are encountered while initialising the field.
See Also:
TableInitialiser#TableInitialiser(Object, Field)

initTextArea

protected void initTextArea(String name,
                            Field field)
                     throws Throwable
Initialise a TextArea component along with its associated style if any.

Parameters:
name - The name of the field in view that is to be initialised.
field - The field in the view that is to be initialised.
Throws:
Throwable - If errors are encountered while initialising the text area.

initTextField

protected void initTextField(String name,
                             Field field)
                      throws Throwable
Initialise TextField component along with its associated action listener if any.

Parameters:
name - The name of the field in view that is to be initialised.
field - The field in the view that is to be initialised.
Throws:
Throwable - If errors are encountered while initialising the text field.

setStyle

protected void setStyle(Component component,
                        String name,
                        Field field)
                 throws Throwable
Set the style for the specified component based upon annotations provided.

Parameters:
component - The component whose style attributes are to be set.
name - The name of the field in view that is to be initialised.
field - The field in the view that is to be initialised.
Throws:
Throwable - If errors are encountered while setting the style.

initActionListener

protected ActionListener initActionListener(Field field)
                                     throws Throwable
Return an action listener instance based upon the annotation for the specified field.

Parameters:
field - The field for which the action listener is to be attached.
Returns:
The initialised action listener.
Throws:
Throwable - If errors are encountered while initialising the action listener.

initListModel

protected void initListModel(Field field,
                             AbstractListComponent component)
                      throws Throwable
Initialise the ListModel for the specified list component.

Parameters:
field - The field in view that is being initialised
component - The list component whose list model is being initialised.
Throws:
Throwable - If exceptions are encountered while initialising the list model.

isPrimitive

protected boolean isPrimitive(String name)
Check the specified class name to see if it represents a primitive type.

Parameters:
name - The name of the class to check.
Returns:
Return true if the name represents a primitive type.

SPT Core API