Creating calculated datalist columns in Alfresco Share 3.4b

This is a short one since not much changed. If you didn’t have a chance to read the 3.3 version of this please review it now since I’m not going to post the entire tutorial again. We only need to change the filter and specifically how the dynamic columns are added to the form. public class ProjectStatusFilter extends AbstractFilter { @Override public void afterGenerate(Object item, List fields, List forcedFields, Form form, Map context) { boolean typeDefCorrect = (item instanceof TypeDefinition && ((TypeDefinition) item) .getName().equals(PmoModel.TYPE_PROJECT_STATUS_DL)); boolean nodeRefCorrect = (item instanceof NodeRef && AlfUtil.services() .getNodeService().getType((NodeRef) item).equals( PmoModel.TYPE_PROJECT_STATUS_DL)); if (typeDefCorrect || nodeRefCorrect) { double varianceValue = 0d; double percentComplete = 0d; double percentExpended = 0d; // If this is a node then do the calculations if (nodeRefCorrect) { NodeRef itemNode = (NodeRef) item; /* Some calculations that aren't interesting */ } /* Here are the changes for 3.4b */ form.addField(FieldUtils.makePropertyField(PmoModel.variancePropDef, varianceValue,AlfUtil.services().getNamespaceService())); } } /* Left the other 3 fuctions for completeness */ @Override public void afterPersist(Object item, FormData data, NodeRef persistedObject) {} @Override public void beforeGenerate(Object item, List fields, List forcedFields, Form form, Map context) {} @Override public void beforePersist(Object item, FormData data) {} }

October 28, 2010 · 1 min · Dan

Creating calculated datalist columns in Alfresco Share 3.3

Datalists out-of-the-box don’t have a whole lot of functionality outside of simply capturing data. A simple way to help users is to add calculated columns that transform other columns or related data from the repository. In Alfresco 3.3 this functionality is straightforward and allows creating powerful datalists that even an Excel user could love. For this demo we will create a part of a project management datalist that takes allows users to enter the following: Estimated to completion, estimated at completion, actuals and budget. From these inputs we will generate the variance, percent complete and percent expended. ...

October 25, 2010 · 4 min · Dan