Package com.volantis.mcs.protocols

Examples of com.volantis.mcs.protocols.DOMOutputBuffer


            public void rendererVisit(Menu menu) throws RendererException {
                // For menus, we render only the root menu.
                if (menu.getContainer() == null) {
                    // process the root menu
                   
                    DOMOutputBuffer dom = locator.getOutputBuffer();

                    // Open a menu element so we can see this renderer in the
                    // output.
                    Element menuElement = dom.openElement("menu");

                    // Iterate over the children in order.
                    renderChildren(menu);

                    // Close the menu element.
                    dom.closeElement(menuElement);
                }
                // else, ignore nested menus for now
            }
        };
        visitor.accept(menu);
View Full Code Here


     * todo XDIME-CP: Fix when done layout transformation.
     */
    public void notestOpenPane() throws RepositoryException {
        privateSetUp();

        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();

        Element el = null;

        Pane pane = null;
        PaneAttributes attributes = null;

        //=============================================================
        // Styles defined = No
        //=============================================================
        pane = new Pane(null);
        attributes = new PaneAttributes();
        attributes.setStyles(StylesBuilder.getDeprecatedStyles());
        attributes.setPane(pane);

        protocol.openPane(buffer, attributes);

        assertSame("The buffer current element should be the root element " +
                   "but was" + buffer.getCurrentElement(),
                   buffer.getRoot(),
                   buffer.getCurrentElement());

        //=============================================================
        // Styles defined = Yes
        //@todo XDIME-CP pass in Styles and check they're correctly propagated through
        //=============================================================
        pane = new Pane(null);

        attributes = new PaneAttributes();
        attributes.setStyles(StylesBuilder.getDeprecatedStyles());
//        attributes.setStyleClass("fred");
//        attributes.setBackgroundColour("#ff0000");
//        attributes.setBorderWidth("1");
//        attributes.setCellPadding("2");
//        attributes.setCellSpacing("3");
        attributes.setPane(pane);

        protocol.openPane(buffer, attributes);
        try {
            // A div will have been opened to render styles because:
            // 1. This protocol supports stylesheets.
            // 2. The pane has a style class "fred".
            // 3. Any of border width/cell padding/cell spacing have non-zero
            //    values.
            // The div will have an appropriate class attribute.
            el = buffer.closeElement("div");
//            assertEquals("Invalid class attribute on div",
//                    "VE-pane-fred", el.getAttributeValue("class"));

            el = buffer.closeElement("td");

            assertNull("bgcolor on td", el.getAttributeValue("bgcolor"));
            assertNull("border on td", el.getAttributeValue("border"));
            assertNull("cellspacing on td", el.getAttributeValue("cellspacing"));
            assertNull("cellpadding on td", el.getAttributeValue("cellpadding"));
            el = buffer.closeElement("tr");
            assertNull("Class attribute on tr", el.getAttributeValue("class"));
            assertNull("bgcolor on tr", el.getAttributeValue("bgcolor"));
            assertNull("border on tr", el.getAttributeValue("border"));
            assertNull("cellspacing on tr", el.getAttributeValue("cellspacing"));
            assertNull("cellpadding on tr", el.getAttributeValue("cellpadding"));
            el = buffer.closeElement("table");
//            assertNull("Invalid class attribute on table",
//                    el.getAttributeValue("class"));
            assertEquals("Invalid bgcolor attribute",
                    "#ff0000", el.getAttributeValue("bgcolor"));
            assertEquals("Invalid border attribute",
View Full Code Here

        Styles styles = null;
        if (elementDetails != null) {
            styles = elementDetails.getStyles();
        }

        DOMOutputBuffer outputBuffer = (DOMOutputBuffer) buffer;
        Element element = outputBuffer.addElement("plain-image");
        if (styles != null) {
            element.setStyles(styles);
        }

        try {
View Full Code Here

    /**
     * Test the method doImage
     */
    public void testDoImage() throws Exception {
        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();

        // Needed to allow the call to getTextFromReference within doImage to work
        context = new TestMarinerPageContext();

        protocol.setMarinerPageContext(context);
View Full Code Here

     * handles null values for "rows" and "cols" attributes and negative values.
     *
     * @throws Exception
     */
    public void testOpenSegmentGrid() throws Exception {
        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();

        int[] rows = null;
        int[] cols = null;


        SegmentGridAttributes ga = new SegmentGridAttributes();
        // set to null
        ga.setColumnWidths(cols);
        ga.setRowHeights(rows);

        protocol.openSegmentGrid(buffer, ga);

        // test to ensure that null columnWidth and rowHeights produce NO
        // args in the resulting HTML
        String expected = "<frameset border=\"0\" frameborder=\"no\" " +
                "framespacing=\"0\"/>";
        assertEquals("Ensure that null column and row widths do not produce " +
                "attributes", expected, bufferToString(buffer));

        // test to ensure that -1 for row or column attribute will be replaced
        // by "*" (indicating default value for the browser to decide how to
        // render
        expected = "<frameset border=\"0\" frameborder=\"no\" " +
                "framespacing=\"0\" rows=\"*\"/>";
        rows = new int[1];
        rows[0] = -1;
        ga.setRowHeights(rows);
        buffer.clear();
        protocol.openSegmentGrid(buffer, ga);
        assertEquals("Ensure that -1 is replaced by * (rows)", expected,
                bufferToString(buffer));

        // same test as above but for columns
        expected = "<frameset border=\"0\" cols=\"*\" frameborder=\"no\" " +
                "framespacing=\"0\"/>";
        ga.setRowHeights(null);
        ga.setColumnWidths(rows);
        buffer.clear();
        protocol.openSegmentGrid(buffer, ga);
        assertEquals("Ensure -1 is replaced by * (cols)", expected,
                bufferToString(buffer));

        // general test to check substitution of negative values for "*"
        expected = "<frameset border=\"0\" cols=\"*,4,*\" frameborder=\"no\" " +
                "framespacing=\"0\" rows=\"3,*,3\"/>";
        rows = new int[]{3, -100, 3};
        cols = new int[]{-1, 4, -1};
        ga.setRowHeights(rows);
        ga.setColumnWidths(cols);
        buffer.clear();
        protocol.openSegmentGrid(buffer, ga);
        assertEquals("Ensure that general substitution occurs correctly",
                expected, bufferToString(buffer));
    }
View Full Code Here

        TestRendererContext context =
                new TestRendererContext(assetResolverMock);
       
        TestDeprecatedOutputLocator outputLocator
                = new TestDeprecatedOutputLocator();
        DOMOutputBuffer buffer = context.getBuffer();
        TestDeprecatedImageOutput imageOutput
                = (TestDeprecatedImageOutput) outputLocator.getImageOutput();

        // Create the renderer to test, using the test objects created above.
        OpenwaveMenuItemRendererFactory rendererFactory =
                new OpenwaveMenuItemRendererFactory(context, outputLocator);
        final StylePropertyResolver stylePropertyResolver =
                new DefaultStylePropertyResolver(null, null);
        final DefaultMenuSeparatorRendererSelector rendererSelector =
                new DefaultMenuSeparatorRendererSelector(
                        new OpenwaveMenuSeparatorRendererFactory(),
                        context.getAssetResolver(),
                        stylePropertyResolver);
        DefaultMenuItemRendererSelector selector =
                new DefaultMenuItemRendererSelector(
                        rendererFactory, rendererSelector);

        MenuBufferFactory bufferFactory
                = new ConcreteMenuBufferFactory(SeparatorRenderer.NULL);

        DefaultMenuBufferLocator bufferLocator
                = new DefaultMenuBufferLocator(context.getOutputBufferResolver(),
                        bufferFactory);

        OpenwaveMenuRenderer menuRenderer =
                new OpenwaveMenuRenderer(selector, bufferLocator);

        // Build a simple menu model we can exercise the renderer with.
        Menu menu = createSimpleMenu(
                imageStyle, textStyle, orderStyle,
                menuTitle, itemTitle, itemHref, itemText, itemImageComponent);

        // Render the menu model out to the buffer.
        menuRenderer.render(menu);

        // Extract the output from the menu rendering as a string.
        String actual = styledDOMTester.render(buffer.getRoot());
        //System.out.println(actual);

        // Calculate the image part of the menu items rendered from the
        // related mariner menu style property setting, if any.
        String imageValue = null;
View Full Code Here

        builder.setHref(new LiteralLinkAssetReference(href));

        builder.startLabel();

        builder.startText();
        DOMOutputBuffer dom = new TestDOMOutputBuffer();
        dom.writeText(text);
        builder.setText(dom);
        builder.endText();

        builder.startIcon();
        // this is required or we crash trying to extract the element name in
View Full Code Here

    }

    protected DOMOutputBuffer getCurrentBuffer (
            ContainerInstance containerInstance) {

        DOMOutputBuffer buffer = (DOMOutputBuffer)
                containerInstanceBufferMap.get(containerInstance);
        return (null != buffer) ? buffer : super.getCurrentBuffer(containerInstance);
    }
View Full Code Here

                = new DefaultMenuItemRendererSelector(
                        itemRendererFactory, separatorRendererSelector);
        DeprecatedDivOutput divOutput = new TestDeprecatedDivOutput();
        bracketingRenderer
                = new DefaultMenuBracketingRenderer(divOutput);
        DOMOutputBuffer outputBuffer = new TestDOMOutputBuffer();
        OutputBufferResolver bufferResolver
                = new TestOutputBufferResolver(outputBuffer);
        bufferLocatorFactory
                = new DefaultMenuBufferLocatorFactory(bufferResolver);
    }
View Full Code Here

       
        i = element.exprElementEnd(requestContext,attributes);
        assertEquals("Wrong code returned by elementEnd",
                PAPIElement.CONTINUE_PROCESSING, i);

        DOMOutputBuffer dob = protocol.getCurrentBuffer();
        String str = DOMUtilities.toString(dob.getRoot());
        assertEquals("Incorrect output ",
            "<script charset=\"Ascii\" defer=\"defer\" language=\"Language\"" +
            " type=\"text/javascript\"/>", str );
    }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.protocols.DOMOutputBuffer

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.