/* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ideyatech.ninja.web.controller; import com.ideyatech.ninja.bean.Ninja; import org.opentides.bean.SystemCodes; import org.opentides.service.TagService; import org.opentides.web.controller.BaseCrudController; import com.ideyatech.ninja.web.validator.NinjaValidator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.List; /** * This is the controller class for Ninja. * Scaffold generated by opentides3 on Feb 13, 2013 12:40:25. * * @author opentides */ @RequestMapping("/ninja") @Controller public class NinjaCrudController extends BaseCrudController<Ninja> { @Autowired private TagService tagService; @ModelAttribute("genderList") public List<SystemCodes> genderList() { List<SystemCodes> genderList = new ArrayList<SystemCodes>(); genderList.add(new SystemCodes("GENDER","MALE","Male")); genderList.add(new SystemCodes("GENDER","FEMALE","Female")); genderList.add(new SystemCodes("OTHER","OTHER","Other")); return genderList; } @Autowired public void setValidator(NinjaValidator ninjaValidator) { this.formValidator = ninjaValidator; } @ModelAttribute("statusList") public List<SystemCodes> statusList() { return systemCodesService.findSystemCodesByCategory("STATUS"); } @ModelAttribute("skillsList") public List<SystemCodes> skillsList() { return systemCodesService.findSystemCodesByCategory("SKILLS"); } @Override protected void onLoadSearch(Ninja command, BindingResult bindingResult, Model uiModel, HttpServletRequest request, HttpServletResponse response) { uiModel.addAttribute("results", search(command, request)); } @Override protected void preUpdate(Ninja command) { command.setTags(tagService.createTags(command.getCsTags().split(","))); } @Override protected void preCreate(Ninja command) { command.setTags(tagService.createTags(command.getCsTags().split(","))); } }