关于ofbiz的order模块测试问题

在ofbiz初学者指南中,有介绍使用其order功能(ecommerce),当以游客身份创建订单时,会出现问题。

原因是在
org.ofbiz.webapp.stats.ServerHitBin类得
protected static void countHit(String baseId, int type,
HttpServletRequest request, long startTime, long runningTime,
GenericValue userLogin, boolean isOriginal) {
}
方法中
String delegatorName = (String) request.getSession().getAttribute(
"delegatorName");
这一步会出现得到的delegatorName是null。

发现更深的原因是在org.ofbiz.order.shoppingcart.ShoppingCartEvents类得清理购物车时有这样的一段操作:
public static String clearCart(HttpServletRequest request, HttpServletResponse response) {
ShoppingCart cart = getCartObject(request);
cart.clear();

// if this was an anonymous checkout process, go ahead and clear the session and such now that the order is placed; we don't want this to mess up additional orders and such
HttpSession session = request.getSession();
GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");
if (userLogin != null && "anonymous".equals(userLogin.get("userLoginId"))) {
// here we want to do a full logout, but not using the normal logout stuff because it saves things in the UserLogin record that we don't want changed for the anonymous user
//问题在这里,当它发现是游客身份的时候,会将session清理掉,那么从session取出的delegatorName当然就是null了。
session.invalidate();
session = request.getSession(true);

// to allow the display of the order confirmation page put the userLogin in the request, but leave it out of the session
request.setAttribute("temporaryAnonymousUserLogin", userLogin);

Debug.logInfo("Doing clearCart for anonymous user, so logging out but put anonymous userLogin in temporaryAnonymousUserLogin request attribute", module);
}

return "success";
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值