Page 1 of 1

currentCustomer returns null

Posted: Mon Mar 04, 2013 1:01 pm
by pam
Hi,

Working on eCommerce project based on broadleaf-framework-1.0.0. I have to process an order, but the currentCustomer is returning null,

Class file - CartExtController.java
protected Order retrieveCartOrder(HttpServletRequest request, ModelMap model) {
Customer currentCustomer = customerState.getCustomer(request); // returns null
Order currentCartOrder = null;
if (currentCustomer != null) {
currentCartOrder = cartService.findCartForCustomer(currentCustomer);
if (currentCartOrder == null) {
currentCartOrder = cartService.createNewCartForCustomer(currentCustomer);
}
}

model.addAttribute("currentCartOrder", currentCartOrder);
return currentCartOrder;
}

Look forward for your responses

Re: currentCustomer returns null

Posted: Tue Mar 05, 2013 5:01 pm
by phillipuniverse
Did you mean broadleaf 2.0.0? The customer should be set on the request via the CustomerStateFilter which is hooked up via Spring Security. This should be referenced in applicationContext-security.xml like this:

Code: Select all

 <sec:custom-filter ref="blCustomerStateFilter" after="REMEMBER_ME_FILTER"/>


Set a breakpoint in the CustomerStateFilter; does this actually get hit?

Re: currentCustomer returns null

Posted: Tue Mar 05, 2013 5:47 pm
by pam
Thank you for the reply.

Yeah the settings was commented out in applicationContext-security.xml file.

I could overcome this issue by uncommenting it.