cancel
Showing results for 
Search instead for 
Did you mean: 

How to test that a field is not empty not using the button action method?

Former Member
0 Kudos
697

Hello,

I have a standard form with submit button.

Most of the input fields can't be empty on submit.

Is there any way in DynPro to test that these input fields are not empty other than checking each context at the action method handler of the button? I would like that the user will be notified of these fields before submiting the form (Like in Javascript...).

Roy

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Roy,.

there is one event handler onEnter with each inputfield, you can use it for the input fields. Whenever you press enter after leaving an InputField this event handler will fire. But that not similar to the JavaScript functionality u are talking about. There is nothing in WD like that functionality.

Regards,

Shubhadip

Former Member
0 Kudos

1. But what if I leave the field with TAB or just with the mouse?

2. So does it mean that DynPro is working solely Server side?

Roy

Former Member
0 Kudos

WD does the Data Type sort of validation in the client side only. It carries its own JS library to the clientside for that. But we developers dont have any place to put our JS code in it.. so it is.

Shubhadip

Former Member
0 Kudos

10X, so what about my problem? The onEnter will work if the user will leave the input field using TAB or mouse as well?

Roy

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi ,

If i am not not wrong ....This property just display "*" mark on the lable associated with the inputfield just to indicate that the inputfield is mandatory.But doesn't do any validations during runtime.

Regards, Anilkumar

Former Member
0 Kudos

Anilkumar is right.

Former Member
0 Kudos

Hi,

yep! its just for that * and nothing more !

Former Member
0 Kudos

Yes, you both right

To enforce entering text create Simple Type as specialization of string and define Min. Length constraint (1 or more)

VS

Former Member
0 Kudos

Hi Roy,

Yes, My mistake.

I have just checked. Its just for showing purpose.

Bhavik

Former Member
0 Kudos

Hey Valery,

I've tried that but I don't see any validation after the submit...

Roy

Former Member
0 Kudos

Hey,

I am not creating a simple type will give a error in that input field itself.

But anyway check if the action handler has without validation unchecked.

Former Member
0 Kudos

Hey Bharathwaj,

The action handler has without validation unchecked.

So, isn't there a way to check that an input field is not empty before submitting it? Sounds a bit strange to me that such a basic service is not provided at DynPro...

Roy

Former Member
0 Kudos

Hi,

You can do one thing..Manually check them. And use reportContextattributeMessage of MessageManager to report the error for each input field.

And there is a method in the controller called wdDoBeforeNavigation which is executed before each navigation...

Try making use of this.I will think if i can find a way of using this function!

cant think of anythin else!:)

Regards

Bharathwaj

Former Member
0 Kudos

Hey Bharathwaj,

Well, at the moment no, but I wanted to avoid this manual check. I guess there is no choice than...

Roy

Former Member
0 Kudos

Roy,

Please describe your steps. It should work

VS

Former Member
0 Kudos

Hey Valery,

I am creating a simple type of type String for example, set it's Minimum to 1, set it to "Not Null" as well and bind it to the relevant instance at the context. The relevant instance at the context I am binding to the input field.

Roy

Former Member
0 Kudos

Hi Roy,

Yes, you can do it. For that change the state of the Inputfiled to "Required".

There is one property of Input field element that is, "STATE". You have to set its value as "required".

It will do validation on client side whether field is empty or not.

Regards,

Bhavik

guru_subramanianb
Active Contributor
0 Kudos

Hi Roy,

Webdynpro by itself does not support Javascipt as the webdynpro meta model has no support to javascript.

But you can acheive client side validation in an alternative way.

There is an inbuilt java class in Webdynpro called as Message manager class. This class has some methods which helps us to find whether a particular UI elemnt say a Input field in empty or not by clicking a button.

Here is the link for the same.This is slove your problem.

http://help.sap.com/saphelp_erp2004/helpdata/en/72/1d6526263ff24995016a152705eab2/frameset.htm

Regards,

Guru

P.S :- Close this thread if you are satisfied with the answer and reward points suitably.

Former Member
0 Kudos

No It will not .

Only way i can see is validating through context.

Regards, Anilkumar

Message was edited by: Anilkumar Vippagunta