org.strutsme.wishlist.client.forms
Class FormTools

java.lang.Object
  extended by org.strutsme.wishlist.client.forms.FormTools

public final class FormTools
extends java.lang.Object

Formtools provides some utilityfunctions to create or update editable fields in Forms.

Author:
lbusmann

Method Summary
static void clearCommands(javax.microedition.lcdui.Screen screen)
          clears the commands of the screen.
static void clearlist(javax.microedition.lcdui.List list)
          deletes all items of the wishList.
static javax.microedition.lcdui.TextField createTextField(java.lang.String title, java.lang.String value, int len, int kind)
          Creates a Textfield.
static java.lang.String dateToStr(java.util.Date date)
           
static java.lang.String dateToStr(int[] calFormat, java.util.Date date)
           
static javax.microedition.midlet.MIDlet getMainMidlet()
           
static java.util.Calendar parseCalendar(int[] calformat, java.lang.String calStr)
          parses the calStr.
static java.util.Calendar parseCalendar(java.lang.String calStr)
          parses the calStr against the default calformat.
static void setCurrentDisplayable(javax.microedition.lcdui.Displayable displayable)
          brings the displayable on top of the screen and activates it.
static void setMainMidlet(javax.microedition.midlet.MIDlet mainMidlet)
           
static void setTextFieldString(javax.microedition.lcdui.TextField textField, java.lang.String value)
          Sets the displayed value of Textfield.
static void showAlert(javax.microedition.lcdui.Alert alert)
          shows the alert on the screen.
static void showErrorAlert(java.lang.String title, java.lang.String message)
          shows a Alert of type ERROR on the screen.
static void showMessages(javax.microedition.lcdui.Form form, SafeHashtable messages, java.lang.String marker)
          generates for each message in messages a StringItem and appends it to the form.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createTextField

public static javax.microedition.lcdui.TextField createTextField(java.lang.String title,
                                                                 java.lang.String value,
                                                                 int len,
                                                                 int kind)
Creates a Textfield. If the value is longer than len, the value is truncated to len.

Parameters:
title - the title of the textfield
value - the value
len - the max. length of the textfield
kind - the kind of the textfield
Returns:
the created textfield
See Also:
TextField

setTextFieldString

public static void setTextFieldString(javax.microedition.lcdui.TextField textField,
                                      java.lang.String value)
Sets the displayed value of Textfield. If the value is longer than the maxSize of the Textfield, the value is truncated to the MaxSize.

Parameters:
textField - the Textfield
value - the value for the Textfield

clearlist

public static void clearlist(javax.microedition.lcdui.List list)
deletes all items of the wishList.

Parameters:
list - the list to clear

getMainMidlet

public static javax.microedition.midlet.MIDlet getMainMidlet()
Returns:
the mainMidlet

setMainMidlet

public static void setMainMidlet(javax.microedition.midlet.MIDlet mainMidlet)
Parameters:
mainMidlet - the mainMidlet to set

setCurrentDisplayable

public static void setCurrentDisplayable(javax.microedition.lcdui.Displayable displayable)
brings the displayable on top of the screen and activates it. To use this method, the mainmidlet of the Formtools must be set.

Parameters:
displayable - the new currentDisplayable

showAlert

public static void showAlert(javax.microedition.lcdui.Alert alert)
shows the alert on the screen. To use this method, the mainmidlet of the Formtools must be set.

Parameters:
alert - the alert to display

showErrorAlert

public static void showErrorAlert(java.lang.String title,
                                  java.lang.String message)
shows a Alert of type ERROR on the screen.

Parameters:
title - the title of the alert
message - the message of the alert

clearCommands

public static void clearCommands(javax.microedition.lcdui.Screen screen)
clears the commands of the screen.

Parameters:
screen - the screen to remove the commands from

showMessages

public static void showMessages(javax.microedition.lcdui.Form form,
                                SafeHashtable messages,
                                java.lang.String marker)
generates for each message in messages a StringItem and appends it to the form.

Parameters:
form - the form, where to display the messages
messages - the messages themselves
marker - the prefix or marker for the messages

parseCalendar

public static java.util.Calendar parseCalendar(java.lang.String calStr)
parses the calStr against the default calformat. This method is not just really safe against formaterrors.

Parameters:
calStr - the String to parse
Returns:
the parsed Calendar

parseCalendar

public static java.util.Calendar parseCalendar(int[] calformat,
                                               java.lang.String calStr)
parses the calStr. This method is not just really safe against formaterrors.

Parameters:
calformat - the dateformat of the string
calStr - the String to parse
Returns:
the parsed Calendar

dateToStr

public static java.lang.String dateToStr(java.util.Date date)
Parameters:
date - the date to convert
Returns:
the Date as formatted String

dateToStr

public static java.lang.String dateToStr(int[] calFormat,
                                         java.util.Date date)
Parameters:
calFormat - the format to use
date - the date to convert
Returns:
the Date as formatted String