Showing posts with label LOV. Show all posts
Showing posts with label LOV. Show all posts

Wednesday, February 4, 2015

Assigning default search values for LOV Search and Select popup

Values for search attributes on LOV Search and Select popup can be preset using a launchPopupListener method

<af:inputComboboxListOfValues id="inpClv2"
    popupTitle="Search and Select: #{bindings.StateProvince.hints.label}"
    value="#{bindings.StateProvince.inputValue}"
    label="#{bindings.StateProvince.hints.label}"
    model="#{bindings.StateProvince.listOfValuesModel}"
    required="#{bindings.StateProvince.hints.mandatory}"
    columns="#{bindings.StateProvince.hints.displayWidth}"
    shortDesc="#{bindings.StateProvince.hints.tooltip}"
    launchPopupListener="#{backingBeanScope.lovBean.stateLaunchPopupListener}"> 
</af:inputComboboxListOfValues>


Suppose if we want to preset CountryId in Search and Select popup for State LOV, the launchPopupListener code will look like:
public void stateLaunchPopupListener(LaunchPopupEvent launchPopupEvent)
{
    UIXInputPopup lovComponent = (UIXInputPopup)launchPopupEvent.getSource();
    ListOfValuesModel model = lovComponent.getModel();
    if (model != null)
    {          
        QueryDescriptor queryDesc = model.getQueryDescriptor();
        ConjunctionCriterion conCrit = queryDesc.getConjunctionCriterion();
        List<Criterion> criterionList = conCrit.getCriterionList();
        for (Criterion criterion: criterionList)
        {
            AttributeDescriptor attrDesc = ((AttributeCriterion) criterion).getAttribute();
            if (attrDesc.getName().equalsIgnoreCase("CountryId")) 
            {
                List values = ((AttributeCriterion) criterion).getValues();
                values.set(0, "US"); 
            }
        }
    }           

}