A
Callback of this type
represents a request to ask the user a yes/no or multiple-choice
question. A CallbackHandler should first call
getPrompt( )
to obtain the text of the question. It should also call
getMessageType(
) to determine the message type
(INFORMATION, WARNING, or
ERROR) and present the question to the user in a
suitable manner based on that type.
Next, the CallbackHandler must determine the
appropriate set of responses to the question. It does this by calling
getOptionType( ). The return values have the
following meanings:
- YES_NO_OPTION
-
The CallbackHandler should allow the user to
respond to the question with a
"yes" or a
"no" (or their localized
equivalents).
- YES_NO_CANCEL_OPTION
-
The CallbackHandler should allow
"yes",
"no", and
"cancel" (or their localized
equivalents) responses.
- OK_CANCEL_OPTION
-
The CallbackHandler should allow
"ok" and
"cancel" (or their localized
equivalents) responses.
- UNSPECIFIED_OPTION
-
The CallbackHandler should call
getOptions( ) and use present all strings it
returns as possible responses.
In each of these cases, the CallbackHandler should
also call getdefaultOption( ) to determine which
response should be presented as the default response. If
getOptionType( ) returned
UNSPECIFIED_TYPE, then getdefaultOption(
) returns an index into the array of options returned by
getOptions( ). Otherwise
getdefaultOption( ) returns one of the constants
YES, NO, OK,
or CANCEL.
When the user has selected a response to the callback, the
CallbackHandler should pass that response to
setSelectedIndex( ). The response value should be
one of the constants YES, NO,
OK, or CANCEL, or an index into
the array of options returned by getOptions( ).

public class ConfirmationCallback implements Callback, Serializable {
// Public Constructors
public ConfirmationCallback(int messageType, String[ ] options, int defaultOption);
public ConfirmationCallback(int messageType, int optionType, int defaultOption);
public ConfirmationCallback(String prompt, int messageType, String[ ] options,
int defaultOption);
public ConfirmationCallback(String prompt, int messageType, int optionType,
int defaultOption);
// Public Constants
public static final int CANCEL; =2
public static final int ERROR; =2
public static final int INFORMATION; =0
public static final int NO; =1
public static final int OK; =3
public static final int OK_CANCEL_OPTION; =2
public static final int UNSPECIFIED_OPTION; =-1
public static final int WARNING; =1
public static final int YES; =0
public static final int YES_NO_CANCEL_OPTION; =1
public static final int YES_NO_OPTION; =0
// Public Instance Methods
public int getDefaultOption( );
public int getMessageType( );
public String[ ] getOptions( );
public int getOptionType( );
public String getPrompt( );
public int getSelectedIndex( );
public void setSelectedIndex(int selection);
}