Exemple #1
0
  public String updateTask() {
    try {
      // fetch task and update before sending to database
      Task t = taskEJB.getTask(taskBean.getTaskId());
      t.setAssignedTo(accountEJB.getUser(taskBean.getAssignedUser()));
      t.setOwner(accountEJB.getUser(taskBean.getOwner()));
      t.setCompleted(taskBean.isCompleted());
      t.setDueDate(taskBean.getDueDate());
      t.setNote(taskBean.getNote());
      t.setTitle(taskBean.getTitle());
      t.setPriority(taskBean.getPriority());
      taskEJB.update(t);
      FacesMessage message = new FacesMessage();
      message.setSummary("Task is updated");
      message.setSeverity(FacesMessage.SEVERITY_INFO);
      FacesContext ctxt = FacesContext.getCurrentInstance();
      ctxt.addMessage(null, message);
    } catch (Exception ex) {
      Logger.getLogger(TaskController.class.getSimpleName()).log(Level.SEVERE, ex.getMessage());
    }

    return "tasks";
  }
Exemple #2
0
  public String createTask() {

    try {
      Task task = new Task();
      task.setTitle(taskBean.getTitle());
      task.setNote(taskBean.getNote());
      task.setCompleted(taskBean.isCompleted());
      task.setDueDate(taskBean.getDueDate());
      task.setCreateDate(new Date());
      task.setOwner(login.getUser());
      task.setAssignedTo(accountEJB.getUser(taskBean.getAssignedUser()));
      task.setPriority(taskBean.getPriority());

      taskEJB.createTask(task);
      JsfUtil.addSuccessMessage("Task created");
      return prepareCreate();
    } catch (Exception ex) {
      JsfUtil.addErrorMessage(ex.getMessage());
      return null;
    }
  }