Click here to Skip to main content
15,891,033 members
Articles / Programming Languages / Java / Java SE / J2EE

Modular J2EE, Using Spring DM, Zk and EclipseLink

Rate me:
Please Sign up or sign in to vote.
4.92/5 (9 votes)
21 Apr 2011CPOL15 min read 52.9K   401   8  
This article describes how to create a basic modular Java Enterprise Application, by using these Open Source frameworks
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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead
Morocco Morocco
Adrabi!, Just another Ghost in the Shell =)

Comments and Discussions