on 08-28-2009 12:11 PM
Hi,
I have a inputfiled with date type. If i enter any number without any format. I should get message like " Enter the value in the format 25/11/1987" . But that message is displaying only some time. But some time it display error message saying that nullpointer exception.
I should get that message all the time when i enter wrong date format value.
Regards,
H.V.Swathi
Where ever you are trying to use method compareTo and getYear from any date, that date should not be null.
Regards,
Rohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Swathi,
Null Pointer Exception is nothing to do with input Field with Date attribute. please check whether the cardinality of the node EmpDetail. the null pointer exception might be coz of empDetailElement or the date object being null .from the error trace , u will be able to find the actual line from where the exception is being raised. if possible post the error trace.
Thanks and Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Swathi,
I have a inputfiled with date type. If i enter any number without any format. I should get message like " Enter the value in the format 25/11/1987" . But that message is displaying only some time. But some time it display error message saying that nullpointer exception.
Can u post the complete Error trace ie Null Pointer Exception ?
Thanks and Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try{
Date dateb=wdContext.currentEmpDetailElement().getZem_Dob();
Date datej=wdContext.currentEmpDetailElement().getZem_Doj();
Date datec=wdContext.currentEmpDetailElement().getZem_Doc();
if((wdContext.currentEmpDetailElement().getZem_Dom()) != null)
{
if((wdContext.currentEmpDetailElement().getZem_Dom()).compareTo(dateb) > 0)
{
if((datej.getYear()-dateb.getYear()) >= 18 && datej.compareTo(datec) >= 0 ){
if(wdThis.emailTest(wdContext.currentEmpDetailElement().getZem_Mail())==true )
{
if(wdThis.validphoneno(wdContext.currentEmpDetailElement().getZem_Phone())==true)
{
wdThis.Save();
}
else
{
String errorMessage = "phone no is not valid !";
IWDEventHandlerInfo windowHandler = wdControllerAPI.getViewInfo().getViewController().findInEventHandlers("OK");
IWDConfirmationDialog windowDialog = wdComponentAPI.getWindowManager().createConfirmationWindow(errorMessage, windowHandler, "OK");
windowDialog.open();
windowDialog.setWindowPosition(300,250);
}
}
else
{
String errorMessage = "Email id or phone no is not valid !";
IWDEventHandlerInfo windowHandler = wdControllerAPI.getViewInfo().getViewController().findInEventHandlers("OK");
IWDConfirmationDialog windowDialog = wdComponentAPI.getWindowManager().createConfirmationWindow(errorMessage, windowHandler, "OK");
windowDialog.open();
windowDialog.setWindowPosition(300,250);
}
}
else
{
String errorMessage = "Date of joining should be Greater than the birth date and greater than date of conf !";
IWDEventHandlerInfo windowHandler = wdControllerAPI.getViewInfo().getViewController().findInEventHandlers("OK");
IWDConfirmationDialog windowDialog = wdComponentAPI.getWindowManager().createConfirmationWindow(errorMessage, windowHandler, "OK");
windowDialog.open();
windowDialog.setWindowPosition(300,250);
}
}
else
{
String errorMessage = "Date of marriage should be greater than birth date !";
IWDEventHandlerInfo windowHandler = wdControllerAPI.getViewInfo().getViewController().findInEventHandlers("OK");
IWDConfirmationDialog windowDialog = wdComponentAPI.getWindowManager().createConfirmationWindow(errorMessage, windowHandler, "OK");
windowDialog.open();
windowDialog.setWindowPosition(300,250);
}
}
else
{
if(((wdContext.currentEmpDetailElement().getZem_Doj()).getYear()-(wdContext.currentEmpDetailElement().getZem_Dob()).getYear()) >= 18 && (wdContext.currentEmpDetailElement().getZem_Doj()).compareTo(wdContext.currentEmpDetailElement().getZem_Doc()) >= 0 ){
if(wdThis.emailTest(wdContext.currentEmpDetailElement().getZem_Mail())==true )
{
if(wdThis.validphoneno(wdContext.currentEmpDetailElement().getZem_Phone())==true)
{
wdThis.Save();
}
else
{
String errorMessage = "phone no is not valid !";
IWDEventHandlerInfo windowHandler = wdControllerAPI.getViewInfo().getViewController().findInEventHandlers("OK");
IWDConfirmationDialog windowDialog = wdComponentAPI.getWindowManager().createConfirmationWindow(errorMessage, windowHandler, "OK");
windowDialog.open();
windowDialog.setWindowPosition(300,250);
}
}
else
{
String errorMessage = "Email id or phone no is not valid !";
IWDEventHandlerInfo windowHandler = wdControllerAPI.getViewInfo().getViewController().findInEventHandlers("OK");
IWDConfirmationDialog windowDialog = wdComponentAPI.getWindowManager().createConfirmationWindow(errorMessage, windowHandler, "OK");
windowDialog.open();
windowDialog.setWindowPosition(300,250);
}
}
else
{
String errorMessage = "Date of joining should be Greater than the birth date and greater than date of conf !";
IWDEventHandlerInfo windowHandler = wdControllerAPI.getViewInfo().getViewController().findInEventHandlers("OK");
IWDConfirmationDialog windowDialog = wdComponentAPI.getWindowManager().createConfirmationWindow(errorMessage, windowHandler, "OK");
windowDialog.open();
windowDialog.setWindowPosition(300,250);
}
}
}
catch(Exception e)
{
wdComponentAPI.getMessageManager().reportException("Error Message "+e.getMessage(),true);
wdComponentAPI.getMessageManager().reportException("Error Cause "+e.getCause(),true);
}
Hi,
I think exception is These two lines.
if ((wdContext.currentEmpDetailElement().getZem_Dom()).compareTo(dateb)> 0)
{
if ((datej.getYear() - dateb.getYear()) >= 18&& datej.compareTo(datec) >= 0)
Because might be either dateb or datec or datej is blank and you can't compare any date with blank(null) date. And if datej or dateb is blank then you are trying to fetch year from blank date which is also not possible. In these both conditions null pointer exception will be thrown.
I hope it helps.
Regards,
Rohit
Edited by: Rohit Makkar on Aug 28, 2009 5:58 PM
That null pointer exception might be due to some other line of code. Check the line number in the details of the error.
Proabaly add try and catch statements for the lines of code where u get the error.
For an input feild of date type you will always get the error message " Enter the value in the format 25/11/1987"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
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.