// Generate message
requiredMessage = MessageFormat.format("Field {0} is not Long.: {1}", field, value); //NOI18N
+ // Value is not right type
+ facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessage, requiredMessage); //NOI18N
+ break;
+ } else if ((!allowNull) && (!(value instanceof Integer))) {
+ // Generate message
+ requiredMessage = MessageFormat.format("Field {0} is not Integer.: {1}", field, value); //NOI18N
+
// Value is not right type
facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessage, requiredMessage); //NOI18N
break;
}
- // Cast to string
- Long num = (Long) value;
+ // Declare variables
+ Integer i = null;
+ Long l = null;
+
+ // Which type?
+ if (value instanceof Integer) {
+ // Cast to Long
+ i = (Integer) value;
+ } else {
+ // Cast to Long
+ l = (Long) value;
+ }
// Is the number below zero?
- if (num < 0) {
+ if ((!allowNull) && ((i instanceof Integer) && (i < 0))) {
+ // Generate message
+ requiredMessage = MessageFormat.format("Value {0} for field {1} is below zero.", i, field); //NOI18N
+
+ // Abort processing here
+ facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessage, requiredMessage);
+ break;
+ } else if ((!allowNull) && ((l instanceof Long) && (l < 0))) {
// Generate message
- requiredMessage = MessageFormat.format("Value {0} for field {1} is below zero.", num, field); //NOI18N
+ requiredMessage = MessageFormat.format("Value {0} for field {1} is below zero.", l, field); //NOI18N
// Abort processing here
facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessage, requiredMessage);