Team LiB
Previous Section Next Section

ChoiceCallbackjavax.security.auth.callback

Java 1.4serializable

A Callback of this type represents a request to display set of text choices and allow the user to select one or more of them. A CallbackHandler, should display the prompt returned by getPrompt( ) and also the strings returned by getChoices( ). If allowMultipleSelections( ) is true, then it should allow the user to select zero or more; otherwise, it should only allow the user to select a single one. In either case, the CallbackHandler should also call geTDefaultChoice( ) and make the choice at the returned index the default choice. When the user has made her selection, the CallbackHandler should pass the index of a single selection to setSelectedIndex( ), or the indexes of multiple selections to setSelectedIndexes( ).

Figure 19-6. javax.security.auth.callback.ChoiceCallback


public class ChoiceCallback implements Callback, Serializable {
// Public Constructors
     public ChoiceCallback(String prompt, String[ ] choices, int defaultChoice, 
        boolean multipleSelectionsAllowed);  
// Public Instance Methods
     public boolean allowMultipleSelections( );  
     public String[ ] getChoices( );  
     public int getDefaultChoice( );  
     public String getPrompt( );  
     public int[ ] getSelectedIndexes( );  
     public void setSelectedIndex(int selection);  
     public void setSelectedIndexes(int[ ] selections);  
}

    Team LiB
    Previous Section Next Section