RE: Providing IModel to Validators

2008-05-22 Thread Hoover, William
done: https://issues.apache.org/jira/browse/WICKET-1654 

-Original Message-
From: Igor Vaynberg [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 21, 2008 8:10 PM
To: users@wicket.apache.org
Subject: Re: Providing IModel to Validators

ah, i see. so the model for the validator overrides the message
completely?

i have already built in a support for this into the core api via
IValidationError. the problem is that our validator implementations are
based around resource keys, and changing that will probably entail api
breakages which we cannot have in a 1.3 release.

enter an rfe and we can refactor this stuff for 1.4/1.5

-igor


On Wed, May 21, 2008 at 5:00 PM, Hoover, William <[EMAIL PROTECTED]>
wrote:
> A "column" attribute, or any other attribute for that matter, would 
> not make a difference because if would all be encapsulated within the 
> model set on the validator (use case 6 below). Providing models to the

> validators would make it a lot easier to override validation messages 
> because all the developer would have to do is set the model on it (vs 
> looking up the resource key and add it to the components properties 
> file). I can see that this is receiving some strong resistance so I 
> wont push the issue any further :o)
>
> ==
>
> Use Case 6:
>
> StringResourceModel srm =  new
> StringResourceModel("CustomStringValidator.minimum", null, null, new 
> Object[]{ rowIndex, columnIndex });
>
> add(new textfield("fname").setlabel(new model("first 
> name")).add(stringvalidator.minimum(5, srm));
>
> results in- 'first name' with value 'abc' at row 10, column 3 is 
> shorter than the minimum of 5 characters.
>
> ==
>
> -Original Message-
> From: Igor Vaynberg [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, May 21, 2008 3:07 PM
> To: users@wicket.apache.org
> Subject: Re: Providing IModel to Validators
>
> and what happens when someone wants ${label} at row {0} column {1} is 
> required? do we start passing in arrays, lists, or maps for imodels to

> validators?
>
> why not just do
>
> textfield.setlabel(new model("first name at row "+row));
>
> -igor
>
> On Wed, May 21, 2008 at 4:52 AM, Hoover, William <[EMAIL PROTECTED]>
> wrote:
>> What I'm proposing would not require the same "first name" model on 
>> both validators. I might not have been clear enough in my
> explanation...
>>
>> StringValidator.minimum='${label}' with value '${input}' is shorter 
>> than the minimum of ${minimum} characters.
>>
>> CustomStringValidator.minimum='${label}' with value '${input}' at row

>> {0} is shorter than the minimum of ${minimum} characters.
>>
>> MyUsernameValidator.unique='${label}' with value '${input}' at row 
>> {0}
>
>> is not unique.
>>
>> ==
>>
>> Use Case 1:
>>
>> add(new textfield("fname").add(stringvalidator.minimum(5));
>>
>> results in- 'fNameId' with value 'abc' is shorter than the minimum of
>> 5 characters.
>>
>> ==
>>
>> Use Case 2:
>>
>> add(new textfield("fname").setlabel(new model("first 
>> name")).add(stringvalidator.minimum(5));
>>
>> results in- 'first name' with value 'abc' is shorter than the minimum

>> of
>> 5 characters.
>>
>> ==
>>
>> Use Case 3:
>>
>> StringResourceModel srm =  new
>> StringResourceModel("CustomStringValidator.minimum", null, null, new 
>> Object[]{ rowIndex });
>>
>> add(new textfield("fname").add(stringvalidator.minimum(5, srm));
>>
>> results in- 'fNameId' with value 'abc' at row 10 is shorter than the 
>> minimum of 5 characters.
>>
>> ==
>>
>> Use Case 4:
>>
>> StringResourceModel srm =  new
>> StringResourceModel("CustomStringValidator.minimum", null, null, new 
>> Object[]{ rowIndex });
>>
>> add(new textfield("fname").setlabel(new model("first 
>> name")).add(stringvalidator.minimum(5, srm));
>>
>> results in- 'first name' with value 'abc' at row 10 is shorter than 
>> the minimum of 5 characters.
>>
>> ==
>>
>> Use Case 5:
>>
>> StringResourceModel srm =  new
>> StringResourceModel("CustomStringValidator.minimu

Re: Providing IModel to Validators

2008-05-21 Thread Igor Vaynberg
ah, i see. so the model for the validator overrides the message completely?

i have already built in a support for this into the core api via
IValidationError. the problem is that our validator implementations
are based around resource keys, and changing that will probably entail
api breakages which we cannot have in a 1.3 release.

enter an rfe and we can refactor this stuff for 1.4/1.5

-igor


On Wed, May 21, 2008 at 5:00 PM, Hoover, William <[EMAIL PROTECTED]> wrote:
> A "column" attribute, or any other attribute for that matter, would not
> make a difference because if would all be encapsulated within the model
> set on the validator (use case 6 below). Providing models to the
> validators would make it a lot easier to override validation messages
> because all the developer would have to do is set the model on it (vs
> looking up the resource key and add it to the components properties
> file). I can see that this is receiving some strong resistance so I wont
> push the issue any further :o)
>
> ==
>
> Use Case 6:
>
> StringResourceModel srm =  new
> StringResourceModel("CustomStringValidator.minimum", null, null, new
> Object[]{ rowIndex, columnIndex });
>
> add(new textfield("fname").setlabel(new model("first
> name")).add(stringvalidator.minimum(5, srm));
>
> results in- 'first name' with value 'abc' at row 10, column 3 is shorter
> than the minimum of 5 characters.
>
> ==
>
> -Original Message-
> From: Igor Vaynberg [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, May 21, 2008 3:07 PM
> To: users@wicket.apache.org
> Subject: Re: Providing IModel to Validators
>
> and what happens when someone wants ${label} at row {0} column {1} is
> required? do we start passing in arrays, lists, or maps for imodels to
> validators?
>
> why not just do
>
> textfield.setlabel(new model("first name at row "+row));
>
> -igor
>
> On Wed, May 21, 2008 at 4:52 AM, Hoover, William <[EMAIL PROTECTED]>
> wrote:
>> What I'm proposing would not require the same "first name" model on
>> both validators. I might not have been clear enough in my
> explanation...
>>
>> StringValidator.minimum='${label}' with value '${input}' is shorter
>> than the minimum of ${minimum} characters.
>>
>> CustomStringValidator.minimum='${label}' with value '${input}' at row
>> {0} is shorter than the minimum of ${minimum} characters.
>>
>> MyUsernameValidator.unique='${label}' with value '${input}' at row {0}
>
>> is not unique.
>>
>> ==
>>
>> Use Case 1:
>>
>> add(new textfield("fname").add(stringvalidator.minimum(5));
>>
>> results in- 'fNameId' with value 'abc' is shorter than the minimum of
>> 5 characters.
>>
>> ==
>>
>> Use Case 2:
>>
>> add(new textfield("fname").setlabel(new model("first
>> name")).add(stringvalidator.minimum(5));
>>
>> results in- 'first name' with value 'abc' is shorter than the minimum
>> of
>> 5 characters.
>>
>> ==
>>
>> Use Case 3:
>>
>> StringResourceModel srm =  new
>> StringResourceModel("CustomStringValidator.minimum", null, null, new
>> Object[]{ rowIndex });
>>
>> add(new textfield("fname").add(stringvalidator.minimum(5, srm));
>>
>> results in- 'fNameId' with value 'abc' at row 10 is shorter than the
>> minimum of 5 characters.
>>
>> ==
>>
>> Use Case 4:
>>
>> StringResourceModel srm =  new
>> StringResourceModel("CustomStringValidator.minimum", null, null, new
>> Object[]{ rowIndex });
>>
>> add(new textfield("fname").setlabel(new model("first
>> name")).add(stringvalidator.minimum(5, srm));
>>
>> results in- 'first name' with value 'abc' at row 10 is shorter than
>> the minimum of 5 characters.
>>
>> ==
>>
>> Use Case 5:
>>
>> StringResourceModel srm =  new
>> StringResourceModel("CustomStringValidator.minimum", null, null, new
>> Object[]{ rowIndex });
>>
>> add(new textfield("fname").setlabel(new model("first
>> name")).add(stringvalidator.minimum(5, srm)).add(new
>> MyUsernameValidator());
>>
>> results in

RE: Providing IModel to Validators

2008-05-21 Thread Hoover, William
A "column" attribute, or any other attribute for that matter, would not
make a difference because if would all be encapsulated within the model
set on the validator (use case 6 below). Providing models to the
validators would make it a lot easier to override validation messages
because all the developer would have to do is set the model on it (vs
looking up the resource key and add it to the components properties
file). I can see that this is receiving some strong resistance so I wont
push the issue any further :o)

==

Use Case 6:

StringResourceModel srm =  new
StringResourceModel("CustomStringValidator.minimum", null, null, new
Object[]{ rowIndex, columnIndex });

add(new textfield("fname").setlabel(new model("first
name")).add(stringvalidator.minimum(5, srm));

results in- 'first name' with value 'abc' at row 10, column 3 is shorter
than the minimum of 5 characters.

==

-Original Message-
From: Igor Vaynberg [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 21, 2008 3:07 PM
To: users@wicket.apache.org
Subject: Re: Providing IModel to Validators

and what happens when someone wants ${label} at row {0} column {1} is
required? do we start passing in arrays, lists, or maps for imodels to
validators?

why not just do

textfield.setlabel(new model("first name at row "+row));

-igor

On Wed, May 21, 2008 at 4:52 AM, Hoover, William <[EMAIL PROTECTED]>
wrote:
> What I'm proposing would not require the same "first name" model on 
> both validators. I might not have been clear enough in my
explanation...
>
> StringValidator.minimum='${label}' with value '${input}' is shorter 
> than the minimum of ${minimum} characters.
>
> CustomStringValidator.minimum='${label}' with value '${input}' at row 
> {0} is shorter than the minimum of ${minimum} characters.
>
> MyUsernameValidator.unique='${label}' with value '${input}' at row {0}

> is not unique.
>
> ==
>
> Use Case 1:
>
> add(new textfield("fname").add(stringvalidator.minimum(5));
>
> results in- 'fNameId' with value 'abc' is shorter than the minimum of 
> 5 characters.
>
> ==
>
> Use Case 2:
>
> add(new textfield("fname").setlabel(new model("first 
> name")).add(stringvalidator.minimum(5));
>
> results in- 'first name' with value 'abc' is shorter than the minimum 
> of
> 5 characters.
>
> ==
>
> Use Case 3:
>
> StringResourceModel srm =  new
> StringResourceModel("CustomStringValidator.minimum", null, null, new 
> Object[]{ rowIndex });
>
> add(new textfield("fname").add(stringvalidator.minimum(5, srm));
>
> results in- 'fNameId' with value 'abc' at row 10 is shorter than the 
> minimum of 5 characters.
>
> ==
>
> Use Case 4:
>
> StringResourceModel srm =  new
> StringResourceModel("CustomStringValidator.minimum", null, null, new 
> Object[]{ rowIndex });
>
> add(new textfield("fname").setlabel(new model("first 
> name")).add(stringvalidator.minimum(5, srm));
>
> results in- 'first name' with value 'abc' at row 10 is shorter than 
> the minimum of 5 characters.
>
> ==
>
> Use Case 5:
>
> StringResourceModel srm =  new
> StringResourceModel("CustomStringValidator.minimum", null, null, new 
> Object[]{ rowIndex });
>
> add(new textfield("fname").setlabel(new model("first 
> name")).add(stringvalidator.minimum(5, srm)).add(new 
> MyUsernameValidator());
>
> results in- 'first name' with value 'abc' at row 10 is shorter than 
> the minimum of 5 characters.
>
> results in- 'first name' with value 'abc' at row 10 is not unique.
>
> ==
>
> -Original Message-
> From: Igor Vaynberg [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, May 20, 2008 8:41 PM
> To: users@wicket.apache.org
> Subject: Re: Providing IModel to Validators
>
> On Tue, May 20, 2008 at 3:39 PM, Hoover, William <[EMAIL PROTECTED]>
> wrote:
>> sure, if you know to override NumberValidator.minimum with:
>>
>> label.myminimum=My Object at row: {0} with value 
>> NumberValidator.minimum=${label} '${input}' must be smaller than 
>> ${minimum}
>>
>> It seems odd because:
>> 1) NumberValidator.minimum (or any other entry in
>> Application.properties) does not use ${label} by defau

Re: Providing IModel to Validators

2008-05-21 Thread Igor Vaynberg
and what happens when someone wants ${label} at row {0} column {1} is
required? do we start passing in arrays, lists, or maps for imodels to
validators?

why not just do

textfield.setlabel(new model("first name at row "+row));

-igor

On Wed, May 21, 2008 at 4:52 AM, Hoover, William <[EMAIL PROTECTED]> wrote:
> What I'm proposing would not require the same "first name" model on both
> validators. I might not have been clear enough in my explanation...
>
> StringValidator.minimum='${label}' with value '${input}' is shorter than
> the minimum of ${minimum} characters.
>
> CustomStringValidator.minimum='${label}' with value '${input}' at row
> {0} is shorter than the minimum of ${minimum} characters.
>
> MyUsernameValidator.unique='${label}' with value '${input}' at row {0}
> is not unique.
>
> ==
>
> Use Case 1:
>
> add(new textfield("fname").add(stringvalidator.minimum(5));
>
> results in- 'fNameId' with value 'abc' is shorter than the minimum of 5
> characters.
>
> ==
>
> Use Case 2:
>
> add(new textfield("fname").setlabel(new model("first
> name")).add(stringvalidator.minimum(5));
>
> results in- 'first name' with value 'abc' is shorter than the minimum of
> 5 characters.
>
> ==
>
> Use Case 3:
>
> StringResourceModel srm =  new
> StringResourceModel("CustomStringValidator.minimum", null, null, new
> Object[]{ rowIndex });
>
> add(new textfield("fname").add(stringvalidator.minimum(5, srm));
>
> results in- 'fNameId' with value 'abc' at row 10 is shorter than the
> minimum of 5 characters.
>
> ==
>
> Use Case 4:
>
> StringResourceModel srm =  new
> StringResourceModel("CustomStringValidator.minimum", null, null, new
> Object[]{ rowIndex });
>
> add(new textfield("fname").setlabel(new model("first
> name")).add(stringvalidator.minimum(5, srm));
>
> results in- 'first name' with value 'abc' at row 10 is shorter than the
> minimum of 5 characters.
>
> ==
>
> Use Case 5:
>
> StringResourceModel srm =  new
> StringResourceModel("CustomStringValidator.minimum", null, null, new
> Object[]{ rowIndex });
>
> add(new textfield("fname").setlabel(new model("first
> name")).add(stringvalidator.minimum(5, srm)).add(new
> MyUsernameValidator());
>
> results in- 'first name' with value 'abc' at row 10 is shorter than the
> minimum of 5 characters.
>
> results in- 'first name' with value 'abc' at row 10 is not unique.
>
> ==
>
> -Original Message-
> From: Igor Vaynberg [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, May 20, 2008 8:41 PM
> To: users@wicket.apache.org
> Subject: Re: Providing IModel to Validators
>
> On Tue, May 20, 2008 at 3:39 PM, Hoover, William <[EMAIL PROTECTED]>
> wrote:
>> sure, if you know to override NumberValidator.minimum with:
>>
>> label.myminimum=My Object at row: {0} with value
>> NumberValidator.minimum=${label} '${input}' must be smaller than
>> ${minimum}
>>
>> It seems odd because:
>> 1) NumberValidator.minimum (or any other entry in
>> Application.properties) does not use ${label} by default
>
> i have argued for this, but ive been met with resistance. reasoning was
> that not everyone uses setLabel() for every component.
>
>> 2) label.myminimum has to be worded in a way that would accommodate
>> all types of IValidator that may be used
>
> right, the ones in application.properties are generic. of course you can
> override the message just for that page/component by simply defining
> your own NumberValidator.minimum key
>
> and if i remember correctly you can do without the label entirely,
> defining your own componentid.NumberValidator.minimum - but dont quote
> me on this
>
>> 3) label.myminimum shouldn't really exist on it's own
>
> of course not, you are calling setlabel(new
> resourcemodel("label.minimum")) on that one specific component, its not
> meant to be reusable
>
>> 4) It's not very intuitive to use the label because... well... it's a
>> label, not a validation message :o)
>
> well, this is a label meant to be used inside a validation message. so
> there :) i see nothing counter intuitive about
>
> add(new textfield("fname").setlabel(ne

RE: Providing IModel to Validators

2008-05-21 Thread Hoover, William
What I'm proposing would not require the same "first name" model on both
validators. I might not have been clear enough in my explanation...

StringValidator.minimum='${label}' with value '${input}' is shorter than
the minimum of ${minimum} characters.

CustomStringValidator.minimum='${label}' with value '${input}' at row
{0} is shorter than the minimum of ${minimum} characters.

MyUsernameValidator.unique='${label}' with value '${input}' at row {0}
is not unique.

==

Use Case 1:

add(new textfield("fname").add(stringvalidator.minimum(5));

results in- 'fNameId' with value 'abc' is shorter than the minimum of 5
characters.

==

Use Case 2:

add(new textfield("fname").setlabel(new model("first
name")).add(stringvalidator.minimum(5));

results in- 'first name' with value 'abc' is shorter than the minimum of
5 characters.

==

Use Case 3:

StringResourceModel srm =  new
StringResourceModel("CustomStringValidator.minimum", null, null, new
Object[]{ rowIndex });

add(new textfield("fname").add(stringvalidator.minimum(5, srm));

results in- 'fNameId' with value 'abc' at row 10 is shorter than the
minimum of 5 characters.

==

Use Case 4:

StringResourceModel srm =  new
StringResourceModel("CustomStringValidator.minimum", null, null, new
Object[]{ rowIndex });

add(new textfield("fname").setlabel(new model("first
name")).add(stringvalidator.minimum(5, srm));

results in- 'first name' with value 'abc' at row 10 is shorter than the
minimum of 5 characters.

==

Use Case 5:

StringResourceModel srm =  new
StringResourceModel("CustomStringValidator.minimum", null, null, new
Object[]{ rowIndex });

add(new textfield("fname").setlabel(new model("first
name")).add(stringvalidator.minimum(5, srm)).add(new
MyUsernameValidator());

results in- 'first name' with value 'abc' at row 10 is shorter than the
minimum of 5 characters.

results in- 'first name' with value 'abc' at row 10 is not unique.

==

-Original Message-
From: Igor Vaynberg [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 20, 2008 8:41 PM
To: users@wicket.apache.org
Subject: Re: Providing IModel to Validators

On Tue, May 20, 2008 at 3:39 PM, Hoover, William <[EMAIL PROTECTED]>
wrote:
> sure, if you know to override NumberValidator.minimum with:
>
> label.myminimum=My Object at row: {0} with value 
> NumberValidator.minimum=${label} '${input}' must be smaller than 
> ${minimum}
>
> It seems odd because:
> 1) NumberValidator.minimum (or any other entry in
> Application.properties) does not use ${label} by default

i have argued for this, but ive been met with resistance. reasoning was
that not everyone uses setLabel() for every component.

> 2) label.myminimum has to be worded in a way that would accommodate 
> all types of IValidator that may be used

right, the ones in application.properties are generic. of course you can
override the message just for that page/component by simply defining
your own NumberValidator.minimum key

and if i remember correctly you can do without the label entirely,
defining your own componentid.NumberValidator.minimum - but dont quote
me on this

> 3) label.myminimum shouldn't really exist on it's own

of course not, you are calling setlabel(new
resourcemodel("label.minimum")) on that one specific component, its not
meant to be reusable

> 4) It's not very intuitive to use the label because... well... it's a 
> label, not a validation message :o)

well, this is a label meant to be used inside a validation message. so
there :) i see nothing counter intuitive about

add(new textfield("fname").setlabel(new model("first name")); and
defining a default StringValidator.minimum=${label} must be at least
${minimum} characters for messages like "first name must be at least 5
characters"

>
> If there were a means to add a IModel when adding any of the 
> validators (as described) it would follow the standard Wicket protocol

> of using models. Any thoughts?

setLabel() takes in a model... the fact is that the label is scoped to
the formcomponent, not validation message most of the time. eg

add(new textfield("fname").add(stringvalidator.minimum(5)).add(new
uniqueusernamevalidator());

so with your proposal i would have to give the same "first name" model
to both validators, why? i can declare it once on the textfield, the
label of the formcomponent wont change validator to validator.

-igor

>
> -Origin

Re: Providing IModel to Validators

2008-05-20 Thread Igor Vaynberg
On Tue, May 20, 2008 at 3:39 PM, Hoover, William <[EMAIL PROTECTED]> wrote:
> sure, if you know to override NumberValidator.minimum with:
>
> label.myminimum=My Object at row: {0} with value
> NumberValidator.minimum=${label} '${input}' must be smaller than
> ${minimum}
>
> It seems odd because:
> 1) NumberValidator.minimum (or any other entry in
> Application.properties) does not use ${label} by default

i have argued for this, but ive been met with resistance. reasoning
was that not everyone uses setLabel() for every component.

> 2) label.myminimum has to be worded in a way that would accommodate all
> types of IValidator that may be used

right, the ones in application.properties are generic. of course you
can override the message just for that page/component by simply
defining your own NumberValidator.minimum key

and if i remember correctly you can do without the label entirely,
defining your own componentid.NumberValidator.minimum - but dont quote
me on this

> 3) label.myminimum shouldn't really exist on it's own

of course not, you are calling setlabel(new
resourcemodel("label.minimum")) on that one specific component, its
not meant to be reusable

> 4) It's not very intuitive to use the label because... well... it's a
> label, not a validation message :o)

well, this is a label meant to be used inside a validation message. so
there :) i see nothing counter intuitive about

add(new textfield("fname").setlabel(new model("first name")); and
defining a default StringValidator.minimum=${label} must be at least
${minimum} characters for messages like "first name must be at least 5
characters"

>
> If there were a means to add a IModel when adding any of the validators
> (as described) it would follow the standard Wicket protocol of using
> models. Any thoughts?

setLabel() takes in a model... the fact is that the label is scoped to
the formcomponent, not validation message most of the time. eg

add(new textfield("fname").add(stringvalidator.minimum(5)).add(new
uniqueusernamevalidator());

so with your proposal i would have to give the same "first name" model
to both validators, why? i can declare it once on the textfield, the
label of the formcomponent wont change validator to validator.

-igor

>
> -----Original Message-
> From: Igor Vaynberg [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, May 20, 2008 1:52 PM
> To: users@wicket.apache.org
> Subject: Re: Providing IModel to Validators
>
> that is why formcomponents have a setLabel(IModel) whose text is
> then available via ${label} place holder.
>
> -igor
>
>
> On Tue, May 20, 2008 at 7:14 AM, Hoover, William <[EMAIL PROTECTED]>
> wrote:
>>
>> What does everyone think about updating the Wicket core validators to
>> contain an optional IModel?
>>
>> Simple Use Case:
>> # properties file
>> label.myminimum=My Object at row: {0} with value '${input}' must be
>> smaller than ${minimum}
>>
>> ...
>> final RefreshingView myView = new RefreshingView("tr-my-object-view")
> {
>>protected final void populateItem(final Item item) {
>>...
>>final TextField myTextField = new
>> TextField("input-text-field");
>>final IModel myMinValidatorModel = new
>> StringResourceModel("label.myminimum", item, null, new Object[] {
>> item.getIndex() });
>>
>> myTextField.add(NumberValidator.MinimumValidator.minimum(10L,
>> myMinValidatorModel);
>>...
>>}
>> };
>> ...
>>
>> So, instead of seeing a very general message that could apply to any
>> number of fields that may contain the same value:
>> ...
>> '0' is smaller than the minimum of 10.
>> '0' is smaller than the minimum of 10.
>> '0' is smaller than the minimum of 10.
>> ...
>>
>> You would see this:
>> ...
>> My Object at row: 1 with value '0' must be smaller than 10 My Object
>> at row: 12 with value '0' must be smaller than 10 My Object at row: 20
>
>> with value '0' must be smaller than 10 ...
>>
>> The problem with just overriding the "NumberValidator.minimum"
>> resource in this example is that makes it difficult to add custom
>> property values (i.e. the index in example).
>>
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Providing IModel to Validators

2008-05-20 Thread Hoover, William
sure, if you know to override NumberValidator.minimum with:

label.myminimum=My Object at row: {0} with value
NumberValidator.minimum=${label} '${input}' must be smaller than
${minimum}

It seems odd because:
1) NumberValidator.minimum (or any other entry in
Application.properties) does not use ${label} by default
2) label.myminimum has to be worded in a way that would accommodate all
types of IValidator that may be used
3) label.myminimum shouldn't really exist on it's own
4) It's not very intuitive to use the label because... well... it's a
label, not a validation message :o)

If there were a means to add a IModel when adding any of the validators
(as described) it would follow the standard Wicket protocol of using
models. Any thoughts?

-Original Message-
From: Igor Vaynberg [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 20, 2008 1:52 PM
To: users@wicket.apache.org
Subject: Re: Providing IModel to Validators

that is why formcomponents have a setLabel(IModel) whose text is
then available via ${label} place holder.

-igor


On Tue, May 20, 2008 at 7:14 AM, Hoover, William <[EMAIL PROTECTED]>
wrote:
>
> What does everyone think about updating the Wicket core validators to 
> contain an optional IModel?
>
> Simple Use Case:
> # properties file
> label.myminimum=My Object at row: {0} with value '${input}' must be 
> smaller than ${minimum}
>
> ...
> final RefreshingView myView = new RefreshingView("tr-my-object-view")
{
>protected final void populateItem(final Item item) {
>...
>final TextField myTextField = new 
> TextField("input-text-field");
>final IModel myMinValidatorModel = new 
> StringResourceModel("label.myminimum", item, null, new Object[] {
> item.getIndex() });
>
> myTextField.add(NumberValidator.MinimumValidator.minimum(10L,
> myMinValidatorModel);
>...
>}
> };
> ...
>
> So, instead of seeing a very general message that could apply to any 
> number of fields that may contain the same value:
> ...
> '0' is smaller than the minimum of 10.
> '0' is smaller than the minimum of 10.
> '0' is smaller than the minimum of 10.
> ...
>
> You would see this:
> ...
> My Object at row: 1 with value '0' must be smaller than 10 My Object 
> at row: 12 with value '0' must be smaller than 10 My Object at row: 20

> with value '0' must be smaller than 10 ...
>
> The problem with just overriding the "NumberValidator.minimum" 
> resource in this example is that makes it difficult to add custom 
> property values (i.e. the index in example).
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Providing IModel to Validators

2008-05-20 Thread Igor Vaynberg
that is why formcomponents have a setLabel(IModel) whose text
is then available via ${label} place holder.

-igor


On Tue, May 20, 2008 at 7:14 AM, Hoover, William <[EMAIL PROTECTED]> wrote:
>
> What does everyone think about updating the Wicket core validators to
> contain an optional IModel?
>
> Simple Use Case:
> # properties file
> label.myminimum=My Object at row: {0} with value '${input}' must be
> smaller than ${minimum}
>
> ...
> final RefreshingView myView = new RefreshingView("tr-my-object-view") {
>protected final void populateItem(final Item item) {
>...
>final TextField myTextField = new
> TextField("input-text-field");
>final IModel myMinValidatorModel = new
> StringResourceModel("label.myminimum", item, null, new Object[] {
> item.getIndex() });
>
> myTextField.add(NumberValidator.MinimumValidator.minimum(10L,
> myMinValidatorModel);
>...
>}
> };
> ...
>
> So, instead of seeing a very general message that could apply to any
> number of fields that may contain the same value:
> ...
> '0' is smaller than the minimum of 10.
> '0' is smaller than the minimum of 10.
> '0' is smaller than the minimum of 10.
> ...
>
> You would see this:
> ...
> My Object at row: 1 with value '0' must be smaller than 10
> My Object at row: 12 with value '0' must be smaller than 10
> My Object at row: 20 with value '0' must be smaller than 10
> ...
>
> The problem with just overriding the "NumberValidator.minimum" resource
> in this example is that makes it difficult to add custom property values
> (i.e. the index in example).
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Providing IModel to Validators

2008-05-20 Thread Johan Compagner
we kind of have that support in AbstractValidator

protected Map variablesMap(IValidatable validatable)
{
final Map resourceModel = new HashMap(1);
return resourceModel;
}

the problem is that somehow it should do a call back to the IValidatable
(which is FormComponent most of the time)
so that that will also fill in stuff..

protected Map variablesMap(IValidatable validatable)
{
final Map resourceModel = new HashMap(3);
validatable.fillVariablesMap(resourceModel);
return resourceModel;
}

then it will be very easy for people to do that.

Igor what do you think? Those parts are mostly your code and i guess having
a IModel inside the IValidator is not what you want :)

johan




On Tue, May 20, 2008 at 4:14 PM, Hoover, William <[EMAIL PROTECTED]>
wrote:

>
> What does everyone think about updating the Wicket core validators to
> contain an optional IModel?
>
> Simple Use Case:
> # properties file
> label.myminimum=My Object at row: {0} with value '${input}' must be
> smaller than ${minimum}
>
> ...
> final RefreshingView myView = new RefreshingView("tr-my-object-view") {
>protected final void populateItem(final Item item) {
>...
>final TextField myTextField = new
> TextField("input-text-field");
>final IModel myMinValidatorModel = new
> StringResourceModel("label.myminimum", item, null, new Object[] {
> item.getIndex() });
>
> myTextField.add(NumberValidator.MinimumValidator.minimum(10L,
> myMinValidatorModel);
>...
>}
> };
> ...
>
> So, instead of seeing a very general message that could apply to any
> number of fields that may contain the same value:
> ...
> '0' is smaller than the minimum of 10.
> '0' is smaller than the minimum of 10.
> '0' is smaller than the minimum of 10.
> ...
>
> You would see this:
> ...
> My Object at row: 1 with value '0' must be smaller than 10
> My Object at row: 12 with value '0' must be smaller than 10
> My Object at row: 20 with value '0' must be smaller than 10
> ...
>
> The problem with just overriding the "NumberValidator.minimum" resource
> in this example is that makes it difficult to add custom property values
> (i.e. the index in example).
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>