views:

37

answers:

0

Hi,

I'm trying to follow the examples provided in this post, to create a dynamic list constraint in Alfresco 3.3.

So, I've created my own class extending ListOfValuesConstraint:

public class MyConstraint extends ListOfValuesConstraint {
    private static ServiceRegistry registry;

    @Override
    public void initialize() {
        loadData();
    }

    @Override
    public List getAllowedValues() {
        //loadData();
        return super.getAllowedValues();
    }

    @Override
    public void setAllowedValues(List allowedValues) {
    }

    protected void loadData() {
        List<String> values = new LinkedList<String>();
        String query = "+TYPE:\"cm:category\" +@cm\\:description:\"" + tipo + "\"";
        StoreRef storeRef = new StoreRef("workspace://SpacesStore");
        ResultSet resultSet = registry.getSearchService().query(storeRef, SearchService.LANGUAGE_LUCENE, query);
        // ... values.add(data obtained using searchService and nodeService) ...

        if (values.isEmpty()) {
            values.add("-");
        }
        super.setAllowedValues(values);
    }
}

ServiceRegistry reference is injected by Spring, and it's working fine. If I only call loadData() from initialize(), it executes the Lucene query, gets the data, and the dropdown displays it correctly. Only that it's not dynamic: data doesn't get refreshed unless I restart the Alfresco server.

getAllowedValues() is called each time the UI has to display a property having this constraint. The idea on the referred post is to call loadData() from getAllowedValues() too, so the values will be actually dynamic. But when I do this, I don't get any data. The Lucene query is the same, but returns 0 results, so my dropdown only displays -.

BTW, the query I'm doing is: +TYPE:"cm:category" +@cm\:description:"something here", and it's the same on each case. It works from initialize, but doesn't from getAllowedValues.

Any ideas on why is this happening, or how can I solve it?

Thanks

Edit: we upgraded to Alfresco 3.3.0g Community yesterday, but we're still having the same issues.

related questions