SIMPLE ZK CODE TO HANDLE MULTIPLE BUTTONS ON (.zul) FILE

OUTPUT IMAGE
————————-







.JAVA CLASS FILE
———————–

package classes;

import org.zkoss.zk.ui.Component;

import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.util.Composer;
import org.zkoss.zul.Label;

public class MultipleEvents implements Composer, EventListener{
Component comp=null;
Label message;

@Override
public void doAfterCompose(Component comp) throws Exception {
this.comp=comp;
comp.getFellow(“FIRST”).addEventListener(“onClick”, this);
comp.getFellow(“SECOND”).addEventListener(“onClick”, this);
comp.getFellow(“THIRD”).addEventListener(“onClick”, this);
message=(Label) comp.getFellow(“message”);
}

@Override
public void onEvent(Event event) throws Exception {
if (event.getTarget().getId().equals(“FIRST”)){

message.setValue(“hi, good morning”);
}
if (event.getTarget().getId().equals(“SECOND”)){
message.setValue(“how are you.”);
}
if (event.getTarget().getId().equals(“THIRD”)){
message.setValue(“Have a happy happy day.”);
}

}

}

————————————————————————-
.ZUL FILE
—————


————————————————————
Advertisements

About rajkirpal

i am a software engineer. and i have decent knowledge about java technologies like ANDROID, Servlet, Jsp, Struts, Hibernet, Spring, J2ME, Java Script, Ajax, JQuery, CSS. Further i am Preparing Easy understandable materials/documents upon the same java technologies and developing project in core java , advanced java and j2me , ANDROID as per the requirements Also designing the web sites and logos Thank You.
This entry was posted in J2EE. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s