AnsweredAssumed Answered

Pouplate dropdown values from datalist using ListofValueConstraint

Question asked by sandhya.nair on Jul 15, 2019
Latest reply on Jul 15, 2019 by sandhya.nair



I want to dynamically populate the dropdown values in alfresco share. I have created a datalist to store the dropdown values and created a class extending the ListOfValuesConstraint class and calling it from the model file. But there is no option to get the search service or node service to look for the datalist values from the custom class. I dont want to store the dropdown values in database since the maintenence also will be difficult. To add a new value later we may have to contact the DB team insert values on that table. Please see the code below.


Model File configuration
<constraint name="hr:procesDropdownList"
<parameter name="allowedValues">


<property name="hr:process">
<index enabled="true">
<constraint ref="hr:procesDropdownList" />



<field id="hr:process"
label-id="form.field.label.hr_process" set="hrDocSet">
template="/org/alfresco/components/form/controls/selectone.ftl" />


public class ProcessDropdownListConstraint extends ListOfValuesConstraint{

private static ServiceRegistry serviceRegistry;

public void initialize() {


//I am unable to get the service registry object or  node Service or Search service here

public void setAllowedValues(List allowedValues) {
List<String> allowedValues1 = new ArrayList<String>();
allowedValues1.add("Holiday and Absense");
System.out.println("allowedValues1 "+allowedValues1);



Tried below code not working
ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
System.out.println("ctx "+ctx);


Also tried this way still getting application context as null.


public class ProcessDropdownListConstraint extends ListOfValuesConstraint implements ApplicationContextAware{

private static ServiceRegistry registry;
private static ApplicationContext applicationContext;

public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;



can anyone pelase help me on this?


Thanks in Advance,