Skip to Content

Here is a short tip on the IWDValueSupplier and what it can be used for.

Background 

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.

image

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.  

The Problem

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

 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.

Example

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.

Outlook

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. 

Credits

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.

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Alvaro Tejada Galindo
    Hi David:

    Your blog is very nice and informative, even when I’m not into WebDynpro for Java -;) But…Second box of code is kinda short…Could you make it bigger??? It would be easy for others to read it -:)

    Greetings,

    Blag.

    (0) 
  2. Kranthi Paruchuri
    I really like this hack!

    Standard EVS accept the key only with exact case. I have been looking for a clean way  to accept direct input without case.
    [code]
    public boolean contains(Object aKey) {
         Set keys = values.keySet();
         for (Iterator iter = keys.iterator(); iter.hasNext();) {
              String key =  (String)iter.next();
                   if(key.equalsIgnoreCase((String)aKey)) {
                        return true;
                   }                    
              }            
                    return false;
         }
    [/code]

    (0) 

Leave a Reply