Web Dynpro Tip: Using the ValueSupplier to have a ValueSet and free text input
Here is a short tip on the IWDValueSupplier and what it can be used for.
Web Dynpro input fields are very powerfull. When you bind a Context Attribute of type date the input field will show a small button to show a calendar. If the datatype of the attribute has a valueset assigned you will have the F4 help that enables you to choose values from list.
The validation works automatically. That means depending on the datatype and its meta data (textservice, valueservice) the input of the field is validated. Example if it is a date field only dates are allowed and if it has a Valueset (called enumeration in the java dictionary) only values are allowed that are contained in the valueset.
You want to offer the user a list of predefined values BUT also allow him to enter a value that is NOT in the valueset. The problem is whenever you execute a validating action in that view, Web Dynpro will mark that field in red and tell you that this value is not contained in the list of values. So how can you provide the user with a valuehelp without limiting the entry of free text?
The solution is that you either change all action to “not validating” which I find a very ugly solution. The better solution is to implement a IWDValueSupplier yourself, where you can control the Valueset and the check method (contains(obj)) and override them to your needs.
Here is an example of a ValueSet that allows you to enter free text:
The second step is to bind this ValueSupplier to a specific attribute in the Context.
This ValueSupplier can of course be enhanced. For example you can implement a ValueSupplier that fills its values depending on another value in the Context or you can do a lazy loading value supplier that loads the valueset ondemand from the database. There you can implement filter functionality yourself etc.
I came across this solution together with Reto Badertscher of Holcim AG. Thanks also to Bertram Ganz and Valery Silaev for their many Weblogs, inspiration and hints in the forum.