ADF

How to get LOV value instead of index when it is used in standalone ADF “selectOneChoice” component ?

Its a common issue in ADF to get a LOV value instead of index in ADF form. How to do that in collection context, for example – when we have “selectOneChoice” in table row cell, I’ve noted in another post. And that was really easy. Its more complicated when we need the same in “selectOneChoice” used in form, standalone component and especially when it is populated with static values and has no bindings. Shortly saying, irrespective of use case, this helper function can be used to determine value instead of index:

 public static DCDataControl getDataControl(String name) {
     FacesContext fctx = FacesContext.getCurrentInstance();
     BindingContext bindingContext = BindingContext.getCurrent();
     return bindingContext.findDataControl(name);
 }
public static String getLookupIndexCode(String lookupVOInstanceName, int ind) {
    ApplicationModule myAppModule = (ApplicationModule) getDataControl("MyDataControl").getDataProvider();
    ViewObject vo =myAppModule.findViewObject(lookupVOInstanceName);
    Row vr = vo.getRowSet().getRowAtRangeIndex(ind);
    return (String) vr.getAttribute("Code");
}

ADF Version 12.2.1.0.0