Skip to Content
0
Former Member
Jun 05, 2008 at 03:06 PM

Problem with value selector in WD Java

16 Views

Hi.

I have a view with an input field which is bound to a String node in the context. In the wdDoInit() of the component controller I query a database table to fill the values for a value selector for this field. Bear with me, please:

private void fillListWithMasterData(String category, String contextAttribute) {

// category needed for select in DB, contextAttribute is the name of the attribute for which
// we are filling the value selector

  try {
    MasterDataServiceHome mdmHome = MasterDataServiceLocator.getMasterDataServiceHome();
    MasterDataService service = mdmHome.create();
    MasterDataDTO[] masterData = service.getMasterData(category); //gets the entries from the DB

    if (masterData != null && masterData.length > 0) { // contains all the expected entries
      Properties dataAsProps = new Properties();

      for (int i=0; i < masterData.length; i++) {		
        String code = masterData<i>.getCode();
        String text = masterData<i>.getText();
        if (code != null && code.length() > 0)	{	
          dataAsProps.put(code, text);	
        }
      }

      wdContext.currentContextElement().setCampaignID(null);
      this.fillPickList(contextAttribute, dataAsProps);	
    } 	    
  }
  catch (Exception ex) {
    wdComponentAPI.getMessageManager().reportException(ex.toString(), true);
  }
}

private void fillPickList(String attribute, Properties data) {
  ISimpleTypeModifiable enumType = wdThis.wdGetAPI().getContext().getModifiableTypeOf(attribute);
  IModifiableSimpleValueSet enumSet = enumType.getSVServices().getModifiableSimpleValueSet();
  enumSet.clear();

  try {
    Iterator it = data.keySet().iterator();
    while (it.hasNext()) {
      String key = (String)it.next();
      String value = data.getProperty(key);
      enumSet.put(key, value);
    }

    enumSet.sort(false, true, false);
  } catch (Exception ex) {
    String message = "Exception in fillPickList: " + ex.toString();
    wdComponentAPI.getMessageManager().reportException(message, true);
  }
}

The value selector is rendered just fine, and as to be expected it shows two columns, one for the key and one with the corresponding values.

Unfortunately I somehow can't add screenshots here, so I will try to explain the actual problem:

one returned key-value pair is

key -> CRM-BRI-1

value -> CRM-BRI-TEST

I have debugged many times to find that this pair exists as described. Now one would expect that, were I to expand the value selector and enter "BRI" in the filter area for the key column, this key-value pair would be visible for selection? Not the case. Nothing is selectable. Instead, this happens only when I enter "bri" (in lower case).

Though, as mentioned, the items are in the IModifiableSimpleValueSet as described, I have tried toUpperCase() wherever possible - to no avail.

Does anybody have an idea?

Cheers,

Harald