You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by stanlick <st...@gmail.com> on 2007/08/17 22:00:01 UTC

S2 XML Validation

I am trying to figure out the <validator type="expression"> and not having
much success.  Can someone tell me what is wrong with this?


	<field name="model.password">
		<field-validator type="requiredstring">
			<message key="requiredstring" />
		</field-validator>
	</field>
	<field name="model.confirmPassword">
		<field-validator type="requiredstring">
			<message key="requiredstring" />
		</field-validator>
	</field>
	<validator type="expression">
		
			model.password.equals(model.confirmPassword)
		
		<message>${getText("nomatch")} ${min} and ${max}</message>
	</validator>
-- 
View this message in context: http://www.nabble.com/S2-XML-Validation-tf4287832.html#a12206250
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: S2 XML Validation

Posted by Laurie Harper <la...@holoweb.net>.
stanlick wrote:
> I am trying to figure out the <validator type="expression"> and not having
> much success.  Can someone tell me what is wrong with this?
> 
> 
> 	<field name="model.password">
> 		<field-validator type="requiredstring">
> 			<message key="requiredstring" />
> 		</field-validator>
> 	</field>
> 	<field name="model.confirmPassword">
> 		<field-validator type="requiredstring">
> 			<message key="requiredstring" />
> 		</field-validator>
> 	</field>
> 	<validator type="expression">
> 		
> 			model.password.equals(model.confirmPassword)
> 		
> 		<message>${getText("nomatch")} ${min} and ${max}</message>
> 	</validator>

The documentation is ambiguous, since the description says the validator 
uses a regular expression but the parameter description says it uses an 
OGNL expression. Assuming the latter is correct, you might try changing 
your expression to 'model.password == model.confirmPassword', though I 
would have thought what you have would work.

What's actually happening with what you have? Do you get any errors 
logged? Are the other validations working correctly? I'm assuming it's 
just a typo that your expression is not wrapped in <param 
name="expression"> </param> tags, and that you have a message that 
doesn't seem to be relevant to the validation?

If you're still having problems, make sure to post the exact code that 
you're actually using and describe exactly what is happening (or not 
happening) as a result.

L.


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