Package nextapp.echo2.webrender

Examples of nextapp.echo2.webrender.ServerMessage


    throws IOException {
        UserInstance userInstance = conn.getUserInstance();
        synchronized(userInstance) {
            Document clientMessageDocument = parseRequestDocument(conn);
            String messageType = clientMessageDocument.getDocumentElement().getAttribute("type");
            ServerMessage serverMessage;
           
            if ("initialize".equals(messageType)) {
                serverMessage = renderInit(conn, clientMessageDocument);
                ClientPropertiesStore.renderStoreDirective(serverMessage, userInstance.getClientProperties());
                ClientConfigurationUpdate.renderUpdateDirective(serverMessage, userInstance.getClientConfiguration());
                ServerDelayMessageUpdate.renderUpdateDirective(serverMessage, userInstance.getServerDelayMessage());
               
                // Add "test attribute" used by ClientEngine to determine if browser is correctly (un)escaping
                // attribute values.  Safari does not do this correctly and a workaround is thus employed if such
                // bugs are detected.
                serverMessage.getDocument().getDocumentElement().setAttribute("xml-attr-test", "x&y");
            } else {
                serverMessage = renderUpdate(conn, clientMessageDocument);
                processUserInstanceUpdates(userInstance, serverMessage);
            }
            serverMessage.setTransactionId(userInstance.getNextTransactionId());
            conn.setContentType(ContentType.TEXT_XML);
            serverMessage.render(conn.getWriter());
        }
    }
View Full Code Here


    /**
     * Test <code>addLibrary()</code>.
     */
    public void testAddLibrary() {
        NodeList libraryNodeList;
        ServerMessage message = new ServerMessage();
       
        message.addLibrary("service1");
        libraryNodeList = message.getDocument().getElementsByTagName("library");
        assertEquals(1, libraryNodeList.getLength());
       
        message.addLibrary("service2");
        libraryNodeList = message.getDocument().getElementsByTagName("library");
        assertEquals(2, libraryNodeList.getLength());
       
        message.addLibrary("service1");
        libraryNodeList = message.getDocument().getElementsByTagName("library");
        assertEquals(2, libraryNodeList.getLength());
    }
View Full Code Here

   
    /**
     * Test <code>appendPartDirective()</code>.
     */
    public void testAppendPartDirective() {
        ServerMessage message = new ServerMessage();
        message.appendPartDirective(ServerMessage.GROUP_ID_UPDATE, "DomUpdate", "dom-add");
        message.appendPartDirective(ServerMessage.GROUP_ID_UPDATE, "DomUpdate", "dom-remove");
        message.appendPartDirective(ServerMessage.GROUP_ID_UPDATE, "DomUpdate", "dom-add");
        message.appendPartDirective(ServerMessage.GROUP_ID_UPDATE, "SomethingElse", "thing");
        message.appendPartDirective(ServerMessage.GROUP_ID_UPDATE, "DomUpdate", "dom-remove");
        message.appendPartDirective(ServerMessage.GROUP_ID_UPDATE, "DomUpdate", "dom-add");
        assertEquals(3, message.getDocument().getElementsByTagName("message-part").getLength());
    }
