Package org.apache.commons.validator

Examples of org.apache.commons.validator.ValidatorResources


     *
     * @exception IOException if an input/output error is encountered, not thrown by this implementation
     * @exception ServletException if we cannot initialize these resources, not thrown by this implementation
     */
    protected void initResources() throws IOException, ServletException {
        this.resources = new ValidatorResources();

        if (pathnames == null || pathnames.length() <= 0) {
            return;
        }

View Full Code Here


     */
    public int doStartTag() throws JspException {
        StringBuffer results = new StringBuffer();

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

        Locale locale = RequestUtils.retrieveUserLocale(this.pageContext, null);

        Form form = resources.get(locale, formName);
        if (form != null) {
            if ("true".equalsIgnoreCase(dynamicJavascript)) {
                MessageResources messages =
                    (MessageResources) pageContext.getAttribute(
                        bundle + config.getPrefix(),
                        PageContext.APPLICATION_SCOPE);

                List lActions = new ArrayList();
                List lActionMethods = new ArrayList();

                // Get List of actions for this Form
                for (Iterator i = form.getFields().iterator(); i.hasNext();) {
                    Field field = (Field) i.next();

                    for (Iterator x = field.getDependencies().iterator(); x.hasNext();) {
                        Object o = x.next();

                        if (o != null && !lActionMethods.contains(o)) {
                            lActionMethods.add(o);
                        }
                    }

                }

                // Create list of ValidatorActions based on lActionMethods
                for (Iterator i = lActionMethods.iterator(); i.hasNext();) {
                    String depends = (String) i.next();
                    ValidatorAction va = resources.getValidatorAction(depends);

                    // throw nicer NPE for easier debugging
                    if (va == null) {
                        throw new NullPointerException(
                            "Depends string \""
View Full Code Here

   *                    fields.  If the field's page is less than or equal
   *                    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

        URL url = (URL) urlList.get(urlIndex);

        urlArray[urlIndex] = url.toExternalForm();
      }

      this.resources = new ValidatorResources(urlArray);
    } catch (SAXException sex) {
      log.error("Skipping all validation", sex);
      throw new ServletException(sex);
    }
  }
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

            for (int streamIndex = 0;streamIndex < streamSize;streamIndex++) {
                InputStream is = (InputStream) streamList.get(streamIndex);
                streamArray[streamIndex] = is;
            }

            this.resources = new ValidatorResources(streamArray);
        } catch (SAXException sex) {
            log.error("Skipping all validation",sex);
            throw new ServletException(sex);
        } finally {
            Iterator streamIterator = streamList.iterator();
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

            log.info("Initializing Validator Integration");
        }

        // Configure and cache the validator resources for this application
        ServletContext context = event.getServletContext();
        ValidatorResources resources = null;
        try {
            resources = validatorResources(context);
        } catch (IllegalArgumentException e) {
            throw e;
        } catch (IOException e) {
View Full Code Here

        for (int i = 0; i < array.length; i++) {
            array[i] = ((URL) urls.get(i)).toExternalForm();
        }
       
        // Construct and return a new ValidatorResources instance
        return new ValidatorResources(array);

    }
View Full Code Here

          (HttpServletRequest)pageContext.getRequest();
        ServletContext servletContext = pageContext.getServletContext();
        ModuleConfig config =
          ModuleUtils.getInstance().getModuleConfig(request, servletContext);

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

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

        Form form = resources.getForm(locale, formName);
        if (form != null) {
            if ("true".equalsIgnoreCase(dynamicJavascript)) {
                MessageResources messages =
                    (MessageResources) pageContext.getAttribute(
                        bundle + config.getPrefix(),
                        PageContext.APPLICATION_SCOPE);

                List lActions = new ArrayList();
                List lActionMethods = new ArrayList();

                // Get List of actions for this Form
                for (Iterator i = form.getFields().iterator(); i.hasNext();) {
                    Field field = (Field) i.next();

                    for (Iterator x = field.getDependencyList().iterator();
                        x.hasNext();) {
                        Object o = x.next();

                        if (o != null && !lActionMethods.contains(o)) {
                            lActionMethods.add(o);
                        }
                    }

                }

                // Create list of ValidatorActions based on lActionMethods
                for (Iterator i = lActionMethods.iterator(); i.hasNext();) {
                    String depends = (String) i.next();
                    ValidatorAction va = resources.getValidatorAction(depends);

                    // throw nicer NPE for easier debugging
                    if (va == null) {
                        throw new NullPointerException(
                            "Depends string \""
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.