1 29 30 package nextapp.echo2.webrender.servermessage; 31 32 import nextapp.echo2.webrender.ServerMessage; 33 34 import org.w3c.dom.Element ; 35 36 41 public class EventProcessor { 42 43 private static final String MESSAGE_PART_NAME = "EchoEventProcessor.MessageProcessor"; 44 private static final String [] EVENT_ADD_KEYS = new String []{"type", "handler"}; 45 private static final String [] EVENT_REMOVE_KEYS = new String []{"type"}; 46 47 59 public static void renderEventAdd(ServerMessage serverMessage, String eventType, 60 String elementId, String eventHandler) { 61 Element itemizedUpdateElement = serverMessage.getItemizedDirective(ServerMessage.GROUP_ID_POSTUPDATE, 62 MESSAGE_PART_NAME, "event-add", EVENT_ADD_KEYS, new String []{eventType, eventHandler}); 63 Element itemElement = serverMessage.getDocument().createElement("item"); 64 itemElement.setAttribute("eid", elementId); 65 itemizedUpdateElement.appendChild(itemElement); 66 } 67 68 78 public static void renderEventRemove(ServerMessage serverMessage, String eventType, 79 String elementId) { 80 Element itemizedUpdateElement = serverMessage.getItemizedDirective(ServerMessage.GROUP_ID_PREREMOVE, 81 MESSAGE_PART_NAME, "event-remove", EVENT_REMOVE_KEYS, new String []{eventType}); 82 Element itemElement = serverMessage.getDocument().createElement("item"); 83 itemElement.setAttribute("eid", elementId); 84 itemizedUpdateElement.appendChild(itemElement); 85 } 86 } 87 | Popular Tags |