Package de.odysseus.calyxo.base.conf

Examples of de.odysseus.calyxo.base.conf.ConfigException


  protected void init() throws Exception {
    super.init();

    selectTag = (SelectTag)findAncestor(SelectTag.class);
    if (selectTag == null) {
      throw new ConfigException("A listoptions tag must be nested in a select tag!");
    }
    if (selectTag.getListModel() == null) {
      throw new ConfigException("A listoptions tag requires a listModel in select tag '" +  selectTag.getName() + "'!");
    }
    if (selection != null && !selectTag.getGroupModel().isSelectionAvailable()) {
      if (selection instanceof String) {
        key = (String)selection;
        if (!selectTag.isSelectable(key)) {
          throw new ConfigException("A selected list option for select '" + selectTag.getName() + "' contains invalid value '" + key + "'!");
        }
      } else if (selection instanceof String[]) {
        String[] strings = (String[])selection;
        if (!selectTag.getGroupModel().isMultiple() && strings.length > 1) {
          throw new ConfigException("A single selection must be of size <= 1 in '" + selectTag.getName() + "'!");
        }
        keys = new HashSet(strings.length);
        for (int i = 0; i < strings.length; i++) {
          if (!selectTag.isSelectable(strings[i])) {
            throw new ConfigException("A selected list option for select '" + selectTag.getName() + "' contains invalid value '" + strings[i] + "'!");
          }
          keys.add(strings[i]);
        }
      } else {
        throw new ConfigException("Unsupported object type in selection: " + keys.getClass() + " (must be String or String[])");
      }
    }

  }
View Full Code Here


    Class clazz = null;
    if (className != null) {
      try {
        clazz = loader.loadClass(className);
      } catch (Exception e) {
        throw new ConfigException("Could not get class in " + toInlineString(), e);
      }
    } else if (value != null) {
      clazz = value.getClass();
    } else {
      throw new ConfigException("Cannot get member from null in " + toInlineString());
    }
    if (method != null) {
      return method.invoke(clazz, value, loader);
    } else {
      return field.get(clazz, value);
View Full Code Here

  }

  protected void checkMultiple() throws Exception {
    if (getContext().isMultiple(this)) {
      if (getValue() == null) {
        throw new ConfigException("An array checkbox requires a value!");
      }
    }
  }
View Full Code Here

   */
  protected void init() throws Exception {
    super.init();

    if (getIndex() >= 0 && size > 1) {
      throw new ConfigException("An indexed selection requires size == 1");
    }
  }
View Full Code Here

    checkMultiple();
  }

  protected void checkMultiple() throws Exception {
    if (getContext().isMultiple(this))
      throw new ConfigException("Radio buttons cannot map to an array!");
  }
View Full Code Here

   * (non-Javadoc)
   * @see de.odysseus.calyxo.base.conf.impl.ConfigImpl#_resolve(javax.servlet.jsp.el.ExpressionEvaluator, javax.servlet.jsp.el.VariableResolver)
   */
  protected void _resolve(ExpressionEvaluator evaluator, VariableResolver variables) throws ConfigException {
    if ((value == null) == (member == null)) {
      throw new ConfigException("Either value attribute or nested member element required in " + toInlineString());
    }
    super._resolve(evaluator, variables);
  }
View Full Code Here

    super._evaluate(context);

    ClassLoader loader = context.getClassLoader();
    Object object = member == null ? value : member.get(loader);
    if (object == null) {
      throw new ConfigException("Cannot use null in " + toInlineString());
    }
    apply(object, loader);
  }
View Full Code Here

    FormsRootConfigImpl formsRootConfig =
      (FormsRootConfigImpl)_getNearestAncestor(FormsRootConfigImpl.class);
    ValidatorsConfig validators = formsRootConfig.getValidatorsConfig();
    validatorConfig = getValidatorFrom(validators);
    if (validatorConfig == null) {
      throw new ConfigException("Could not find validator named " + name + " in '" + toInlineString() + "'");
    }
  }
View Full Code Here

      MessageConfig fieldMessage = getFieldConfig().getMessageConfig();
      if (fieldMessage != null && fieldMessage.getKey() != null) {
        baseMessage = fieldMessage;
      }
      if (baseMessage == null) {
        throw new ConfigException("No base message in validator '" + name + "' in '" + toInlineString() + "'");
      } else if (baseMessage.getKey() == null) {
        throw new ConfigException("No key for message in validator '" + name + "' in '" + toInlineString() + "'");
      }
      Iterator args = message.getArgConfigs();
      while (args.hasNext()) {
        ArgConfig arg = (ArgConfig)args.next();
        if (arg.getName() == null) {
          throw new ConfigException("Missing name for argument '" + arg + "' in '" + toInlineString() + "'");
        } else if (baseMessage.getArgConfig(arg.getName()) == null) {
          throw new ConfigException("No argument with name '" + arg.getName() + "' in base message of validator '" + name + "' in '" + toInlineString() + "'");
        }
      }
    }
    // make sure that all properties exist and are not final
    Iterator propertyConfigs = getPropertyConfigs();
    while (propertyConfigs.hasNext()) {
      PropertyConfig propertyConfig = (PropertyConfig)propertyConfigs.next();
      String name = propertyConfig.getName();
      ValidatorPropertyConfig validatorPropertyConfig =
        validatorConfig.getValidatorPropertyConfig(name);
      if (validatorPropertyConfig == null) {
        throw new ConfigException("Unknown property " + name + " in '" + toInlineString() + "'");
      }
      if (validatorPropertyConfig.isFinal()) {
        throw new ConfigException("Must not override property " + name + " in '" + toInlineString() + "'");
      }
    }
    // make sure abstract validator properties are defined
//    Iterator validatorPropertyConfigs = validatorConfig.getValidatorPropertyConfigs();
//    while (validatorPropertyConfigs.hasNext()) {
View Full Code Here

   */
  protected void init() throws Exception {
    if (context == null) {
      context = (FormContext)pageContext.getRequest().getAttribute(FORM_CONTEXT_KEY);
      if (context == null) {
        throw new ConfigException("Cannot find form context!");
      }
    }
    context.check(this);
  }
View Full Code Here

TOP

Related Classes of de.odysseus.calyxo.base.conf.ConfigException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.