Finally I solved issue with custom valuator!

I did not specify “formset” in the custom-rules.xml.

Simple example looks like.

 

1. custom-rules.xml

<!DOCTYPE form-validation PUBLIC

  "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.2.0//EN"

  "http://jakarta.apache.org/commons/dtds/validator_1_2_0.dtd">

 

<form-validation>

  <global>

            <validator name="minFloatValue"

              classname=" com.testing.ValidationUtil"

              method="isMinValue"

              methodParams="float,float"

              msg="errors.minValue"

      depends="float"

    />

  </global>

 

  <formset>

    <form name="org.apache.shale.validator.minFloatValue">

      <field property="minFloatValue">

        <arg position="0" name="message" key="arg" resource="false"/>

        <arg position="1" name="message" key="submittedValue" resource="false"/>

        <arg position="2" name="message" key="min" resource="false"/>

             

        <arg position="0" name="parameter" key="submittedValue" resource="false"/>

        <arg position="1" name="parameter" key="min" resource="false"/>

      </field>

    </form>

  </formset>

 

</form-validation>

 

2. shale-messages.properties

errors.minValue=The {0} should be biger {2}.

 

3. Java class.

package com.testing;

 

public class ValidationUtil

            implements java.io.Serializable

{

            public ValidationUtil(){}

 

            public static boolean isMinValue(float value, float minValue)

            {

                        boolean res = true;

                        if(value<minValue)

                                    res = false;

                        return res;

            }

}

 



From: Gary VanMatre [mailto:[EMAIL PROTECTED]
Sent: Friday, July 07, 2006 3:53 PM
To: MyFaces Discussion
Subject: RE: Shale Validation Framework Issue.

The commons validator was upgraded for 1.3 support.  The method for registering a new validation rule has changed. 
 
 
The original ticket:
http://issues.apache.org/struts/browse/SHALE-36
 
There is a bit of java doc on this here: 
http://struts.apache.org/struts-shale/shale-core/apidocs/org/apache/shale/validator/CommonsValidator.html
 
The standard rules config:
http://svn.apache.org/viewvc/shale/trunk/shale-core/src/main/resources/org/apache/shale/validator/validator-rules.xml?view=log

Gary
-------------- Original message --------------
From: "Iakouchev Alexander-EAL027C" <[EMAIL PROTECTED]>

> Thank you Matthias.
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
> Matthias Wessendorf
> Sent: Friday, July 07, 2006 2:33 PM
> To: MyFaces Discussion
> Subject: Re: Shale Validation Framework Issue.
>
> Maybe this question is better addressed on the *new* shale user list
>
>
>
> On 7/7/06, Alex Yakushev <[EMAIL PROTECTED]>wrote:
> >
> > Hello everybody!
> > I am a new in Shale Validation Framework. Actually I got an error then
>
> > form submitted.
> >
> > 2006-07-07 13:52:21,401 [http-80-Processor23] WARN
> >! org.ap ache.commons.validator .ValidatorResources - Form
> > 'org.apache.shale.validator.minFloatValue' not found for locale
> > 'en_US'
> > 2006-07-07 13:52:21,401 [http-80-Processor23] ERROR
> > StandardWrapper[/RPTCService sManagement:Faces Servlet] -
> > Servlet.service() for servlet Faces Servlet threw e xception
> > java.lang.NullPointerException
> > at
> > org.apache.shale.validator.CommonsValidator.getArgs(CommonsValidator.
> > java:621)
> > at
> > org.apache.shale.validator.CommonsValidator.getMethodParamNames(Commo
> > nsValidator.java:585)
> > at
> > org.apache.shale.validator.CommonsValidator.loadMethodParamValues(Com
> > monsValidator.java:715)
> > at
> > org.apache.shale.validator.CommonsValidator.validate(CommonsValidator
> > .java:798)
> > at
> > javax.faces.component._! Compone ntUtils.callValidators(_ComponentUtils.
> > java:157)
> > at
> javax.faces.component.UIInput.validateValue(UIInput.java:312)
> > at javax.faces.component.UIInput.validate(UIInput.java:353)
> > at
> javax.faces.component.UIInput.processValidators(UIInput.java:183)
> > at
> > javax.faces.component.UIComponentBase.processValidators(UIComponentBa
> > se.java:624)
> > at
> > javax.faces.component.UIComponentBase.processValidators(UIComponentBa?
> >
> > That is wrong with my code?
> > Seems, information from custom-rules.xml file loaded properly, but it
> > is looks like minFloatValue method can not findound.
> >
> > INFO: Loading validation rules file from /WEB-INF/custom-rules.xml
> > 2006-07-07 13:52:16,714 [http-80-Processor24] WARN
> > org.apache.myfaces.renderkit .html.util.ReducedHTMLParser - ! Invalid
> > tag found: unexpected input while looking
> >
> > 1. /WEB-INF/web.xml
> >
> >
> >
> org.apache.shale.validator.VALIDATOR_RULES
> >
> > /org/apache/shale/validator/validator-rules.xml,
> > /WEB-INF/custom-rules.xml
> >
> >

> >
> > 2. /WEB-INF/custom-rules.xml
> >
> > > > "-//Apache Software Foundation//DTD Commons Validator Rules
> > Configuration 1.2.0//EN"
> > "http://jakarta.apache.org/commons/dtds/validator_1_2_0.dtd">
> >
> >
> > > > classname="test.ValidationUtil"
> > method="isMinFloatValue"
> > methodParams="java.lang.Object"
> &g! t; msg= "errors.minFloatValue">
> >

> >

> >
> >
> > 3. /WEB-INF/faces-config.xml
> >
> > mot.resource.shale_messages
> >
> > en
> > en
> >

> >

> >
> > 4. ValidationUtil Class.
> > package test.jobmaintenance;
> >
> > public class ValidationUtil
> > implements java.io.Serializable {
> > public static boolean isMinFloatValue(Object value1)
> > {
> > System.out.println("++++++++++++++++++ RECEIVED VALUE1 "+value1);
> > return false;
> > }
> > }
> >
> > 5. JSP Page.
> > > styleClass="ErrorM! essage"
> > rendered="#{mtJobEditor.isEditableAdminFee}"/>
> > > value="#{mtJobEditor.job.tmpAdminFee}"
> > rendered="#{mtJobEditor.isEditableAdminFee}"
> > maxlength="10" size="10"
> > tabindex="-1"
> > >
> > > > type="minFloatValue"
> > server="true"
> > client="false"
> > />
> >

> > > rendered="#{!mtJobEditor.isEditableAdminFee}"
> > value="#{mtJobEditor.job.tmpAdminFee}"
> > />
> >
> > I will be appreciating for any feed back.
> > Alex.
> >
> >
> > --
> > View this message in context:
> > http://www.nabble.com/Shale-Validation-Framework-Issue.-tf1907955.html
> > #a5222352 Sent from the MyFaces - Users forum at Nabble! .com. < BR>> >
> >
>
>
> --
> Matthias Wessendorf
>
> futher stuff:
> blog: http://jroller.com/page/mwessendorf
> mail: mwessendorf-at-gmail-dot-com

Reply via email to