Search in sources :

Example 1 with Team

use of com.demo.model.Team in project jSqlBox by drinkjava2.

the class TeamController method addTeamPage.

@RequestMapping(value = "/add", method = RequestMethod.GET)
public ModelAndView addTeamPage() {
    ModelAndView modelAndView = new ModelAndView("add-team-form");
    modelAndView.addObject("team", new Team());
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) Team(com.demo.model.Team) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with Team

use of com.demo.model.Team in project jSqlBox by drinkjava2.

the class TeamController method editTeamPage.

@RequestMapping(value = "/edit/{id}", method = RequestMethod.GET)
public ModelAndView editTeamPage(@PathVariable Integer id) {
    ModelAndView modelAndView = new ModelAndView("edit-team-form");
    Team team = teamService.getTeam(id);
    modelAndView.addObject("team", team);
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) Team(com.demo.model.Team) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with Team

use of com.demo.model.Team in project jSqlBox by drinkjava2.

the class TeamController method listOfTeams.

@RequestMapping(value = "/list")
public ModelAndView listOfTeams() {
    ModelAndView modelAndView = new ModelAndView("list-of-teams");
    List<Team> teams = teamService.getTeams();
    modelAndView.addObject("teams", teams);
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) Team(com.demo.model.Team) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with Team

use of com.demo.model.Team in project jSqlBox by drinkjava2.

the class Initializer method onStartup.

public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(WebAppConfig.class);
    servletContext.addListener(new ContextLoaderListener(ctx));
    ctx.setServletContext(servletContext);
    Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    servlet.addMapping("/");
    servlet.setLoadOnStartup(1);
    // force refresh
    ctx.refresh();
    // SqlBoxContext.setGlobalAllowShowSql(true);
    SqlBoxContext sqlCtx = ctx.getBean(SqlBoxContext.class);
    SqlBoxContext.setGlobalSqlBoxContext(sqlCtx);
    String[] ddls = sqlCtx.toDropAndCreateDDL(Team.class);
    for (String ddl : ddls) sqlCtx.quiteExecute(ddl);
    for (int i = 0; i < 5; i++) new Team().put("name", "Team" + i, "rating", i * 10).insert();
    System.out.println("========== com.jsqlboxdemo.init.Initializer initialized=====");
}
Also used : Dynamic(javax.servlet.ServletRegistration.Dynamic) DispatcherServlet(org.springframework.web.servlet.DispatcherServlet) ContextLoaderListener(org.springframework.web.context.ContextLoaderListener) SqlBoxContext(com.github.drinkjava2.jsqlbox.SqlBoxContext) Team(com.demo.model.Team) AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext)

Aggregations

Team (com.demo.model.Team)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 SqlBoxContext (com.github.drinkjava2.jsqlbox.SqlBoxContext)1 Dynamic (javax.servlet.ServletRegistration.Dynamic)1 ContextLoaderListener (org.springframework.web.context.ContextLoaderListener)1 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)1 DispatcherServlet (org.springframework.web.servlet.DispatcherServlet)1