com.mycompany.expense
Class EntryHandler

java.lang.Object
  extended bycom.mycompany.expense.EntryHandler

public class EntryHandler
extends java.lang.Object

This class contains properties and methods for the JSF components in the report entry area of the sample expense report aplication.

Version:
1.0
Author:
Hans Bergsten, Gefion Software

Field Summary
private  ReportEntry currentEntry
           
private  java.util.List expenseTypeChoices
           
private  java.util.Map expenseTypes
           
private  boolean includeSpecial
           
private  ReportHandler reportHandler
           
private  java.util.List specialChoices
           
private  java.util.Map specialTypes
           
 
Constructor Summary
EntryHandler()
           
 
Method Summary
 java.lang.String add()
          Adds the current entry to the current report by calling the addEntry() method on the ReportHandler.
 java.util.List getCurrentChoices()
          Returns a List with SelectItem instances for the expense type choices, including the special choices if the "includeSpecial" flag is set to "true".
 ReportEntry getCurrentEntry()
          Returns the current ReportEntry instance, or a new instance if there's no current instance.
 java.util.List getExpenseTypeChoices()
          Returns a List with SelectItem instances for the standard expense type choices.
 java.util.List getI18nChoices()
          Returns a List with SelectItem instances matching the standard expense type choices with labels localized for the view's locale, from a resource bundle with the base name "entryTypes".
private  java.lang.String getResource(java.util.ResourceBundle bundle, java.lang.String key)
          Returns the resource matching the provided key after replacing all spaces with underscores, or a String containing the key embedded in question marks if no resource matches the key.
private  java.util.List getSpecialChoices()
          Returns a List with SelectItem instances for the special expense type choices.
 void setExpenseTypes(java.util.Map expenseTypes)
          Sets the standard expense type choice values.
 void setReportHandler(ReportHandler reportHandler)
          Sets a reference to the ReportHandler that this instance interacts with.
 void setSpecialTypes(java.util.Map specialTypes)
          Sets the special expense type choice values.
 java.lang.String toggleTypes()
          Toggles the value of the "includeSpecial" flag.
 void toggleTypes(javax.faces.event.ValueChangeEvent event)
          Toggles the value of the "includeSpecial" flag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reportHandler

private ReportHandler reportHandler

currentEntry

private ReportEntry currentEntry

expenseTypes

private java.util.Map expenseTypes

expenseTypeChoices

private java.util.List expenseTypeChoices

specialTypes

private java.util.Map specialTypes

specialChoices

private java.util.List specialChoices

includeSpecial

private boolean includeSpecial
Constructor Detail

EntryHandler

public EntryHandler()
Method Detail

setReportHandler

public void setReportHandler(ReportHandler reportHandler)
Sets a reference to the ReportHandler that this instance interacts with.


setExpenseTypes

public void setExpenseTypes(java.util.Map expenseTypes)
Sets the standard expense type choice values.


setSpecialTypes

public void setSpecialTypes(java.util.Map specialTypes)
Sets the special expense type choice values.


getExpenseTypeChoices

public java.util.List getExpenseTypeChoices()
Returns a List with SelectItem instances for the standard expense type choices.


getCurrentChoices

public java.util.List getCurrentChoices()
Returns a List with SelectItem instances for the expense type choices, including the special choices if the "includeSpecial" flag is set to "true".


getI18nChoices

public java.util.List getI18nChoices()
Returns a List with SelectItem instances matching the standard expense type choices with labels localized for the view's locale, from a resource bundle with the base name "entryTypes".


getCurrentEntry

public ReportEntry getCurrentEntry()
Returns the current ReportEntry instance, or a new instance if there's no current instance.


add

public java.lang.String add()
Adds the current entry to the current report by calling the addEntry() method on the ReportHandler.


toggleTypes

public java.lang.String toggleTypes()
Toggles the value of the "includeSpecial" flag. This method is used as an action method for a command component.


toggleTypes

public void toggleTypes(javax.faces.event.ValueChangeEvent event)
Toggles the value of the "includeSpecial" flag. This method is used as value change listener method for an input component.


getSpecialChoices

private java.util.List getSpecialChoices()
Returns a List with SelectItem instances for the special expense type choices.


getResource

private java.lang.String getResource(java.util.ResourceBundle bundle,
                                     java.lang.String key)
Returns the resource matching the provided key after replacing all spaces with underscores, or a String containing the key embedded in question marks if no resource matches the key.