1 29 30 package nextapp.echo2.webrender.servermessage; 31 32 import nextapp.echo2.webrender.ServerDelayMessage; 33 import nextapp.echo2.webrender.ServerMessage; 34 import nextapp.echo2.webrender.output.HtmlDocument; 35 36 import org.w3c.dom.Document ; 37 import org.w3c.dom.Element ; 38 39 44 public class ServerDelayMessageUpdate { 45 46 51 public static void renderUpdateDirective(ServerMessage serverMessage, ServerDelayMessage serverDelayMessage) { 52 Document document = serverMessage.getDocument(); 53 Element setMessageElement = serverMessage.appendPartDirective(ServerMessage.GROUP_ID_INIT, 54 "EchoServerDelayMessage.MessageProcessor", "set-message"); 55 if (serverDelayMessage == null) { 56 return; 57 } 58 59 Element contentContainerElement = serverMessage.getDocument().createElement("content"); 60 setMessageElement.appendChild(contentContainerElement); 61 62 Element messageElement = (Element ) document.importNode(serverDelayMessage.getMessage(), true); 63 messageElement.setAttribute("xmlns", HtmlDocument.XHTML_1_0_NAMESPACE_URI); 64 65 if (!ServerDelayMessage.ELEMENT_ID_MESSAGE.equals(messageElement.getAttribute("id"))) { 66 throw new IllegalStateException ("Invalid ServerDelayMessage: incorrect root element id: " 67 + messageElement.getAttribute("id")); 68 } 69 70 contentContainerElement.appendChild(messageElement); 71 } 72 } 73 | Popular Tags |