View Full Code Here

    /**
     * Test itemized directive capability.
     */
    public void testItemizedDirective() {
        ServerMessage message = new ServerMessage();
        String[] keyAttributeNames = new String[]{"alpha", "bravo"};
       
        Element directiveElement1 = message.getItemizedDirective(ServerMessage.GROUP_ID_POSTUPDATE, "Processor", "Directive",
                keyAttributeNames, new String[]{"alpha1", "bravo1"});
        assertEquals("Directive", directiveElement1.getNodeName());
        assertEquals("alpha1", directiveElement1.getAttribute("alpha"));
        assertEquals("bravo1", directiveElement1.getAttribute("bravo"));
       
        Element directiveElement2 = message.getItemizedDirective(ServerMessage.GROUP_ID_POSTUPDATE, "Processor", "Directive",
                keyAttributeNames, new String[]{"alpha1", "bravo1"});
        assertEquals("Directive", directiveElement2.getNodeName());
        assertEquals("alpha1", directiveElement2.getAttribute("alpha"));
        assertEquals("bravo1", directiveElement2.getAttribute("bravo"));
       
        assertTrue(directiveElement1.equals(directiveElement2));

        Element directiveElement3 = message.getItemizedDirective(ServerMessage.GROUP_ID_POSTUPDATE, "Processor", "Directive",
                keyAttributeNames, new String[]{"alpha2", "bravo2"});
        assertEquals("Directive", directiveElement3.getNodeName());
        assertEquals("alpha2", directiveElement3.getAttribute("alpha"));
        assertEquals("bravo2", directiveElement3.getAttribute("bravo"));
       
View Full Code Here

   
    /**
     * Test group identifiers.
     */
    public void testGroupIds() {
        ServerMessage message = new ServerMessage();
        Element directiveElement, messagePartGroupElement;

        directiveElement = message.appendPartDirective(ServerMessage.GROUP_ID_UPDATE, "Something", "do-something");
        messagePartGroupElement = (Element) directiveElement.getParentNode().getParentNode();
        assertEquals("message-part-group", messagePartGroupElement.getNodeName());
        assertEquals(ServerMessage.GROUP_ID_UPDATE, messagePartGroupElement.getAttribute("id"));
       
        directiveElement = message.appendPartDirective(ServerMessage.GROUP_ID_POSTUPDATE, "Something", "do-something");
        messagePartGroupElement = (Element) directiveElement.getParentNode().getParentNode();
        assertEquals("message-part-group", messagePartGroupElement.getNodeName());
        assertEquals(ServerMessage.GROUP_ID_POSTUPDATE, messagePartGroupElement.getAttribute("id"));
    }
View Full Code Here

     * @param rc the relevant <code>RenderContext</code>
     * @param textComponent the <code>TextComponent<code>
     */
    public void renderDisposeDirective(RenderContext rc, TextComponent textComponent) {
        String elementId = ContainerInstance.getElementId(textComponent);
        ServerMessage serverMessage = rc.getServerMessage();
        Element itemizedUpdateElement = serverMessage.getItemizedDirective(ServerMessage.GROUP_ID_PREREMOVE,
                "EchoTextComponent.MessageProcessor", "dispose", new String[0], new String[0]);
        Element itemElement = serverMessage.getDocument().createElement("item");
        itemElement.setAttribute("eid", elementId);
        itemizedUpdateElement.appendChild(itemElement);
    }
View Full Code Here

     */
    public void renderInitDirective(RenderContext rc, TextComponent textComponent) {
        Extent horizontalScroll = (Extent) textComponent.getRenderProperty(TextComponent.PROPERTY_HORIZONTAL_SCROLL);
        Extent verticalScroll = (Extent) textComponent.getRenderProperty(TextComponent.PROPERTY_VERTICAL_SCROLL);
        String elementId = ContainerInstance.getElementId(textComponent);
        ServerMessage serverMessage = rc.getServerMessage();

        Element itemizedUpdateElement = serverMessage.getItemizedDirective(ServerMessage.GROUP_ID_POSTUPDATE,
                "EchoTextComponent.MessageProcessor", "init", new String[0], new String[0]);
        Element itemElement = serverMessage.getDocument().createElement("item");
        itemElement.setAttribute("eid", elementId);
        if (horizontalScroll != null && horizontalScroll.getValue() != 0) {
            itemElement.setAttribute("horizontal-scroll", ExtentRender.renderCssAttributePixelValue(horizontalScroll, "0"));
        }
        if (verticalScroll != null && verticalScroll.getValue() != 0) {
View Full Code Here

         *      nextapp.echo2.webcontainer.RenderContext, nextapp.echo2.app.update.ServerComponentUpdate)
         */
        public void renderProperty(RenderContext rc, ServerComponentUpdate update) {
            TextComponent textComponent = (TextComponent) update.getParent();
            String elementId = ContainerInstance.getElementId(textComponent);
            ServerMessage serverMessage = rc.getServerMessage();
            Element itemizedUpdateElement = serverMessage.getItemizedDirective(ServerMessage.GROUP_ID_POSTUPDATE,
                    "EchoTextComponent.MessageProcessor", "set-text", new String[0], new String[0]);
            Element itemElement = serverMessage.getDocument().createElement("item");
            itemElement.setAttribute("eid", elementId);
            itemElement.setAttribute("text", textComponent.getText());
            itemizedUpdateElement.appendChild(itemElement);
           
        }
View Full Code Here

     *
     * @param rc the relevant <code>RenderContext</code>
     * @param command the command
     */
    private void renderOpenWindow(RenderContext rc, BrowserOpenWindowCommand command) {
        ServerMessage serverMessage = rc.getServerMessage();
        serverMessage.addLibrary(BROWSER_COMMAND_SERVICE.getId());
        Element openWindowElement = serverMessage.appendPartDirective(ServerMessage.GROUP_ID_POSTUPDATE,
                "EchoBrowserCommand.MessageProcessor", "open-window");
        openWindowElement.setAttribute("uri", command.getUri());
        if (command.getName() != null) {
            openWindowElement.setAttribute("name", command.getName());
        }
View Full Code Here

     *
     * @param rc the relevant <code>RenderContext</code>
     * @param command the command
     */
    private void renderRedirect(RenderContext rc, BrowserRedirectCommand command) {
        ServerMessage serverMessage = rc.getServerMessage();
        serverMessage.addLibrary(BROWSER_COMMAND_SERVICE.getId());
        Element redirectElement = serverMessage.appendPartDirective(ServerMessage.GROUP_ID_POSTUPDATE,
                "EchoBrowserCommand.MessageProcessor", "redirect");
        redirectElement.setAttribute("uri", command.getUri());
    }
View Full Code Here

TOP

Related Classes of nextapp.echo2.webrender.ServerMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.