Just went looking through to code again to confirm a suspicion. This is only half of the story; the other half is the overrides you have to make in the admin code itself. This snippet is copy/pasted from the OrderListDataSourceFactory class that is included in BLC:
Code: Select all
public class OrderListDataSourceFactory implements DataSourceFactory {
public static ListGridDataSource dataSource = null;
public void createDataSource(String name, OperationTypes operationTypes, Object[] additionalItems, AsyncCallback<DataSource> cb) {
if (dataSource == null) {
operationTypes = new OperationTypes(OperationType.ENTITY, OperationType.ENTITY, OperationType.ENTITY, OperationType.ENTITY, OperationType.ENTITY);
PersistencePerspective persistencePerspective = new PersistencePerspective(operationTypes, new String[]{}, new ForeignKey[]{});
DataSourceModule[] modules = new DataSourceModule[]{
new BasicClientEntityModule(CeilingEntities.ORDER, persistencePerspective, AppServices.DYNAMIC_ENTITY)
};
dataSource = new ListGridDataSource(name, persistencePerspective, AppServices.DYNAMIC_ENTITY, modules);
dataSource.buildFields(null, false, cb);
} else {
if (cb != null) {
cb.onSuccess(dataSource);
}
}
}
}
Notice this line here:
Code: Select all
PersistencePerspective persistencePerspective = new PersistencePerspective(operationTypes, new String[]{}, new ForeignKey[]{});
That second String[] parameter corresponds to nonPersistentFields that you want to add to the list of fields. In your specific case, you would change this line to the following:
Code: Select all
PersistencePerspective persistencePerspective = new PersistencePerspective(operationTypes, new String[]{"getTotalFees"}, new ForeignKey[]{});
With that change, now the admin will know to check for that field, and it will get the presentation attributes that you defined in the @AdminPresentationOverrides on the OrderImpl entity.
To give a small recap, you will create a new DataSourceFactory that looks like this:
Code: Select all
public class PBOrderListDataSourceFactory implements DataSourceFactory {
public static ListGridDataSource dataSource = null;
public void createDataSource(String name, OperationTypes operationTypes, Object[] additionalItems, AsyncCallback<DataSource> cb) {
if (dataSource == null) {
operationTypes = new OperationTypes(OperationType.ENTITY, OperationType.ENTITY, OperationType.ENTITY, OperationType.ENTITY, OperationType.ENTITY);
PersistencePerspective persistencePerspective = new PersistencePerspective(operationTypes, new String[]{"getTotalFees"}, new ForeignKey[]{});
DataSourceModule[] modules = new DataSourceModule[]{
new BasicClientEntityModule(CeilingEntities.ORDER, persistencePerspective, AppServices.DYNAMIC_ENTITY)
};
dataSource = new ListGridDataSource(name, persistencePerspective, AppServices.DYNAMIC_ENTITY, modules);
dataSource.buildFields(null, false, cb);
} else {
if (cb != null) {
cb.onSuccess(dataSource);
}
}
}
Now, you have to associate this dataSourceFactory in an overridden OrderPresenter. Your overridden setup() method should look like this:
Code: Select all
public void setup() {
super.setup();
getPresenterSequenceSetupManager().addOrReplaceItem(new PresenterSetupItem("orderDS", new PBOrderListDataSourceFactory(), new AsyncCallbackAdapter() {
public void onSetupSuccess(DataSource top) {
setupDisplayItems(top);
((ListGridDataSource) top).setupGridFields(new String[]{"customer.firstName", "customer.lastName", "name", "orderNumber", "status", "submitDate"});
getDisplay().getListDisplay().getGrid().sort("submitDate", SortDirection.DESCENDING);
}
}));
}
Notice that the second line of that method instantiates a new
PBOrderListDataSOurceFactory.
Once you go through that, you should have what you want.