Package org.apache.shale.validator

Examples of org.apache.shale.validator.CommonsValidator


            Iterator ti = typeMap.entrySet().iterator();
            while (ti.hasNext()) {

                Map.Entry idEntry = (Map.Entry) ti.next();
                String id = (String) idEntry.getKey();
                CommonsValidator v = (CommonsValidator) idEntry.getValue();
                String formName = v.getFormName();

                Map formTypeMap = (Map) formValidators.get(formName);
                if (formTypeMap == null) {
                    formTypeMap = new LinkedHashMap();
                    formValidators.put(formName, formTypeMap);
View Full Code Here


      if (c instanceof EditableValueHolder && c.isRendered()) {
         EditableValueHolder h = (EditableValueHolder) c;
         javax.faces.validator.Validator[] vs = h.getValidators();
         for (int i = 0; i < vs.length; i++) {
            if (vs[i] instanceof CommonsValidator) {
               CommonsValidator v = (CommonsValidator) vs[i];
               v.setFormName(findForm(context, c));
               if (Boolean.TRUE.equals(v.getClient())) {

                   //look for the clientId set
                   Map clientIds = (Map) c.getAttributes().get(ValidatorInputRenderer.VALIDATOR_CLIENTIDS_ATTR);
                   if (clientIds != null) {

                      validatorVars.putAll(clientIds);
                      Iterator ci = clientIds.entrySet().iterator();
                      while (ci.hasNext()) {
                         Map.Entry e = (Map.Entry) ci.next();

                         String id = (String) e.getKey();
                         addValidator(v.getType(), id, v);

                         ValidatorAction action = v.getValidatorAction();
                         List list = action.getDependencyList();
                         Iterator iter = list.iterator();
                         while (iter.hasNext()) {
                             String type = (String) iter.next();
                             addValidator(type, id, v);
                         }

                      }

                   } else {
                       //otherwise just try using the client id
                       String id = c.getClientId(context);
                       addValidator(v.getType(), id, v);

                       ValidatorAction action = v.getValidatorAction();
                       List list = action.getDependencyList();
                       Iterator iter = list.iterator();
                       while (iter.hasNext()) {
                           String type = (String) iter.next();
                           addValidator(type, id, v);
                       }
                   }

               }
               if (Boolean.TRUE.equals(v.getServer())) {
                  // Fields with empty values are not validated, so
                  // we force the issue here by setting the component's
                  // required attribute to true.

                  if ("required".equals(v.getType())) {
                     h.setRequired(true);
                  }
               }
            }
         }
View Full Code Here

              Map map = (Map) formTypeValidators.get(type);
              Iterator iter2 = map.keySet().iterator();
              int k = 0;
              while (iter2.hasNext()) {
                  String id = (String) iter2.next();
                  CommonsValidator v = (CommonsValidator) map.get(id);
                  writer.write("this[" + k + "] = ");
                  k++;
                  writeJavaScriptParams(writer, context, id, v);
                  writer.write(";\n");
              }
View Full Code Here

     *    values.
     *
     * @exception JspException if a JSP processing error occurs
     */
   public Validator createValidator() throws JspException {
      CommonsValidator validator = (CommonsValidator) super.createValidator();

      // parameters for specific validators
      if (min != null) {
          validator.setMin(min);
      }
      if (max != null) {
          validator.setMax(max);
      }
      if (minlength != null) {
          validator.setMinLength(minlength);
      }
      if (maxlength != null) {
          validator.setMaxLength(maxlength);
      }
      if (datePatternStrict != null) {
          validator.setDatePatternStrict(datePatternStrict);
      }
      if (mask != null) {
          validator.setMask(mask);
      }
      if (arg != null) {
          validator.setArg(arg);
      }

      Tags tagUtils = new Tags();

      // these properties require early binding
      validator.setType(tagUtils.evalString(type));
      validator.setMessage(tagUtils.evalString(message));
      validator.setClient(tagUtils.evalBoolean(client));
      validator.setServer(tagUtils.evalBoolean(server));

      tagUtils = null;

      // pass the parameters specified through <s:validatorVar>
      // if these vars contain binding expressions, they are
      // evaluated late
      if (params != null) {
         for (Iterator iterator = params.entrySet().iterator(); iterator.hasNext();) {
            Map.Entry e = (Map.Entry) iterator.next();
            Object key = e.getKey();
            Object value = e.getValue();
            validator.getVars().put(key, value);
         }
      }

      return validator;
   }
View Full Code Here

                Validator[] validators = editableComponent.getValidators();
                // look for components using CommonsValidator
                for (int i = 0; i < validators.length; i++) {
                    if (validators[i] instanceof CommonsValidator) {
                       CommonsValidator validator = (CommonsValidator) validators[i];

                       // look for a map of var's by component type
                       Map localVars = (Map) validatorVars.get(validator.getType());
                       if (localVars == null) {
                           localVars = new TreeMap();
                           validatorVars.put(validator.getType(), localVars);
                       } else {
                           localVars.clear();
                       }

                       Map vars = validator.getVars();
                       Iterator vi = vars.entrySet().iterator();
                       while (vi.hasNext()) {
                          Map.Entry e = (Map.Entry) vi.next();
                          // only override if the var contains a value binding expression
                          if (e.getValue() != null && e.getValue() instanceof String
View Full Code Here

TOP

Related Classes of org.apache.shale.validator.CommonsValidator

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.