on 08-27-2007 5:05 PM
Hello,
I am using an Input field of Big Decimal type. If the user enters characters or anything other, I need to show error image.
Could you please tell, how to validate the bigdecimal?. Thanks.
How you are assigning BigDecimal to InputField? I guess your context attribute is of type string but you want to validate to accept only BigDecimal.
There is no direct InputAction so you should validate on any of the button action:
String bigValue = wdContext.currentContextElement().getBigDecValue();
boolean validValue = true;
BigDecimal bigObj = null;
try
{
bigObj = new BigDecimal(bigValue);
}
catch(NumberFormatException nfe)
{
validValue = false;
wdComponentAPI.getMessageManager().reportException("Invalid value",false);
}
if(validValue)
{
//continue ur logic
}
Regards
AG
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I've a function to get big decimal for your reference.
You can do this in a try/catch block to display in case of error.
Hope it helps.
yung siu wai
public java.math.BigDecimal getBigDecimalValue( java.lang.Object object )
{
//@@begin getBigDecimalValue()
if (object instanceof String){
return new BigDecimal((String)object);
} else if (object instanceof Integer){
return new BigDecimal(((Integer)object).doubleValue());
} else if (object instanceof BigDecimal){
return new BigDecimal(((BigDecimal)object).doubleValue());
} else return null;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sunita,
I never try it, but probabily it may help you, using isValid() function:
Regards,
Vito
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.