Page 1 of 1

Admin Tutorial Error

Posted: Thu Jan 31, 2013 1:57 pm
by filipeares
Hello,
I've doing the Broadleaf commerce tutorials and everything went right until the Showing Calculated Fields on Entities tutorial. After running the tutorial I always get the same error when accessing to page 'Customer Care -> Order':

Cannot read property 'org_broadleafcommerce_openadmin_client_presenter_entity_DynamicFormPresenter_display' of null

Can someone point me the right way to solve this?

Thanks

Re: Admin Tutorial Error

Posted: Fri Feb 01, 2013 10:30 am
by phillipuniverse
What version of Broadleaf are you on? Also, can you post your code that you are using? That's a pretty general error so I can't really respond without more information.

You might also try enabling the remote logging (see the myCompanyAdmin.gwt.xml file for more info on this) which might give you more information.

Re: Admin Tutorial Error

Posted: Mon Feb 04, 2013 7:43 am
by filipeares
Hello,

Sorry the lack of info.
I'm using the 2.0.2-GA version of Broadleaf commerce.

The code that produces the error is the one on the Admin tutorials section:

Code: Select all

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "MY_COMPANY_ORDER")
@AdminPresentationOverride(name="getFulfillmentFees", value=@AdminPresentation(friendlyName="Fulfillment Fees", fieldType= SupportedFieldType.MONEY))
public class MyCompanyOrderImpl extends OrderImpl implements MyCompanyOrder {


    @Override
    public Money getFulfillmentFees() {
        Money result = new Money(BigDecimal.ZERO);
        for (FulfillmentGroup group : getFulfillmentGroups()) {
            for (FulfillmentGroupFee fee : group.getFulfillmentGroupFees()) {
                result = result.add(fee.getAmount());
            }
        }
        return result;
    }
}

public class MyCompanyOrderPresenter extends OrderPresenter {

    @Override
    public void setup() {
        getPresenterSequenceSetupManager().addOrReplaceItem(new PresenterSetupItem("orderDS", new MyCompanyOrderListDataSourceFactory(), new AsyncCallbackAdapter() {
            @Override
            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);
            }
        }));
    }
}


public class MyCompanyOrderPresenter extends OrderPresenter {

    @Override
    public void setup() {
          getPresenterSequenceSetupManager().addOrReplaceItem(new PresenterSetupItem("orderDS",
                new MyCompanyOrderListDataSourceFactory()
                , new AsyncCallbackAdapter() {
            @Override
            public void onSetupSuccess(DataSource top) {
                setupDisplayItems(top);
                ((ListGridDataSource) top).setupGridFields(new String[]{"customer.firstName", "customer.lastName",
                        "name", "orderNumber", "status", "submitDate", "getFulfillmentFees"});
                getDisplay().getListDisplay().getGrid().sort("submitDate", SortDirection.DESCENDING);
            }
        }));
    }
}

public class MyCompanyOrderListDataSourceFactory implements DataSourceFactory {

    public static ListGridDataSource dataSource = null;

    public void createDataSource(String name, OperationTypes operationTypes, Object[] additionalItems, AsyncCallback<DataSource> cb) {
        System.out.println("createDataSource()" + name);
        if (dataSource == null) {
//           operationTypes = new OperationTypes(OperationType.ENTITY, OperationType.ENTITY, OperationType.ENTITY, OperationType.ENTITY, OperationType.ENTITY);
            operationTypes = new OperationTypes();
            //Add our custom getFulfillmentFees non-persistent property to the persistence perspective
            PersistencePerspective persistencePerspective = new PersistencePerspective(operationTypes,
                    new String[]{"getFulfillmentFees"},
                    new ForeignKey[]{new ForeignKey("getFulfillmentFees", EntityImplementations.ORDER, "orderDS")});
            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);
            }
        }
    }
}


In this last class I have experienced other situation, when I import the OperationType enum in package org.broadleafcommerce.common.presentation.client, I have an error
that OperationType.ENTITY doesn't exist. Only exists NONDESTRUCTIVEREMOVE, BASIC, ADORNEDTARGETLIST, MAP. Am I doing something else wrong?

I hope this info can help.

Thank you very much!

Re: Admin Tutorial Error

Posted: Fri Feb 08, 2013 7:07 am
by filipeares
Hello,
I found more info about the error. It's a NullPointerException in the parent class OrderPresenter at bind() method of orderItemPresenter. It´s the last line in the snippet that I post below

Code: Select all

@Override
   public void bind() {
      super.bind();
      
      orderItemPresenter.bind();


Am I missing a step for the instantiation of orderItemPresenter ?

Thanks!

Re: Admin Tutorial Error

Posted: Fri Feb 08, 2013 10:28 am
by phillipuniverse
If you are using 2.0, you will need to use OperationTypes.BASIC (analogous to the older OperationTypes.ENTITY). Looks like that tutorial has not been updated since we changed those enums.

In your subclass, MyCompanyOrderPresenter you never call super.setup(). This is where the orderItemPresenter should be getting instantiated (in the root BLC class).

Re: Admin Tutorial Error

Posted: Fri Feb 08, 2013 1:24 pm
by filipeares
That solved the NullPointerException :)

Thanks for your help! :D