Beware that if you remove the conversionError from your stack, whatever value
was typed (that could not be converted) will *not* be represented when the
screen is redisplayed. Dave's right about the message, but I have
overridden the default message with the one below and it is a little more
meaningful.
xwork.default.invalid.fieldvalue=Are you kidding me? Unable to convert
"{0}" to the expected type
Peace,
Scott
newton.dave wrote:
>
> Conversion errors are added to the list of field errors by the
> "conversionError" interceptor.
>
> Personally, I almost always remove the "conversionError" as the
> conversion error messages aren't necessarily helpful, and are sometimes
> redundant--your mileage may vary.
>
> But that's why you get both messages.
>
> Dave
>
> Robert Stenholt Mygind wrote:
>> Hi All
>>
>> I have some problems with field validation in Struts2, I am not the
>> most experienced in Struts2.
>>
>> </SNIP>
>> I have a form looking something like this:
>> <s:form action="calcprices" method="post">
>> <s:textfield name="subscriptions" label="Some tekst:"/>
>> ..
>> <s:submit name="submit" value="Calc"></s:submit>
>> </s:form>
>> </SNIP>
>>
>> In my acrion class I have something looking like:
>> <SNIP>
>> @RequiredFieldValidator(message = "Some error text", shortCircuit=true)
>> public Integer getSubscriptions() {
>> return subscriptions;
>> }
>> </SNIP>
>>
>> The field is a Integer field, so if I insted write "test" in it I get
>> the following HTML:
>> <SNIP>
>> <div id="wwerr_calcprices_subscriptions" class="wwerr">
>> <div errorFor="calcprices_subscriptions" class="errorMessage">
>> Invalid field value for field "subscriptions".
>> </div>
>> <div errorFor="calcprices_subscriptions" class="errorMessage">
>> Some error text
>> </div>
>> </div>
>> </SNIP>
>>
>> The first is the default from "invalid.fieldvalue" and the second is
>> the one I made.. I only wish to have the secound, in some kind of
>> override. I also tried to use
>> @ConversionErrorFieldValidator(message = "Default message")
>> @RequiredFieldValidator(message = "Some error text", shortCircuit=true)
>>
>> and that is the same, get both errors..
>>
>> I don't have any idea what to do, maybe I have misunderstood the
>> Struts2 validation completely. Hope you can help.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
--
View this message in context:
http://www.nabble.com/Stuts2-field-validation-problems-tp21401218p21508688.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]