Firing Custom Events

Hi All,

Am creating a panel with a table and a few buttons. The tbale will initially be in non-editable mode. And on the button click am supposed to set the table in editable mode. Am trying to achieve this through custom events.

public class HoursOfOperationTable extends Table {

public void addListener(HoursOfOperationEventListener listener) {
try {
Method method = HoursOfOperationEventListener.class.getDeclaredMethod(
“hoursSavedEvent”, new Class { HoursOfOperationEvent.class });
addListener(HoursOfOperationEvent.class, listener, method);
} catch (final java.lang.NoSuchMethodException e) {
throw new java.lang.RuntimeException(
“Internal error, editor saved method not found”);

public void removeListener(HoursOfOperationEventListener listener) {
    removeListener(HoursOfOperationEvent.class, listener);


And below are the custom event and listener interface -

public class HoursOfOperationEvent extends Component.Event {

private String eventName;

public HoursOfOperationEvent(Component source, String eventName) {
    this.eventName = eventName;

public String getEvent() {
    return this.eventName;


public interface HoursOfOperationEventListener extends Serializable {
public void hoursSavedEvent(HoursOfOperationEvent event);

Here is the button click listener -

editButton.addClickListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
fireEvent(new HoursOfOperationEvent(hoursTable, “edit”));


In the panel constructor, am trying construct the table and attach the listener -

hoursTable.addListener(new HoursOfOperationEventListener() {
public void hoursSavedEvent(HoursOfOperationEvent event) {
String action = event.getEvent();
if(“Edit”.equalsIgnoreCase(action)) {
} else if(“Save”.equalsIgnoreCase(action)) {
HoursOfOpPersistResults persistResult = propagateUpdates();
if(HoursOfOpPersistResults.SUCCESS.equals(persistResult.getStatusCode()))“Notification”, “HOPUpdated”), Notification.TYPE_TRAY_NOTIFICATION);
else if(HoursOfOpPersistResults.NOUPDATES.equals(persistResult.getStatusCode()))“Notification”, “HOPUpdateNotRequried”), Notification.TYPE_TRAY_NOTIFICATION);
else if(HoursOfOpPersistResults.PERSISTFAILURE.equals(persistResult.getStatusCode()))“Notification”, “HOPUpdateFailed”), Notification.TYPE_ERROR_MESSAGE);
} else if (“Discard”.equalsIgnoreCase(action)) {

Having all done this, I still don’t see the hoursSavedEvent method getting invoked after the editButton click. And also the table is not moving to editable mode.

Please help. This is much urgent.