コード例 #1
0
  /**
   * This methods receives and processes input made by the user. More specifically, it ckecks
   * whether the user has interacted with the current b:switchWidget. The default implementation
   * simply stores the input value in the list of submitted values. If the validation checks are
   * passed, the values in the <code>submittedValues</code> list are store in the backend bean.
   *
   * @param context the FacesContext.
   * @param component the current b:switchWidget.
   */
  @Override
  public void decode(FacesContext context, UIComponent component) {
    Switch switchWidget = (Switch) component;

    if (switchWidget.isDisabled() || switchWidget.isReadonly()) {
      return;
    }

    decodeBehaviors(context, switchWidget);

    String clientId = switchWidget.getClientId(context);
    String submittedValue =
        (String) context.getExternalContext().getRequestParameterMap().get(clientId);

    if (submittedValue != null) {
      switchWidget.setSubmittedValue(submittedValue);
    }
  }