Methods Summary |
---|
public java.lang.String | add()Adds the current entry to the current report by calling
the addEntry() method on the ReportHandler.
return reportHandler.addEntry(currentEntry);
|
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".
List choices = new ArrayList();
choices.addAll(getExpenseTypeChoices());
if (includeSpecial) {
choices.addAll(getSpecialChoices());
}
Iterator i = choices.iterator();
while (i.hasNext()) {
SelectItem si = (SelectItem) i.next();
}
return choices;
|
public ReportEntry | getCurrentEntry()Returns the current ReportEntry instance, or a new instance
if there's no current instance.
if (currentEntry == null) {
currentEntry = new ReportEntry();
}
return currentEntry;
|
public java.util.List | getExpenseTypeChoices()Returns a List with SelectItem instances for the
standard expense type choices.
if (expenseTypeChoices == null) {
expenseTypeChoices = new ArrayList();
Iterator i = expenseTypes.entrySet().iterator();
while (i.hasNext()) {
Map.Entry me = (Map.Entry) i.next();
expenseTypeChoices.add(new SelectItem(me.getValue(),
(String) me.getKey()));
}
}
return expenseTypeChoices;
|
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".
FacesContext context = FacesContext.getCurrentInstance();
Locale locale = context.getViewRoot().getLocale();
ResourceBundle bundle =
ResourceBundle.getBundle("entryTypes", locale);
List i18nChoices = new ArrayList();
Iterator i = expenseTypes.entrySet().iterator();
while (i.hasNext()) {
Map.Entry me = (Map.Entry) i.next();
i18nChoices.add(new SelectItem(me.getValue(),
getResource(bundle, (String) me.getKey())));
}
return i18nChoices;
|
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.
// Replace all spaces with underscore
key = key.replaceAll(" ", "_");
String resource = null;
try {
resource = bundle.getString(key);
}
catch (MissingResourceException e) {
resource = "???" + key + "???";
}
return resource;
|
private java.util.List | getSpecialChoices()Returns a List with SelectItem instances for the
special expense type choices.
if (specialChoices == null) {
specialChoices = new ArrayList();
if (specialTypes != null) {
Iterator i = specialTypes.entrySet().iterator();
while (i.hasNext()) {
Map.Entry me = (Map.Entry) i.next();
specialChoices.add(new SelectItem(me.getValue(),
(String) me.getKey()));
}
}
}
Iterator i = specialChoices.iterator();
while (i.hasNext()) {
SelectItem si = (SelectItem) i.next();
}
return specialChoices;
|
public void | setExpenseTypes(java.util.Map expenseTypes)Sets the standard expense type choice values.
this.expenseTypes = expenseTypes;
|
public void | setReportHandler(ReportHandler reportHandler)Sets a reference to the ReportHandler that this instance
interacts with.
this.reportHandler = reportHandler;
|
public void | setSpecialTypes(java.util.Map specialTypes)Sets the special expense type choice values.
this.specialTypes = specialTypes;
|
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.
includeSpecial = !includeSpecial;
FacesContext.getCurrentInstance().renderResponse();
|
public java.lang.String | toggleTypes()Toggles the value of the "includeSpecial" flag. This method
is used as an action method for a command component.
includeSpecial = !includeSpecial;
return "success";
|