Package org.apache.commons.validator

Examples of org.apache.commons.validator.ValidatorResources


     *
     * @exception IOException if an input/output error is encountered
     * @exception ServletException if we cannot initialize these resources
     */
    protected void initMapping() throws IOException, ServletException {
  resources = new ValidatorResources();
 
  // Initialize the context-relative path to our configuration resources
  String value = null;
  value = getServletConfig().getInitParameter("config-rules");
  if (value != null) {
View Full Code Here


     * @exception JspException if a JSP exception has occurred
    */
    public int doStartTag() throws JspException {
       StringBuffer results = new StringBuffer();
      
       ValidatorResources resources = (ValidatorResources)
          pageContext.getAttribute(ValidatorPlugIn.VALIDATOR_KEY, PageContext.APPLICATION_SCOPE);

       Locale locale = null;
       try {
           locale = (Locale) pageContext.getAttribute(Action.LOCALE_KEY, PageContext.SESSION_SCOPE);
       } catch (IllegalStateException e) {  // Invalidated session
           locale = null;
       }
      
       if (locale == null) {
           locale = defaultLocale;
       }

       Form form = null;
       if ((form = resources.get(locale, formName)) != null && "true".equals(dynamicJavascript)) {
          MessageResources messages = (MessageResources)
             pageContext.getAttribute(bundle, 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(); ) {
             ValidatorAction va = resources.getValidatorAction((String)i.next());
            
             String javascript = va.getJavascript();
             if (javascript != null && javascript.length() > 0) {
                lActions.add(va);
             } else {
View Full Code Here

   */
   public static Validator initValidator(String key, Object bean,
                                         ServletContext application, HttpServletRequest request,
                                         ActionErrors errors, int page) {

      ValidatorResources resources = StrutsValidatorUtil.getValidatorResources(application);
      Locale locale = StrutsValidatorUtil.getLocale(request);
     
      Validator validator = new Validator(resources, key);
      validator.setUseContextClassLoader(true);
     
View Full Code Here

    try {
      InputStream[] inputStreams = new InputStream[validationConfigLocations.length];
      for (int i = 0; i < inputStreams.length; i++) {
        inputStreams[i] = validationConfigLocations[i].getInputStream();
      }
      this.validatorResources = new ValidatorResources(inputStreams);
    } catch (IOException e) {
      throw new FatalBeanException("Unable to read validation configuration due to IOException.", e);
    } catch (SAXException e) {
      throw new FatalBeanException("Unable to parse validation configuration XML", e);
    }
View Full Code Here

     */
    public static void main(String[] args)
        throws ValidatorException, IOException, SAXException {
           
        InputStream in = null;
        ValidatorResources resources = null;
       
        try {
       
            // Create a new instance of a ValidatorResource, then get a stream
            // handle on the XML file with the actions in it, and initialize the
            // resources from it.  This would normally be done by a servlet
            // run during JSP initialization or some other application-startup
            // routine.
            in = ValidateExample.class.getResourceAsStream("validator-example.xml");
            resources = new ValidatorResources(in);
           
        } finally {
            // Make sure we close the input stream.
            if (in != null) {
                in.close();
View Full Code Here

     * @exception JspException if a JSP exception has occurred
    */
    public int doStartTag() throws JspException {
       StringBuffer results = new StringBuffer();

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

       Locale locale = null;
       try {
           locale = (Locale) pageContext.getAttribute(Action.LOCALE_KEY, PageContext.SESSION_SCOPE);
       } catch (IllegalStateException e) {  // Invalidated session
           locale = null;
       }

       if (locale == null) {
           locale = defaultLocale;
       }

       Form form = null;
       if ((form = resources.get(locale, formName)) != null && "true".equals(dynamicJavascript)) {
          MessageResources messages = (MessageResources)
             pageContext.getAttribute(bundle, 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(); ) {
             ValidatorAction va = resources.getValidatorAction((String)i.next());

             String javascript = va.getJavascript();
             if (javascript != null && javascript.length() > 0) {
                lActions.add(va);
             } else {
View Full Code Here

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

       if (pathnames != null && pathnames.length() > 0) {
          StringTokenizer st = new StringTokenizer(pathnames, RESOURCE_DELIM);

          while (st.hasMoreTokens()) {
View Full Code Here

   */
   public static Validator initValidator(String key, Object bean,
                                         ServletContext application, HttpServletRequest request,
                                         ActionErrors errors, int page) {

      ValidatorResources resources = StrutsValidatorUtil.getValidatorResources(application);
      Locale locale = StrutsValidatorUtil.getLocale(request);

      Validator validator = new Validator(resources, key);
      validator.setUseContextClassLoader(true);

View Full Code Here

        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 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

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.