cancel
Showing results for 
Search instead for 
Did you mean: 

how to check whether the input fields are empty or not?

Former Member
0 Kudos

Hi all,

I have got a requirement in which i have two input fields say x1 and x2 , here i need to make sure that both the input fields are not empty and secondly, they are same ....

Wat's the appropriate code to be written in the implementation part ?

And the other problem that i'm facing is that - i have got 2 views, when i am clicking on a button on view 1, a dump message is getting displayed, i have checked in for all the possible chances for error like 1) action 2) link of action to button 3) fire button statement in action implementation part, but the error is clueless....

thanks in advance ....

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ,

For Inputfield validation use this code

if 2 input fileds are x1 and x2

if( (wdContext.currentContextElement().getx1 != null || wdContext.currentContextElement().getx1 != "") && (wdContext.currentContextElement().getx2 != null || wdContext.currentContextElement().getx2 != "") &&( wdContext.currentContextElement().getx1() .equals(wdContext.currentContextElement().get21() ) )

{

//your code

}

Regards,

Sunitha Hari

Answers (4)

Answers (4)

Former Member
0 Kudos

Vipin,

code to check the input fields


//works only if the type of elements binded to UI is string
if( (wdContext.currentContextElement().getX() == null) || (wdContext.currentContextElement().getY() == null))
{
   wdComponentAPI.getMessageManager().reportWarning( "Fields are empty");
}else{
if( wdContext.currentContextElement().getX().equals( wdContext.currentContextElement().getY()))
{wdComponentAPI.getMessageManager().reportSuccess( "Values are same");
}else
{wdComponentAPI.getMessageManager().reportWarning( "Values are not same");
}
}

Don't understand the second Question, since its not elaborated.

Please give the error message its showing while clicking the button.

Regards

Vinod

Edited by: Vinod V on Jul 14, 2008 8:21 PM

Former Member
0 Kudos

thanks, for all ur repsonses and help, both my problems are solved.

Former Member
0 Kudos

Hi,

try to read the value of the context which you have created for the input field.

Like:- (a)name, (b)age

if((wdcontext.currentContextNode.getName()!=null)&& (wdcontext.currentContextNode.getName()!=null)){

///your code

}else{

//error msg

}

Regarding you second error, you have mentioned like there are two views after coming to the 1st view what action you are doing. Are you trying to navigate to the 2nd on any action on the 1st page. if you are want to navigate you need to attach a fireplug.

If not than please more input for the Second error like what excat message you are getting.

Hope that may help you.

Regards,

Deepak

PradeepBondla
Active Contributor
0 Kudos

Hi,

I support the above 2 replies... and also check the below blog for input field / form validations. its very helpful for all input field validations...

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/60db527d-7be4-2a10-0283-e915cfb1...

with this you will come to know for empty input field. after that if you want to check both the input fields should be same then....

get the input field current element, store in one string ( say s1)and same as second one (say s2)...
if( s1.equalsIgnoreCase(s2))
{
// write your message here
}

this will also helps you in understanding the code

regards,

Pradeep

jnmurthi
Participant
0 Kudos

hi,

regarding input field validation, if both the input fields are bind to a context attributes, then it is easier to validate them. you can use message pooling concept and throw error when the field is validated.

the following link would help you regarding that

[http://help.sap.com/saphelp_nw70/helpdata/en/36/d4528e6dbf084b9d79a50fb8d08e86/content.htm]

if you want to validate without using message pool, then you can do that by writing the following code:

if x1, x2 are the input fields and att1, att2 are the context attributes bind to the input fields respectively, then

if(wdContext.currentcontextelement.getAtt1 != null) && (wdContext.currentcontextelement.getAtt2 != null)

{

//required coding

}

regards,

Murthy.

Edited by: Narayana Murthy on Jul 14, 2008 7:58 AM