In the new IDE if we try to use interal api it gives error.
But in the runtime it doesn't give error. But for pre-cautionary sake changed the logic for getting the ViewCriteria for setting the value.
Changed the FacesControlLOVBinding.ListOfValuesModelImpl to oracle.adf.view.rich.model.ListOfValuesModel which is not internal api. and for getting the ViewCriteria for the current LOV changed the code like in the below screenshot.
New Code And the Source which will run in Jdev 11.1.1.4 is below
Download: Latest Source For Exact Match LOV In Jdev 11.1.1.4
public void lovcustomLaunch(LaunchPopupEvent launchPopupEvent) { String currentColumnName = null; String valueExpression = null; JUCtrlListBinding ctrlListBinding = null; ViewObject baseViewObject = null; AttributeDef lovAttributeDef = null; AttributeDef lovlistAttributeDef = null; ListBindingDef listBindingDef = null; String[] listAttributeNames = null; ListOfValuesModel listOfValuesModel = null; ViewCriteria viewCriteria = null; Object submittedValue = null; ViewCriteriaRow viewCriteriaRow = null; RowSet rowSet = null; Row listRow = null; Row baseViewObjectRow = null; if (!launchPopupEvent.isLaunchPopup()) { return; } submittedValue = launchPopupEvent.getSubmittedValue(); if (submittedValue == null) { return; } BindingContext bindingContext = BindingContext.getCurrent(); BindingContainer bindingContainter = bindingContext.getCurrentBindingsEntry(); RichInputListOfValues inputListOfValues = (RichInputListOfValues)launchPopupEvent.getComponent(); if(inputListOfValues != null) { // below code gets the value expression for the current column i.e in our case #{bindings.DepartmentId.inputValue} valueExpression = inputListOfValues.getValueExpression(inputListOfValues.VALUE_KEY.getName()).toString(); if (valueExpression != null) { // if the column is in the af table then the value will be #{row.bindings.DepartmentId.inputValue} so we are replacing row. valueExpression = StringUtils.replace(valueExpression, "row.", ""); currentColumnName = valueExpression.substring(valueExpression.indexOf(".")+1, valueExpression.lastIndexOf(".")); if (currentColumnName != null) { ctrlListBinding = (JUCtrlListBinding)bindingContainter.getControlBinding(currentColumnName); if (ctrlListBinding != null) { baseViewObject = ctrlListBinding.getIteratorBinding().getViewObject(); if (baseViewObject != null) { baseViewObjectRow = baseViewObject.getCurrentRow(); lovAttributeDef = baseViewObject.findAttributeDef(currentColumnName); if (lovAttributeDef != null) { listBindingDef = lovAttributeDef.getListBindingDef(); if (listBindingDef != null) { listAttributeNames = listBindingDef.getListAttrNames(); if (listAttributeNames != null && listAttributeNames.length > 0) { listOfValuesModel = inputListOfValues.getModel(); if (listOfValuesModel != null) { viewCriteria = ctrlListBinding.getListIterBinding().getViewObject().getViewCriteriaManager().getViewCriteria(listBindingDef.getDisplayCriteriaName()); if (viewCriteria !=null) { viewCriteriaRow = (ViewCriteriaRow)viewCriteria.getRowAtRangeIndex(0); if (viewCriteriaRow != null) { lovlistAttributeDef = viewCriteriaRow.getStructureDef().findAttributeDef(listAttributeNames[0]); if (lovAttributeDef != null) { if (lovAttributeDef.getSQLType() == OracleTypes.NUMBER) { viewCriteriaRow.setAttribute(listAttributeNames[0], submittedValue); viewCriteriaRow.getCriteriaItem(listAttributeNames[0]).setOperator(JboCompOper.OPER_EQ); }else if (lovAttributeDef.getSQLType() == OracleTypes.VARCHAR) { viewCriteriaRow.setAttribute(listAttributeNames[0], submittedValue+"%"); viewCriteriaRow.getCriteriaItem(listAttributeNames[0]).setOperator(JboCompOper.OPER_LIKE); } listOfValuesModel.performQuery(listOfValuesModel.getQueryDescriptor()); if (ctrlListBinding.getListIterBinding().getRowSetIterator() != null && ctrlListBinding.getListIterBinding().getRowSetIterator().getRowCount() > 0) { rowSet = ctrlListBinding.getListIterBinding().getRowSetIterator().getRowSet(); listRow = rowSet.getRowAtRangeIndex(0); if (listRow != null && listRow.getAttribute(listAttributeNames[0]).equals(submittedValue)) { if (baseViewObjectRow != null) { baseViewObjectRow.setAttribute(currentColumnName, submittedValue); } RowKeySetImpl rowKeySet = new RowKeySetImpl(); List list = new ArrayList(); list.add(listRow.getKey()); launchPopupEvent.setLaunchPopup(false); launchPopupEvent.queue(); inputListOfValues.queueEvent(new ReturnPopupEvent(inputListOfValues,rowKeySet)); AdfFacesContext.getCurrentInstance().addPartialTarget(inputListOfValues); } } } } } } } } } } } } } } }
Hi, I have a little problem with this piece of code. When I use it the ValueChangeEvent of the LOV is not launching. ¿Any workaround? Thanks!
ReplyDeleteHi, I took the project and imported in JDev 11.1.2.1.0 (through migration process) and it seems not to work, even if an exact match is inserted, the LOV will still launch. Do you know if what you presented works only on specific versions of JDev? Thanks, Georgiana
ReplyDelete