Re: Validators in Wicket 6

2012-11-30 Thread Sven Meier

So the intentional use that you register other converters with a field other
than those intended for use with the model?


An example:
You've added a behavior to a component, which renders a value into the 
title attribute of the tag. The value might be a number, while the 
component's model object is a date.
The component provides the converter for each of these values, i.e. a 
NumberConverter and a DateConverter.


I just can't conceive of why you would even want a converter for a 
field's label.


You would't ;).
All vars of error messages are converted, it just happens that the label 
is one of them.
We might want to shortcut this by checking the type of the variable if 
it's already a String (before trying to convert it).


Hope this helps
Sven


On 11/30/2012 08:51 PM, Hobbes00uk wrote:

So the intentional use that you register other converters with a field other
than those intended for use with the model?

I just can't conceive of why you would even want a converter for a field's
label. It just seems a bizarre thing to do. I can sort of see that it's a
place to stick handy converters perhaps, but it does seem like a weird
hack.

That was my point really, I was really trying to understand under what
conditions this place to stuff converters other than the one for the model
would be useful. I could see what the code did... I just didn't understand
*why* that is considered useful (and it obviously wasn't legacy having been
deliberately implemented).





--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Validators-in-Wicket-6-tp4654349p4654396.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Validators in Wicket 6

2012-11-30 Thread Hobbes00uk


 You would't ;).
 All vars of error messages are converted, it just happens that the label
 is one of them.
 We might want to shortcut this by checking the type of the variable if
 it's already a String (before trying to convert it).

 Hope this helps
It does and thank you for taking the time to explain it, it is appreciated.

Matt




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Validators-in-Wicket-6-tp4654349p4654400.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Validators in Wicket 6

2012-11-29 Thread Hobbes00uk
I'm hoping someone can help me with my understanding. I've been updating my
website to Wicket 6. In doing that the DateConverter I was applying to a
field has started throwing a class cast exception.

After some work, I made the problem go away, by checking the class parameter
in the over-ridden getConverter(Class type) method and only returning the
DateConverter for a date object - as it's shown in the DateTextField class.
All fine.

My confusion is that the class cast exception happens at the point where
Wicket is forming the error message. At that point it passes the name of the
field's label (birth date in this case) to the DateConverter's toString
method (which naturally expects a Date object) and hence the class cast
exception.

I just don't understand why it would do that? Why is the field label being
sent to the field's converter?

If I've misread what is happening then I apologize - I'm not an experienced
java coder but I have checked and rechecked this because I just couldn't
believe what I was seeing. And while I've made the problem go away, I'm
concerned I've achieved that with a profound lack of understanding as to why
it is happening. 




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Validators-in-Wicket-6-tp4654349.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Validators in Wicket 6

2012-11-29 Thread Sven Meier
checking the class parameter in the over-ridden getConverter(Class 
type) method

and only returning the DateConverter for a date object

Yes, you have to check the type parameter, as other types than the 
component's model type might need a converter.
With WICKET-4608 all variables in error messages are now properly 
converted by the formComponent.

This is why getConverter() is called more often.

Sven

On 11/29/2012 06:46 PM, Hobbes00uk wrote:

I'm hoping someone can help me with my understanding. I've been updating my
website to Wicket 6. In doing that the DateConverter I was applying to a
field has started throwing a class cast exception.

After some work, I made the problem go away, by checking the class parameter
in the over-ridden getConverter(Class type) method and only returning the
DateConverter for a date object - as it's shown in the DateTextField class.
All fine.

My confusion is that the class cast exception happens at the point where
Wicket is forming the error message. At that point it passes the name of the
field's label (birth date in this case) to the DateConverter's toString
method (which naturally expects a Date object) and hence the class cast
exception.

I just don't understand why it would do that? Why is the field label being
sent to the field's converter?

If I've misread what is happening then I apologize - I'm not an experienced
java coder but I have checked and rechecked this because I just couldn't
believe what I was seeing. And while I've made the problem go away, I'm
concerned I've achieved that with a profound lack of understanding as to why
it is happening.




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Validators-in-Wicket-6-tp4654349.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org