com.ui4j.spi.NativeEventManager Maven / Gradle / Ivy
The newest version!
package com.ui4j.spi;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.ui4j.api.dom.EventTarget;
import com.ui4j.api.event.EventHandler;
@SuppressWarnings("unchecked")
public class NativeEventManager implements EventManager {
private PageContext context;
public NativeEventManager(PageContext context) {
this.context = context;
}
@Override
public void bind(EventTarget target, String event, EventHandler handler) {
context.getEventRegistrar().register(target, event, handler);
Map map = new HashMap<>();
map.put("event", event);
map.put("listener", handler);
Object events = target.getProperty("events");
if (events == null || "undefined".equals(events.toString().trim())) {
target.setProperty("events", new ArrayList<>(1));
}
List