I receive the following exceptions org.zkoss.zk.ui.UiException
and java.lang.NumberFormatException
. Can someone please help? My stacktrace is as follows:
Nov 08, 2013 10:43:17 AM org.zkoss.zk.ui.impl.UiEngineImpl handleError:1359
SEVERE: >>org.zkoss.zk.ui.UiException: For input string: "Enter Number"
>>java.lang.NumberFormatException: For input string: "Enter Number"
>> at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
>> at java.lang.Double.parseDouble(Unknown Source)
>> at com.abcd.acd.a.web.viewmodel.FolderInfoEditViewModel.loadFolderInfoList(FolderInfoEditViewModel.java:633)
>> at com.abcd.acd.a.web.viewmodel.FolderInfoEditViewModel.afterCompose(FolderInfoEditViewModel.java:116)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
My Zul file:
<zk if="${civilInfoData.infoType.equalsIgnoreCase('n') and !civilInfoData.encrypted }">
<doublebox value="@bind(civilInfoData.folderInforecord.infoValueNumeric)"
hflex="1" placeholder="@load(vm.getText('FolderInfoDetail:LABEL_VALUE'))"
mandatory="@load(civilInfoData.folderInforecord.valueRequired)"
maxlength="10"
tooltiptext="@load(vm.getText('FolderInfoDetail:ENTER_NUMBER'))">
</doublebox>
</zk>
Viewmodel (FolderInfoEditViewModel.java):
if (info.getInfoType().equalsIgnoreCase("n")) {
if (StringUtils.isNotBlank(info.getFolderInforecord().getInfoValue()) &&
!info.getFolderInforecord().getInfoValue().equalsIgnoreCase("null")) {
info.setInfoNumericValue(Double.parseDouble(
info.getFolderInforecord()
.getInfoValue()));
}
}
Can someone tell me how can resolve this issue?
Thanks
info.getFolderInforecord().getInfoValue()
is returning a String
that does not successfully parse to a double
, which is why you're getting a NumberFormatException
. Without more information, that's all I can say.
You're only checking that's it's not blank and not equal to "null". You can stop your program from crashing by wrapping the code in a try/catch
where you handle the NumberFormatException