| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
package net.sf.beanform.validator; |
| 16 |
|
|
| 17 |
|
import java.text.MessageFormat; |
| 18 |
|
import java.util.Locale; |
| 19 |
|
import java.util.ResourceBundle; |
| 20 |
|
|
| 21 |
|
import org.apache.tapestry.form.IFormComponent; |
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
1 |
class ValidatorMessages { |
| 29 |
|
|
| 30 |
1 |
private static final String RESOURCE_BUNDLE = ValidatorMessages.class.getName(); |
| 31 |
|
|
| 32 |
|
static String mustBeNumber( IFormComponent field, Locale locale ) { |
| 33 |
4 |
return getMessage( "must-be-number", field, locale ); |
| 34 |
|
} |
| 35 |
|
|
| 36 |
|
static String mustBeWholeNumber( IFormComponent field, Locale locale ) { |
| 37 |
4 |
return getMessage( "must-be-whole-number", field, locale ); |
| 38 |
|
} |
| 39 |
|
|
| 40 |
|
private static String getMessage( String key, IFormComponent field, Locale locale ) { |
| 41 |
8 |
String message = ResourceBundle.getBundle( RESOURCE_BUNDLE, locale ).getString( key ); |
| 42 |
8 |
return MessageFormat.format( message, field.getDisplayName() ); |
| 43 |
|
} |
| 44 |
|
|
| 45 |
|
} |