This example demonstrates how to write a SelectProvider with Yes and No options.

package atg.cim.worker.common;

import java.util.ArrayList;
import java.util.List;

import atg.cim.model.SelectProviderOption;
import atg.cim.worker.ISelectProvider;
import atg.cim.worker.SelectProvider;

/**{@link ISelectProvider} that provides a Yes and No option
 */

public class YesNoSelectProvider extends SelectProvider {

  private boolean mChoice;
  /**Get the user selection
   * @return True if the user selected Yes, False if they selected No
   */
  public boolean isChoice() {
    return mChoice;
  }
/**Set the users selection
 * @param pChoice the choice to set
 */
public void setChoice(boolean pChoice) {
  mChoice = pChoice;
}

/**Always Return true
 * @return True
 * @see atg.cim.worker.ISelectProvider#canProvide()
 */
public boolean canProvide() {
  return true;
}

/**Provides a list with options Yes and No
 * @return A SelectProviderOtpion list of Yes and No
 * @see atg.cim.worker.ISelectProvider#provideChoices()
 */
public List<SelectProviderOption> provideChoices(){
  List<SelectProviderOption> choices = new ArrayList<SelectProviderOption>(2);
  choices.add(0, new SelectProviderOption("yes","Yes"));
  choices.add(1,new SelectProviderOption("no","No"));
  return choices;
}

/**Set the value from the user's selection
 * @param pChoices
 * @see atg.cim.worker.ISelectProvider#setUserSelection(java.util.List)
 */
public void setUserSelection(List<SelectProviderOption> pChoices){
  if(pChoices.get(0).isSelected())
    mChoice = true;
  else
    mChoice = false;
  }

}

Copyright © 1997, 2013 Oracle and/or its affiliates. All rights reserved. Legal Notices