on 04-24-2008 7:21 AM
Hi All
I have to add an input field which will accept email Id from users. This field has to be kept mandatory. I have kept a check on the value entered. If the user does not enter any value, an error message should be displayed. Below is the code that I have written. Whenever, the user keeps this field blank and submits the form, null point exception error is displayed.
Please help how to overcome this problem
email = wdContext.currentContextElement().getEmail_Id();
try{
if (wdContext.currentContextElement().getEmail_Id().equals("") )
{
IWDMessageManager msg = wdThis.wdGetAPI().getComponent().getMessageManager();
msg.reportMessage(IMessageTender_ResignationComp.PERSONAL_EMAIL_ID,new Object[]{"Please enter correct Email Id"},true);
}
else
{
.......
....
}
Hi Umang,
Instead of
if (wdContext.currentContextElement().getEmail_Id().equals("") )
try
if (wdContext.currentContextElement().getEmail_Id() == null || wdContext.currentContextElement().getEmail_Id().equals("") )
Regards,
Gopal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
Actually as soon as it finds null, it throws the null pointer exception.....for this you can try the following code:
String val=wdContext.currentContextElement().getEmail_Id().
int length=(val==null)?0:val.length();
if(length==0)
{
msg1.raiseMessage(IMessageComp_Message.EMPID,new Object[]{""},true);
}
regards,
pinki
Hi
Check your Code....
And Debug you app then find where is the error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Umang,
try this,
String E_Mail = wdContext.currentContextElement().getMail();
if(E_Mail.equals(""))
{
wdComponentAPI.getMessageManager.reportException("Please enter valid EMail Id",true);
}
else
{
//Process
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Put the code as follows:
String email = wdContext.currentContextElement().getEmail_Id();
if( email.equals( "") || ( email == null) || ( email.length == 0))
{
wdComponentAPI.getMessageManager().reportWarning( "The email field can not be empty!");
}
// checking in three conditions: one for empty second for null value and the last by length of the input email string.
Regards
Vinod V
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
u can initialize the email id attribute to blank in init method
then u can try the following code
if(wdContext.currentContextElement().getAtribute().equalsIgnoreCase(""))
{
print error mesage
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Umang ,
If the input field is blank, the the chances are node wdContext.currentContextElement()
will be Null. You you cannot get Email id using get Email id, if the node object is null.
Try like this..
if( wdContext.currentContextElement() != null && wdContext.currentContextElement().getEmail_Id().size() == 0){
IWDMessageManager msg = wdThis.wdGetAPI().getComponent().getMessageManager();
msg.reportMessage(IMessageTender_ResignationComp.PERSONAL_EMAIL_ID,new Object[]{"Please enter correct Email Id"},true);
}
Hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Change the following code to
email = wdContext.currentContextElement().getEmail_Id();
try{
if (wdContext.currentContextElement().getEmail_Id().equals("") )
{
IWDMessageManager msg = wdThis.wdGetAPI().getComponent().getMessageManager();
msg.reportMessage(IMessageTender_ResignationComp.PERSONAL_EMAIL_ID,new Object[]{"Please enter correct Email Id"},true);
}
if (wdContext.currentContextElement() != null)
{
email = wdContext.currentContextElement().getEmail_Id();
if ( email.equals("") )
{
IWDMessageManager msg = wdThis.wdGetAPI().getComponent().getMessageManager();
msg.reportMessage(IMessageTender_ResignationComp.PERSONAL_EMAIL_ID,new Object[]{"Please enter correct Email Id"},true);
}
}
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Umang,
if (wdContext.currentContextElement().getEmail_Id().equals("") )
instead of this line try the below code.
if(email == null || email.trim().length() == 0){
IWDMessageManager msg = wdThis.wdGetAPI().getComponent().getMessageManager();
msg.reportMessage(IMessageTender_ResignationComp.PERSONAL_EMAIL_ID,new Object[]{"Please enter correct Email Id"},true);
}
Hope it resolves your problem.
Thanks n Regards,
Jhansi Mirayala
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.