class DefineProductCategoryPreviewController {

    @RequestMapping(method = RequestMethod.POST)
    public ModelAndView processFormSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String cancel,
            @RequestParam(value = EDIT_PARAM, required = false) String edit,
            @ModelAttribute("formBean") ProductCategoryFormBean bean,
            BindingResult result) {
        ModelAndView modelAndView = new ModelAndView("defineNewCategory");
        if (StringUtils.isNotBlank(cancel)) {
            modelAndView.setViewName(REDIRECT_TO_ADMIN);
        } else if (StringUtils.isNotBlank(edit)) {
            modelAndView.setViewName("defineNewCategory");
            modelAndView.addObject("formBean", bean);
            modelAndView.addObject("typeList", this.getProductCategoryTypes());
        } else if (result.hasErrors()) {
            modelAndView.setViewName("newProductCategoryPreview");
            modelAndView.addObject("formBean", bean);
        } else {
            CreateOrUpdateProductCategory productCategory = new CreateOrUpdateProductCategory(Short.parseShort(bean.getProductTypeId()), bean.getProductCategoryName(),
                    bean.getProductCategoryDesc(), Short.parseShort(bean.getProductCategoryStatusId()), bean.getGlobalPrdCategoryNum());

            try {
                this.adminServiceFacade.createProductCategory(productCategory);
                modelAndView.setViewName(REDIRECT_TO_ADMIN);
            } catch (BusinessRuleException e) {
                ObjectError error = new ObjectError("formBean", new String[] { e.getMessageKey() }, new Object[] {}, "default: ");
                result.addError(error);
                modelAndView.setViewName("newProductCategoryPreview");
                modelAndView.addObject("formBean", bean);
            }
        }
        return modelAndView;
    }

    public  DefineProductCategoryPreviewController(final AdminServiceFacade adminServiceFacade);
    protected  DefineProductCategoryPreviewController();

}