cancel
Showing results for 
Search instead for 
Did you mean: 

How to do validation of input fields

Former Member
0 Kudos

Hi all,

I have a rquirement to do the validation of input fields.Can anybody explain me how to go for that???Please explain in detail.U can also give me a link where i can find the tutorial for doing this.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Amit,

What everyone has said above is correct - in the method of your action simply test for whatever condition you need to validate for. However, the following tutorial shows you how to use Web Dynpro's Message Manager to display the messages on the screen in an easy user-friendly way:

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/wd%20java/wd%20tutorials/a%20simple%20input%20form%20with%20message%20and%20error%20service%20support.pdf">Enabling Message and Error Support</a>

In addition, there are some validations that are done automatically depending on what you have your input fields set to - for instance, if you bind your input field to a date and a user enters words into the field instead of an actual date, it will automatically display an error message. To learn how to turn this feature on and off, see this tutorial

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/edf6ea90-0201-0010-7696-a68662381c12">Using Validating and Non-Validating Actions</a>

Former Member
0 Kudos
Former Member
0 Kudos

Hi

if you are looking for your own validation u can get your values as this

String getYourData=wdThis.

wdGetYourComponentController().

wdGetContext().

currentYourNodeElement().

getYourElement();

and pass your data to a method where you do your validations if it meets your requiurements you can pass it on

other wise you can set your error message field like following

wdContext.currentContextElement().setDisplay("Your String");

Regards

Abhijith YS

Former Member
0 Kudos

Hi Amit,

It would be good if you give exact requirement that you need to have for your Input Field validation.

Assume that you need to check whether the input field is empty or not.

1. Create a value attribute called value1.

2. Bind this value1 to the value property of your Input Field.

3. Say you have a button where you need to apply validation of the form(inputfield over here).

So, on action of the button you can check the value of the context attribute

if(wdContext.currentContextElement().getValue1().equals(null))

{

//your logic

}

else

{

// your logic

}

Regards,

Murtuza