@RequestMapping(value = "/jobs/{jobName}", method = RequestMethod.GET)
  public String details(
      ModelMap model,
      @ModelAttribute("jobName") String jobName,
      Errors errors,
      @RequestParam(defaultValue = "0") int startJobInstance,
      @RequestParam(defaultValue = "20") int pageSize) {

    boolean launchable = jobService.isLaunchable(jobName);

    try {

      Collection<JobInstance> result =
          jobService.listJobInstances(jobName, startJobInstance, pageSize);
      Collection<JobInstanceInfo> jobInstances = new ArrayList<JobInstanceInfo>();
      model.addAttribute(
          "jobParameters",
          jobParametersExtractor.fromJobParameters(jobService.getLastJobParameters(jobName)));

      for (JobInstance jobInstance : result) {
        Collection<JobExecution> jobExecutions =
            jobService.getJobExecutionsForJobInstance(jobName, jobInstance.getId());
        jobInstances.add(new JobInstanceInfo(jobInstance, jobExecutions, timeZone));
      }

      model.addAttribute("jobInstances", jobInstances);
      int total = jobService.countJobInstances(jobName);
      TableUtils.addPagination(model, total, startJobInstance, pageSize, "JobInstance");
      int count = jobService.countJobExecutionsForJob(jobName);
      model.addAttribute(
          "jobInfo", new JobInfo(jobName, count, launchable, jobService.isIncrementable(jobName)));

    } catch (NoSuchJobException e) {
      errors.reject(
          "no.such.job",
          new Object[] {jobName},
          "There is no such job (" + HtmlUtils.htmlEscape(jobName) + ")");
    }

    return "jobs/job";
  }
 @RequestMapping(value = "/jobs", method = RequestMethod.GET)
 public void jobs(
     ModelMap model,
     @RequestParam(defaultValue = "0") int startJob,
     @RequestParam(defaultValue = "20") int pageSize) {
   int total = jobService.countJobs();
   TableUtils.addPagination(model, total, startJob, pageSize, "Job");
   Collection<String> names = jobService.listJobs(startJob, pageSize);
   List<JobInfo> jobs = new ArrayList<JobInfo>();
   for (String name : names) {
     int count = 0;
     try {
       count = jobService.countJobExecutionsForJob(name);
     } catch (NoSuchJobException e) {
       // shouldn't happen
     }
     boolean launchable = jobService.isLaunchable(name);
     boolean incrementable = jobService.isIncrementable(name);
     jobs.add(new JobInfo(name, count, null, launchable, incrementable));
   }
   model.addAttribute("jobs", jobs);
 }