Methods Summary |
---|
protected java.lang.Object | formBackingObject(javax.servlet.http.HttpServletRequest request)
UserSession userSession = (UserSession) request.getSession().getAttribute("userSession");
Cart cart = (Cart) request.getSession().getAttribute("sessionCart");
if (cart != null) {
// Re-read account from DB at team's request.
Account account = this.petStore.getAccount(userSession.getAccount().getUsername());
OrderForm orderForm = new OrderForm();
orderForm.getOrder().initOrder(account, cart);
return orderForm;
}
else {
ModelAndView modelAndView = new ModelAndView("Error", "message", "An order could not be created because a cart could not be found.");
throw new ModelAndViewDefiningException(modelAndView);
}
|
protected int | getTargetPage(javax.servlet.http.HttpServletRequest request, java.lang.Object command, org.springframework.validation.Errors errors, int currentPage)
OrderForm orderForm = (OrderForm) command;
if (currentPage == 0 && orderForm.isShippingAddressRequired()) {
return 1;
}
else {
return 2;
}
|
protected boolean | isFormSubmission(javax.servlet.http.HttpServletRequest request)
return super.isFormSubmission(request) || request.getParameter(PARAM_FINISH) != null;
|
protected void | onBindAndValidate(javax.servlet.http.HttpServletRequest request, java.lang.Object command, org.springframework.validation.BindException errors, int page)
if (page == 0 && request.getParameter("shippingAddressRequired") == null) {
OrderForm orderForm = (OrderForm) command;
orderForm.setShippingAddressRequired(false);
}
|
protected org.springframework.web.servlet.ModelAndView | processCancel(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object command, org.springframework.validation.BindException errors)
throw new UnsupportedOperationException();
|
protected org.springframework.web.servlet.ModelAndView | processFinish(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object command, org.springframework.validation.BindException errors)
OrderForm orderForm = (OrderForm) command;
this.petStore.insertOrder(orderForm.getOrder());
request.getSession().removeAttribute("sessionCart");
Map model = new HashMap();
model.put("order", orderForm.getOrder());
model.put("message", "Thank you, your order has been submitted.");
return new ModelAndView("ViewOrder", model);
|
protected java.util.Map | referenceData(javax.servlet.http.HttpServletRequest request, int page)
if (page == 0) {
List creditCardTypes = new ArrayList();
creditCardTypes.add("Visa");
creditCardTypes.add("MasterCard");
creditCardTypes.add("American Express");
Map model = new HashMap();
model.put("creditCardTypes", creditCardTypes);
return model;
}
return null;
|
public void | setPetStore(org.springframework.samples.jpetstore.domain.logic.PetStoreFacade petStore)
this.petStore = petStore;
|
protected void | validatePage(java.lang.Object command, org.springframework.validation.Errors errors, int page)
OrderForm orderForm = (OrderForm) command;
OrderValidator orderValidator = (OrderValidator) getValidator();
errors.setNestedPath("order");
switch (page) {
case 0:
orderValidator.validateCreditCard(orderForm.getOrder(), errors);
orderValidator.validateBillingAddress(orderForm.getOrder(), errors);
break;
case 1:
orderValidator.validateShippingAddress(orderForm.getOrder(), errors);
}
errors.setNestedPath("");
|