Skip to Content
h2. Motivation  The Web Dynpro Object Value Selector is a generic API to add a Search Help to an input field.imageIn contrast to the Extended Value Selector you can define the fields that provide Search input and the result structure yourself. From the input and output structure a search popup is dynamically created. In my opinion it is feasible for simple searches that are a more complex than just searching a key out of a valueset. The biggest problem is that you have very little control over the layout of the search popup why I think it should not be overused. Nevertheless for simple searches it really serves the purpose. There are plenty examples and tutorials on how to program an OVS. I just always found the API too tedious to be usefull. That is why I collected some pieces and advices from other tutorials and blogs and made up a very small helper library that makes creating OVS searches much easier. h2. The basics The OVS search needs a definition of an search input  and search result structure.image
To report this post you need to login first.

11 Comments

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

  1. Valery Silaev
    However, I have some suggestions to your post:
    1. Make addProperty method of both InputInfo and ResultInfo to return InputInfo/ResultInfo itself. This is very common pattern for builders (see java.lang.StringBuffer for example) and allows to chain invocations:
    getResultInfo()
      .addProperty(“id”,”Customer ID”,Integer.class)
      .addProperty(“lastName”,”Last Name”,String.class)
      .addProperty(“firstName”,”First Name”,String.class)
    ;
    2. Probably it’s a good idea to add generic applyResult implementation, at least in custom subclass:
    public class public class CustomerOVSBuilder extends BaseOVSBuilder {
      private String nodeAttrName, modelAttrName;

      public CustomerOVSBuilder() {this(null, null);}

      public CustomerOVSBuilder(String nodeAttrName, String modelAttrName) {
        …
        this.nodeAttrName = nodeAttrName;
        this.modelAttrName = modelAttrName;
      }

      public void applyResult(
        IWDNodeElement inputElement,
        ICMIGenericModelClass resultBean) {

        if (null == nodeAttrName || null == modelAttrName)
          throw new IllegalStateException(“Both nodeAttrName and modelAttrName must be defined via constructor or applyResult method must be overridden”);

        inputElement.setAttributeValue(      nodeAttrName,resultBean.getAttributeValue(modelAttrName)
        );
       }
    }

    (0) 
  2. Kapil Kamble
    Hello David.
    I was trying out your OVS Builder sans hard coded MyDummyDAO. I m stuck.
    I have a web service which gives me data and I want to apply this OVS on one of the attributes.
    So, wanted to know how can your OVS builder be implemented to consume data from back-end ?
    I hope the scenario described me is clear. If not, please reply.
    Thanks and Regards
    Kapil S Kamble
    (0) 
    1. David Beisert Post author
      Hi Kapil,

      actually it works just the same, as with the DAO.
      Given you have a similar WS ( I am just too lazy now to create one so this is hypothetical).

      public Collection search(ICMIGenericModelClass inputBean) {
      String lastName = (String)inputBean.getAttributeValue(“lastName”);
      Request_GetCustomers req = new Request_GetCustomers();
      SearchInput inp = new SearchInput();
      inp.setLastName(lastName);
      req.setSearchInput(inp);
      req.execute();
      return req.getResponse().getResult();

           return dao.findCustomers(id,lastName,firstName,gender,money);
      }

      /**
      * The Collection returned by search is iterated and for each element in the Collection
      * this method is called that enables you to convert your Object from the query to
      * a generic CMI Bean that the OVS expects.
      */
      public void transformResult(Object resultObject, ICMIGenericModelClass resultBean) {
           Customer c = (Customer)resultObject;
           
           resultBean.setAttributeValue(“id”,c.getId());
           resultBean.setAttributeValue(“lastName”,c.getLastName());
           resultBean.setAttributeValue(“firstName”,c.getFirstName());
           resultBean.setAttributeValue(“gender”,c.getGender());
           resultBean.setAttributeValue(“money”,c.getMoneyToSpent());
      }

      (0) 
  3. Lev Kulaev
    Hello David!
    This is a really fantastic tool! It working fine in 7.0 (former nw2004s). But we have a problem in 7.2. We migrated our components from 7.0 to 7.2 and now OVS working strange – OVS doesn’t take into account input values and doesn’t show result values but apply result is working. How we can esolve this error?
    (0) 
      1. Lev Kulaev
        Hello, David! Thank you for quick reply! Unfortunately new version has no effect. I’ve even placed OVSBuilder extension class in the component controller but the  error is the same: values entered into input fields in OVS screen don’t take effect in query, result values are not shown in result table but passed to the main screen by applyResult.
        (0) 

Leave a Reply