cancel
Showing results for 
Search instead for 
Did you mean: 

Check Mandatory Fields (Dynamic Programming)

0 Kudos

Hi All,

I am currently generating UI elements dynamically. I have few elements in these dynamically generated elements which are mandatory. Does anyone has information about how to programmatically check whether the entries have been made before the user is allowed to proceed to the next step? I have maintained the state property of the InputField and the webdynpro application doesnot automatically checks for the entries.

Any help will be greatly appreciated.

Thanks and regards,

Hemanth

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Hemanth,

there are at least two ways to do this:

1. Define some simple types in the local dictionary with minLength > 0 and use this simple types as the property types of the context attributes. If you bind the UI elements to this context attributes, the WD runtime will do the checks automatically.

2. Check the contents of the UI elements with required input manually (by checking the contents of the bound context attributes). Use the report(Invalid)ContextAttribute... methods of the <a href="https://media.sdn.sap.com/html/submitted_docs/60_sp2_javadocs/webdynpro/com/sap/tc/webdynpro/progmodel/api/IWDMessageManager.html">Message Manager API</a> to report missing data.

Hope that helps.

Regards

Stefan

PS: The state property is just a visual indicator for required/not required fields and doesn't trigger any automatic validation.

0 Kudos

Hi Stefan,

I tried the first approach of specifing the minLength in my dynamically generated UI elements but the WD runtime doesnot seem to check for the entry.

For the second approach, I need to capture all the needed fields that are generated dynamically into the context with the information about whether they are mandatory or not and then check the content to see whether the user has specified anything or not. Please correct me if I am wrong.

Thanks and regards,

Hemanth

Former Member
0 Kudos

Hi Hemanth,

yes, for the second approach you need the information, which field is mandatory and doesn't contain any content. Since you created the context attributes already, all you need to do is to get the content values from the mandatory context attributes and validate them against the criterias needed for your application (null, empty in case of String and so on). This can be done easily by creating and calling a generic method, which gets the node element, the attribute name of the attribute to check and the message key of a error, which is used for report(Invalid)ContextXX().

But i'm still a little bit astonished, that the first approach didn't work for you.

Hope that helps.

Regards

Stefan