Package org.apache.commons.validator

Examples of org.apache.commons.validator.ValidatorResources


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

        HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
        ModuleConfig config = ModuleUtils.getInstance().getModuleConfig(request);
        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


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

     */
    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 = null;
        try {
            locale =
                (Locale) pageContext.getAttribute(Globals.LOCALE_KEY, PageContext.SESSION_SCOPE);
        } catch (IllegalStateException e) { // Invalidated session
            locale = null;
        }

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

        Form form = null;
        form = resources.get(locale, formName);
        if (form != null) {
            if ("true".equals(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

     *
     * @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 {
        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 = Resources.getValidatorResources(application,request);
      Locale locale = Resources.getLocale(request);

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

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.setPage(page);
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();
 
       for (Iterator i = lValidatorRules.iterator(); i.hasNext(); ) {
          String validatorRules = (String)i.next();

    if (log.isInfoEnabled()) {
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(ValidatorServlet.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();
 
       for (Iterator i = lValidatorRules.iterator(); i.hasNext(); ) {
          String validatorRules = (String)i.next();

    if (log.isInfoEnabled()) {
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.