You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by roger <ro...@googlemail.com> on 2011/09/22 09:56:28 UTC

Problem with @ConversionErrorFieldValidator

Hi

In my struts 2 action I'm using the @VistorFieldValidator

@VisitorFieldValidator(message="",appendPrefix=true)
public Rma getRma() {
	return rma;
}

and within the RMA class I'm using 

	@ConversionErrorFieldValidator(message = "Serial Number must be numeric",
shortCircuit=true) 
	public void setSerialNumber(int serialNumber) {
		this.serialNumber = serialNumber;
	}

When I try to enter a non-numeric value into the serialNumber in my .jsp
page I'm getting two
fielderror messages returned.

"Invalid Field Value for field 'rma.serialNumber.'" and "Serial Number must
be numeric". I'm assuming that the first message is generated by the inbuilt
conversion routines. Is it possible to suppress the generation of this
message or am I going to have to override getFieldErrors() in my action to
remove them?

Regards


--
View this message in context: http://struts.1045723.n5.nabble.com/Problem-with-ConversionErrorFieldValidator-tp4829326p4829326.html
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: Problem with @ConversionErrorFieldValidator

Posted by roger <ro...@googlemail.com>.
I've been taking a look at this and I think that the reason for the double
message is that conversion errors are being handled twice, firstly by the
StrutsConversionErrorInterceptor and again by the
AnnotationValidationInterceptor. Both these interceptors are in the
struts-default stack.

Removing the StrutsConversionErrorInterceptor from the stack removes the
Struts generated message and leaves the user defined message as the only
error message displayed. 

Are there any other implications to removing the
StrutsConversionErrorInterceptor from my interceptor stack?

Regards


--
View this message in context: http://struts.1045723.n5.nabble.com/Problem-with-ConversionErrorFieldValidator-tp4829326p4833549.html
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