by default the message should bring the error with it, thus
ValidationErrorFeedback. this is so users can customize feedbackpanels
and get access to ValidationError instances.

sounds like your code should check for ValidationErrorFeedback and
pull your message out of it...

-igor


On Wed, Mar 14, 2012 at 8:48 AM, Martin Grigorov <mgrigo...@apache.org> wrote:
> You almost got it :-)
> Returning Serializable instead of String is half of it.
> The other half is to replace
>
> error(new ValidationErrorFeedback(error, message));
> with
> error(message);
>
> in FormComponent#error()
>
> The 'message' can bring the 'error' that produced it if it needs it.
>
> OK ?
> Wicket 6.0 only of course.
>
> On Wed, Mar 14, 2012 at 5:41 PM, Igor Vaynberg <igor.vaynb...@gmail.com> 
> wrote:
>> i dont quite follow all this, but if you just want to change
>>
>> IValidationErrror#getErrorMessage() to return a Serializable instead
>> of a String im fine with that.
>>
>> -igor
>>
>> On Wed, Mar 14, 2012 at 6:17 AM, Martin Grigorov <mgrigo...@apache.org> 
>> wrote:
>>> Hi,
>>>
>>> A colleague of mine asked me why ValidationError doesn't work with
>>> Serializable as Component's #info, #error, #debug, ... methods.
>>> I looked deeper and I saw a solution: write a custom IValidationError
>>> which keeps the Serializable and use it later.
>>>
>>> Problem 1) IValidationError requires from me to deal with 
>>> IErrorMessageSource
>>> In my case with our custom FeedbackPanel that knows how to render our
>>> custom Serializables this is not needed
>>> Workaround: just return empty string to keep FormComponent#error()
>>> quiet (otherwise it logs a warning if the returned message is null)
>>>
>>> Problem 2) With my custom IValidationError impl I have to override
>>> FormComponent#error() to be able to use it
>>>
>>> And here I start thinking that IErrorMessageSource is something that
>>> is related to org.apache.wicket.validation.ValidationError because it
>>> works with resource keys (message bundles).
>>> I think it would be better if IValidationError actually had a method
>>> that returns a Serializable. In this case the current code of
>>> FormComponent#error() will be in o.a.w.validation.ValidationError and
>>> it will return org.apache.wicket.markup.html.form.ValidationErrorFeedback.
>>> And my custom IValidationError will return my custom Serializable impl
>>>
>>> So the new body of FormComponent#error(IValidatable) will be:
>>>
>>> public void error(IValidationError error)
>>> {
>>>  error(error.getMessage());  // getMessage() returns the Serializable
>>> }
>>>
>>> I doubt there are many custom impls of IErrorMessageSource in the wild.
>>>
>>> --
>>> Martin Grigorov
>>> jWeekend
>>> Training, Consulting, Development
>>> http://jWeekend.com
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com

Reply via email to