Maybe a bit OT, but how exactly do you implement this Jan?
The project I'm working on has:
public final class ValidationListener implements
IComponentOnBeforeRenderListener {
public void onBeforeRender(Component component) {
if (component instanceof FormComponent && !component.hasBeenRendered()) {
processComponent((FormComponent) component);
}
}
...
and then somewhere in processComponent:
...
Column column = field.getAnnotation(Column.class);
Class<?> type = field.getType();
..
if (column.nullable() == false && type != Boolean.class && type !=
Boolean.TYPE) {
component.setRequired(true);
}
Do you something similar, or do you follow an intirely different
aproach (probably, coming from 1.2)?
Eelco
On 6/19/07, Jan Vermeulen <[EMAIL PROTECTED]> wrote:
Problem with all these solutions, is that we have to differentiate between
'RequiredValidators' and other validators, which means somehow we have to
know which ones to call when. Because now, there is just a list of
validators, added to the component, and they get called by Wicket. What I'm
trying to say is that checking if a field is empty or not can be just a
validator task. Now, we can no longer simply plug that in as just another
validator.
I understand that it is handy not to have to check if a value is null, but
we're paying a price for this that might be higher than the gain ?
Jan.
igor.vaynberg wrote:
>
> or instead,
>
> maybe make that hibernatevalidator also be a behavior, and simply toggle
> component's setrequired in onattach
>
> -igor
>
>
> On 6/19/07, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
>>
>> i dont know about that. isvalid's contract is that it only returns false
>> if there are error messages reported against the component.
>>
>> i think this would be simple enough
>>
>> class hibernatetextfield extends textfield {
>> valid() {
>> if (hibernaterequired()) {
>> if (Strings.isEmpty(getInput()[0])) {
>> error(new ValidationError().addMessageKey("Required"));
>> return;
>> }
>> }
>> super.validate();
>> }
>>
>> -igor
>
--
View this message in context:
http://www.nabble.com/Problem-with-latest-changes-in-FormComponent%3Avalidate%28%29-tf3945885.html#a11200959
Sent from the Wicket - Dev mailing list archive at Nabble.com.