|
package com.cp.adrabi.jln.web.todo.components;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Button;
import org.zkoss.zul.Div;
import org.zkoss.zul.Label;
import org.zkoss.zul.Row;
import org.zkoss.zul.RowRenderer;
import com.cp.adrabi.jln.model.Todo;
/**
* Row model for Todo list
*
* @author ADRABI Abderrahim (z3vil)
*
*/
public class TodoRowModel implements RowRenderer
{
@Override
public void render(Row row, final Object obj) throws Exception
{
Todo todo = (Todo) obj;
row.appendChild(new Label(todo.getId().toString()));
row.appendChild(new Label(todo.getSummary()));
Button btnUpdate = new Button("Update");
btnUpdate.setAttribute("id", todo.getId());
btnUpdate.addEventListener(Events.ON_CLICK, new EventListener()
{
@Override
public void onEvent(Event event) throws Exception
{
Object id = event.getTarget().getAttribute("id");
Executions.sendRedirect("/admin/todo/update/id/" + id );
}
});
Button btnRemove = new Button("Remove");
btnRemove.setAttribute("id", todo.getId());
btnRemove.addEventListener(Events.ON_CLICK, new EventListener()
{
@Override
public void onEvent(Event event) throws Exception
{
Object id = event.getTarget().getAttribute("id");
Executions.sendRedirect("/admin/todo/remove/id/" + id );
}
});
Div div = new Div();
div.appendChild(btnUpdate);
div.appendChild(btnRemove);
row.appendChild(div);
}
}
|
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.