예제 #1
0
  /**
   * called by the dropdownchoice when its selection changes to hide/make visible panels that deal
   * with range limits and the 'Other/Specify' check box the value we get from the ajax onUpdate
   * getModelValue() is a string indicating the position of the selected choice in the drop down
   *
   * @param iValue
   */
  protected void onSelectionChanged(int iValue) {
    boolean numericLimitsVisible = false;
    boolean multipleSelectionLimitsVisible = false;
    boolean timeSpanUnitsVisible = false;
    boolean otherSpecifyVisible = false;
    boolean listLimitsVisible = false;
    boolean isListStyle = (Boolean) askingStyleModel.getObject();

    switch (iValue) {
      case 0: // TEXT
        break;
      case 1: // NUMERIC
        numericLimitsVisible = true;
        break;
      case 2: // DROP_DOWN - single SELECTION
        otherSpecifyVisible = true;
        listLimitsVisible = isListStyle;
        break;
      case 3: // MULTIPLE_SELECTION
        multipleSelectionLimitsVisible = true;
        otherSpecifyVisible = true;
        listLimitsVisible = isListStyle;
        break;
      case 4: // DATE
      case 5: // TIME_SPAN
        timeSpanUnitsVisible = true;
        break;
    }

    numericLimitsPanel.setVisible(numericLimitsVisible);
    multipleSelectionLimitsPanel.setVisible(multipleSelectionLimitsVisible);
    noneButtonLabel.setVisible(multipleSelectionLimitsVisible);
    noneButtonCheckBox.setVisible(multipleSelectionLimitsVisible);
    otherSpecifyLabel.setVisible(otherSpecifyVisible);
    otherSpecifyCheckBox.setVisible(otherSpecifyVisible);
    timeUnitsPanel.setVisible(timeSpanUnitsVisible);
    timeUnitsPanel.setWeeksVisible((iValue == 5) ? true : false);
    listLimitsPanel.setVisible(listLimitsVisible);
  }