Re: Validate FormComponent raw input before conversion

2014-07-18 Thread Jack Berg
Thank you for the replies.
You are right. It can be done like this.

Though right now it seems that implementing my own rawvalidator would
require a comparable amount of effort.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Validate-FormComponent-raw-input-before-conversion-tp4666560p483.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: Validate FormComponent raw input before conversion

2014-07-12 Thread Martin Grigorov
Hi,

You can add a new key to YourApp.properties:
xyz.integerKey = 
Wicket will use it instead of the generic message


On Sat, Jul 12, 2014 at 12:17 PM, Francois Meillet <
francois.meil...@gmail.com> wrote:

> TextField t = new TextField("xyz") {
>
> @Override
> public final  IConverter getConverter(Class
> clazz) {
> return (IConverter) new IntegerConverter() {
> @Override
> protected ConversionException
> newConversionException(String message, Object value, Locale locale) {
> return new
> ConversionException(message).setSourceValue(value)
> .setTargetType(getTargetType())
> .setConverter(this)
> .setLocale(locale)
> .setResourceKey("integerKey");
>  <--
> }
> };
> }
> };
>
>
> The integerKey : the key in the Application.properties for the message
>
>
> François Meillet
> Formation Wicket - Développement Wicket
>
>
>
>
>
> Le 11 juil. 2014 à 21:11, Jack Berg  a écrit :
>
> > Hello!
> >
> > I have textfield backed by Integer Model object in the web app and a
> number
> > field in the database.
> > The maximum number the database can hold is less than Integer.MAX_VALUE
> so I
> > have added a validator which checks that and reports the valid range.
> >
> > The problem is that when the user enters a value larger than
> > Integer.MAX_VALUE, the conversion fails and user recieves a generic
> message.
> >
> > Using BigInteger and BigDecimal everywhere in models seems excessive.
> > And it seems I can't validate the raw input string before conversion?
> Would
> > you consider adding this feature or is there a better way?
> >
> > --
> > View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Validate-FormComponent-raw-input-before-conversion-tp4666560.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: Validate FormComponent raw input before conversion

2014-07-12 Thread Francois Meillet
TextField t = new TextField("xyz") {

@Override
public final  IConverter getConverter(Class clazz) {
return (IConverter) new IntegerConverter() {
@Override
protected ConversionException 
newConversionException(String message, Object value, Locale locale) {
return new 
ConversionException(message).setSourceValue(value)
.setTargetType(getTargetType())
.setConverter(this)
.setLocale(locale)
.setResourceKey("integerKey");  
<--
}
};
}
};


The integerKey : the key in the Application.properties for the message


François Meillet
Formation Wicket - Développement Wicket





Le 11 juil. 2014 à 21:11, Jack Berg  a écrit :

> Hello!
> 
> I have textfield backed by Integer Model object in the web app and a number
> field in the database.
> The maximum number the database can hold is less than Integer.MAX_VALUE so I
> have added a validator which checks that and reports the valid range. 
> 
> The problem is that when the user enters a value larger than
> Integer.MAX_VALUE, the conversion fails and user recieves a generic message.
> 
> Using BigInteger and BigDecimal everywhere in models seems excessive.
> And it seems I can't validate the raw input string before conversion? Would
> you consider adding this feature or is there a better way?
> 
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/Validate-FormComponent-raw-input-before-conversion-tp4666560.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
> 



Validate FormComponent raw input before conversion

2014-07-11 Thread Jack Berg
Hello!

I have textfield backed by Integer Model object in the web app and a number
field in the database.
The maximum number the database can hold is less than Integer.MAX_VALUE so I
have added a validator which checks that and reports the valid range. 

The problem is that when the user enters a value larger than
Integer.MAX_VALUE, the conversion fails and user recieves a generic message.

Using BigInteger and BigDecimal everywhere in models seems excessive.
And it seems I can't validate the raw input string before conversion? Would
you consider adding this feature or is there a better way?

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Validate-FormComponent-raw-input-before-conversion-tp4666560.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