Page 1 of 1

Problem with section and new Admin

Posted: Mon Feb 04, 2013 10:57 am
by denis
Hi,

I updated BLC to 2.2.1-SNAPSHOT, everything is OK i can see my customs sections etc... BUT when i click on a custom section i'm redirected to the first section of the module. For instance, i have a section PromotionCode in the module Merchandising when i click on my PromotionCode the URL is :

Code: Select all

http://localhost:8081/admin/promotion-code#moduleKey=BLCMerchandising&pageKey=PromotionCode


and im redirected to :

Code: Select all

http://localhost:8081/admin/promotion-code#moduleKey=BLCMerchandising&pageKey=Category


In BLCMain.java on method setCurrentPageKey, pagesMap doesn't contain my page PromotionCode :

Code: Select all

 Map<String,String[]> pagesMap = modules.get(currentModuleKey).getPages();


Everything worked fine on BLC 2.1.3-SNAPSHOT, is something has changed to register a new section with BLC 2.2.0 ??? On MyMerchandisingModule i have :

Code: Select all

public class MyMerchandisingModule extends MerchandisingModule {

public void onModuleLoad() {
      super.onModuleLoad();

       List<String> promotionCodePermissions = new ArrayList<String>();
       promotionCodePermissions.add("PERMISSION_CREATE_PROMOTION_CODE");
       promotionCodePermissions.add("PERMISSION_UPDATE_PROMOTION_CODE");
       promotionCodePermissions.add("PERMISSION_DELETE_PROMOTION_CODE");
       promotionCodePermissions.add("PERMISSION_READ_PROMOTION_CODE");
       setSection(
            BLCMain.getMessageManager().getString("merchandisingPromotionCodeMainTitle"),
          "promotionCode",
          "my.company.admin.client.view.promotion.code.PromotionCodeView",
          "promotionCodePresenter",
          "my.company.admin.client.presenter.promotion.code.PromotionCodePresenter",
          promotionCodePermissions
       );
   }
}


I added the mapping between Sections and Permissions, evertything should be ok. I'm stuck, have you any idea ?

PS: The only way to make it works it's to remove the super.onModuleLoad() and copy/paste all the code of the super class :shock:

Thanks

Re: Problem with section and new Admin

Posted: Tue Feb 05, 2013 11:12 am
by phillipuniverse
Try calling registerModule() at the bottom of your extended module. I believe this is a relatively recent change and might not have made it into 2.1 (as in, new for 2.2).

Re: Problem with section and new Admin

Posted: Tue Feb 05, 2013 11:12 am
by phillipuniverse
by "at the bottom of your extended module" I mean, call that as the very last thing in your 'onModuleLoad()' method.

Re: Problem with section and new Admin

Posted: Tue Feb 05, 2013 11:47 am
by denis
Hi Phillip,

First of all thanks for your answer.

I tried your solution but it doesn't work, there is an exception on the method BLCMain.addModule :

Code: Select all

java.lang.NullPointerException: null
    at org.broadleafcommerce.openadmin.client.AbstractModule.removeSection(AbstractModule.java:108)
    at org.broadleafcommerce.openadmin.client.BLCMain.addModule(BLCMain.java:100)
    at org.broadleafcommerce.openadmin.client.AbstractModule.registerModule(AbstractModule.java:43)
    at my.company.admin.client.MyCustomerCareModule.onModuleLoad(MyCustomerCareModule.java:155)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396)
    at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
    at java.lang.Thread.run(Thread.java:722)


The error is thrown on line (ModuleFactory.getInstance().remove(items[0])) :

Code: Select all

 public void removeSection(
        String sectionTitle
    ) {
        sectionTitle = sectionTitle.replaceAll("\\s", "");
        //items is null
        String[] items = pages.remove(sectionTitle);
        //HERE
        ModuleFactory.getInstance().remove(items[0]);
        ModuleFactory.getInstance().remove(items[1]);
    }

Re: Problem with section and new Admin

Posted: Fri Feb 08, 2013 7:55 am
by denis
Do you have any other idea to make it works?

Furthermore, there is an other problem with new admin and sections. On your demo site (on the admin) if you are logged in with the account "merchandise", even if this account has no permissions on a section, the section is still displayed. When you click on the section the admin is redirected to the first section of the module. If you have no permissions on a section, the section shouldn't be displayed like previous BLC version, no?

Image