Package org.apache.commons.validator

Examples of org.apache.commons.validator.ValidatorResources


     *                    to this page value, it will be processed.
     */
    public static Validator initValidator(String key, Object bean,
        ServletContext application, HttpServletRequest request,
        ActionMessages errors, int page) {
        ValidatorResources resources =
            Resources.getValidatorResources(application, request);

        Locale locale = RequestUtils.getUserLocale(request, null);

        Validator validator = new Validator(resources, key);
View Full Code Here


            for (int urlIndex = 0; urlIndex < urlSize; urlIndex++) {
                urlArray[urlIndex] = (URL) urlList.get(urlIndex);
            }

            this.resources = new ValidatorResources(urlArray);
        } catch (SAXException sex) {
            log.error("Skipping all validation", sex);
            throw new ServletException(sex);
        }
    }
View Full Code Here

        throws JspException {
        StringBuffer results = new StringBuffer();

        ModuleConfig config =
            TagUtils.getInstance().getModuleConfig(pageContext);
        ValidatorResources resources =
            (ValidatorResources) pageContext.getAttribute(
              ValidatorPlugIn.VALIDATOR_KEY
                + config.getPrefix(), PageContext.APPLICATION_SCOPE);

        if (resources == null) {
            throw new JspException(
                "ValidatorResources not found in application scope under key \""
                + ValidatorPlugIn.VALIDATOR_KEY + config.getPrefix() + "\"");
        }

        Locale locale =
            TagUtils.getInstance().getUserLocale(this.pageContext, null);

        Form form = null;
        if ("true".equalsIgnoreCase(dynamicJavascript)) {
            form = resources.getForm(locale, formName);
            if (form == null) {
                throw new JspException("No form found under '" + formName
                    + "' in locale '" + locale
                    + "'.  A form must be defined in the "
                    + "Commons Validator configuration when "
View Full Code Here

   *
   */
  public ConstraintExceptionBuffer validate(ContentTypeDefinitionVO contentType, ContentVersionVO contentVersionVO, String languageCode) {
    try {
      ContentVersionBean bean = new ContentVersionBean(contentType, contentVersionVO, languageCode);
      ValidatorResources resources = loadResources(contentType, languageCode);
      Validator validator = new Validator(resources, "requiredForm");
      validator.setOnlyReturnErrors(true);
      validator.setParameter(Validator.BEAN_PARAM, bean);
      ValidatorResults results = validator.validate();
      if(results.isEmpty())
View Full Code Here

   *
   */
    private ValidatorResources loadResources(ContentTypeDefinitionVO contentType, String languageCode) {
    try {
      InputStream is = readValidatorXML(contentType, languageCode);
      return new ValidatorResources(is);
    } catch(Exception e) {
      logger.error("Error loading resource: " + e.getMessage());
    }
    return null;
    }
View Full Code Here

       
        // Look up this key to see if its a field of the current form
        boolean requiredField = false;
        boolean validationError = false;

        ValidatorResources resources = getValidatorResources();
       
        Locale locale = pageContext.getRequest().getLocale();

        if (locale == null) {
            locale = Locale.getDefault();
        }
       
        // get the name of the bean from the key
        String formName = key.substring(0, key.indexOf('.'));
        String fieldName = key.substring(formName.length() + 1);

        if (resources != null) {
            Form form = resources.getForm(locale, formName);

            if (form != null) {
                Field field = form.getField(fieldName);

                if (field != null) {
View Full Code Here

                 {
                     // TODO: support extensible user-defined validator resources
                     //is = this.getClass().getResourceAsStream("/org/apache/portals/bridges/velocity/validation/default-portlet-validation.xml");
                     is = config.getPortletContext().getResourceAsStream(validatorConfig);                   
                    
                     validations = new ValidatorResources(is);
                 }
                 catch (Exception e)
                 {
                     throw new PortletException("Failed to load validator configuration.", e);
                 }
View Full Code Here

TOP

Related Classes of org.apache.commons.validator.ValidatorResources

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.