Description: Limited to code that creates a custom list of values (LOV) for editable fields.
Abstract Base Class: AbstractExtensionLovFactory (responsible for constructing an LOV object to be executed later by the UI)
Interface: ELovFactory
Module: Framework
Version Added: 2.2
Requires Code Extension Name or Name Pattern: No
Code Extension Name or Name Pattern: N/A
Where to specify code extensions of this type: In the Variform File Definition form for the variform you are override. See Implement a groovy-driven LOV (on page 1).
The following sample code implements a custom LOV factory that returns query-based LOVs based on the following keys:
UsersStartingWithLetterA: A query for a list of users whose user IDs start with the letter A
CountriesWithStates: A query for a list of countries with states defined
import com.navis.framework.presentation.lovs.Lov
import com.navis.external.framework.ui.lov.AbstractExtensionLovFactory
import com.navis.framework.presentation.lovs.list.DomainQueryLov
import com.navis.framework.portal.query.DomainQuery
import com.navis.framework.presentation.lovs.Style
import com.navis.framework.portal.query.PredicateFactory
import com.navis.security.SecurityEntity
import com.navis.security.SecurityField
import com.navis.framework.portal.query.QueryFactory
import com.navis.reference.ReferenceEntity
import com.navis.reference.ReferenceField
import com.navis.framework.portal.query.OuterQueryMetafieldId
import com.navis.external.framework.ui.lov.ELovKey
public class CustomExtensionLovFactory extends AbstractExtensionLovFactory {
public Lov getLov(ELovKey inKey) {
if (inKey.represents("UsersStartingWithLetterA")) {
final DomainQuery dq = QueryFactory.createDomainQuery(SecurityEntity.BASE_USER);
dq.addDqField(SecurityField.BUSER_UID);
dq.addDqPredicate(PredicateFactory.like(SecurityField.BUSER_UID, "a%"));
DomainQueryLov dqLov = new DomainQueryLov(dq, Style.LABEL_ONLY);
return dqLov;
} else if (inKey.represents("CountriesWithStates")) {
DomainQuery subQuery = QueryFactory.createDomainQuery(ReferenceEntity.REF_STATE).addDqPredicate(PredicateFactory.eqProperty(ReferenceField.STATE_CNTRY,
OuterQueryMetafieldId.valueOf(ReferenceField.CNTRY_CODE)))
final DomainQuery dq = QueryFactory.createDomainQuery(ReferenceEntity.REF_COUNTRY);
dq.addDqField(ReferenceField.CNTRY_NAME);
dq.addDqPredicate(PredicateFactory.subQueryExists(subQuery));
DomainQueryLov dqLov = new DomainQueryLov(dq, Style.LABEL_ONLY);
return dqLov;
}
return null;
}
}
The following example variform definition uses this code extension:
<item fieldId="fooStaticallyDefinedDynamicComponent.fooSDCUserStartWithA">
<item-attribute type="lovKey">customCodeExtensionLov?EXTENSION=custom foo lov factory,KEY=UsersStartingWithLetterA</item-attribute>
<item-attribute type="widgetSubType">search</item-attribute>
</item>
<item fieldId="fooStaticallyDefinedDynamicComponent.fooSDCCountryCustomLov">
<item-attribute type="lovKey">customCodeExtensionLov?EXTENSION=custom foo lov factory,KEY=CountriesWithStates</item-attribute>
<item-attribute type="widgetSubType">search</item-attribute>
</item>