|
package com.cp.adrabi.jln.web.todo.controllers;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zul.Label;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Textbox;
import com.cp.adrabi.jln.model.Todo;
/**
* Controller for updating Todo
*
* @author ADRABI Abderrahim (z3vil)
*
*/
public class ControllerUpdateTodo extends ControllerBaseTodo
{
/**
*
*/
private static final long serialVersionUID = 1L;
private Label lblId;
private Textbox txtSummary;
private Textbox txtDescription;
private Long id;
@Override
public void doAfterCompose(Component comp) throws Exception
{
super.doAfterCompose(comp);
this.loadTodoInfo();
}
public void onClick$btnUpdate() throws InterruptedException
{
this.validateValue(txtSummary, Todo.class, "summary", this.txtSummary.getText());
this.validateValue(this.txtDescription, Todo.class, "description", this.txtDescription.getText());
this.fireValidation();
Todo todo = this.service.getTodoById(this.id);
todo.setSummary(this.txtSummary.getText());
todo.setDescription(this.txtDescription.getText());
this.service.updateTodo(todo);
Messagebox.show("Todo updated successfully");
this.onClick$btnBack(); // :D
}
public void onClick$btnBack()
{
Executions.sendRedirect("/admin/todo/list");
}
private void loadTodoInfo()
{
this.id = Long.valueOf( this.execution.getParameter("id") );
Todo todo = this.service.getTodoById(this.id);
this.lblId.setValue(todo.getId().toString());
this.txtSummary.setText(todo.getSummary());
this.txtDescription.setText(todo.getDescription());
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.