struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Iakouchev Alexander-EAL027C" <EAL0...@motorola.com>
Subject RE: Shale Validation Framework Issue.
Date Mon, 10 Jul 2006 17:58:33 GMT
Hello Gary!
Thank you for reply.
Alex.

-----Original Message-----
From: Gary VanMatre [mailto:gvanmatre@comcast.net] 
Sent: Monday, July 10, 2006 1:13 PM
To: user@struts.apache.org
Subject: Re: Shale Validation Framework Issue.

Please take future Shale discussions to the shale mailing list.
http://shale.apache.org/mail-lists.html

>----- Original Message -----
>From: "Iakouchev Alexander-EAL027C" <EAL027C@motorola.com>
>To: <user@struts.apache.org>
>Sent: Monday, July 10, 2006 8:56 AM
>Subject: Shale Validation Framework Issue.
>

>Hello everybody!
>I am a new in Shale Validation Framework. Actually I got an error after
>form was submitted.
>My Tomahawk version - 1.1.3.
>
>
>[http-80-Processor24] WARN
>org.apache.commons.validator.ValidatorResources - Form
>'org.apache.shale.validator.minStringValue' not found for locale
'en_US'
>
>2006-07-10 10:00:08,784 [http-80-Processor24] ERROR
>StandardWrapper[/RPTCServicesManagement:Faces Servlet] -
>Servlet.service() for servlet Faces Servlet threw exception
>
>java.lang.NullPointerException
>
>at
>org.apache.shale.validator.CommonsValidator.getArgs(CommonsValidator.ja
v
>a:621)

[snippet]

>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

[snippet]

>2. /WEB-INF/custom-rules.xml


You need to add the formset/form for your custom validation rule.  The
form 
is used to define the message key parameters and the parameters used
when 
calling the validation method.

<form-validation>
<global>
<validator name="minStringValue" 
classname="mot.aptc.rptc.jobmaintenance.ValidationUtil"
       method="isMinStringValue" methodParams="java.lang.String" 
msg="errors.minFloatValue">
</validator>
</global>
   <formset>
      <form name="org.apache.shale.validator.minStringValue">
          <field property="required">
              <arg position="0" name="message" key="arg"
resource="false"/>
              <arg position="1" name="message" key="submittedValue" 
resource="false"/>

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

              <arg position="1" name="parameter" key="minLength" 
resource="false"/>
          </field>
      </form>
    </formset>
</form-validation>



The "message" args above define the parameters for the MessageFormat
class. 
If you have a message like "{0} is invalid.  The value {1} is not long 
enough.", the first parameter would be the commons validators arg value
and 
the second the submitted value of the component.

The "parameter" args define the values for the method signature of the 
target validation rule.  I add the second "minLength" parameter above to

show how you might want to make the length a variable.

public static boolean isMinStringValue(String value1, int minLength)

You define this "formset/form" definition once per custom validation
rule 
and then override it at the component level versus each html form.  For 
example, if you wanted to change the validation message you could
override 
that at the component level.

<s:commonsValidator  type="minStringValue" server="true" client="false" 
arg="Last Name"/>

Or

<s:commonsValidator  type="minStringValue" server="true" client="false"
/>
    <s:validatorVar name="arg" value="Last Name"/>
    <s:validatorVar name="minLength" value="10"/>
</s:commonsValidator>


>I will be appreciating for any feed back.
>Alex.

Gary

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message