Package org.htmlparser.tags

Examples of org.htmlparser.tags.JspTag


        throws ParserException
    {
        String tagContents = tagData.getTagContents();
        tagData.setTagContents(
            tagContents.substring(1, tagContents.length() - 1));
        return new JspTag(tagData);
    }
View Full Code Here


        // Register the Jsp Scanner
        parser.addScanner(new JspScanner("-j"));
        parseAndAssertNodeCount(5);
        // The first node should be an HTMLJspTag
        assertTrue("Node 1 should be an HTMLJspTag", node[0] instanceof JspTag);
        JspTag tag = (JspTag) node[0];
        assertStringEquals(
            "Contents of the tag",
            "@ taglib uri=\"/WEB-INF/struts.tld\" prefix=\"struts\" ",
            tag.getText());

        // The second node should be a normal tag
        assertTrue("Node 2 should be an Tag", node[1] instanceof Tag);
        Tag htag = (Tag) node[1];
        assertStringEquals(
            "Contents of the tag",
            "jsp:useBean id=\"transfer\" scope=\"session\" class=\"com.bank.PageBean\"",
            htag.getText());
        assertStringEquals(
            "html",
            "<JSP:USEBEAN ID=\"transfer\" SCOPE=\"session\" CLASS=\"com.bank.PageBean\"/>",
            htag.toHtml());
        // The third node should be an HTMLJspTag
        assertTrue("Node 3 should be an HTMLJspTag", node[2] instanceof JspTag);
        JspTag tag2 = (JspTag) node[2];
        String expected =
            "\r\n"
                + "    org.apache.struts.util.BeanUtils.populate(transfer, request);\r\n"
                + "    if(request.getParameter(\"marker\") == null)\r\n"
                + "        // initialize a pseudo-property\r\n"
                + "        transfer.set(\"days\", java.util.Arrays.asList(\r\n"
                + "            new String[] {\"1\", \"2\", \"3\", \"4\", \"31\"}));\r\n"
                + "    else \r\n"
                + "        if(transfer.validate(request))\r\n"
                + "            ";
        assertEquals("Contents of the tag", expected, tag2.getText());

    }
View Full Code Here

        // Register the Jsp Scanner
        parser.addScanner(new JspScanner("-j"));
        parseAndAssertNodeCount(5);
        // The first node should be an HTMLJspTag
        assertTrue("Node 1 should be an HTMLJspTag", node[0] instanceof JspTag);
        JspTag tag = (JspTag) node[0];
        assertEquals(
            "Raw String of the first JSP tag",
            "<%@ taglib uri=\"/WEB-INF/struts.tld\" prefix=\"struts\" %>",
            tag.toHtml());

        // The third node should be an HTMLJspTag
        assertTrue("Node 2 should be an HTMLJspTag", node[2] instanceof JspTag);
        JspTag tag2 = (JspTag) node[2];
        String expected =
            "<%\r\n"
                + "    org.apache.struts.util.BeanUtils.populate(transfer, request);\r\n"
                + "    if(request.getParameter(\"marker\") == null)\r\n"
                + "        // initialize a pseudo-property\r\n"
                + "        transfer.set(\"days\", java.util.Arrays.asList(\r\n"
                + "            new String[] {\"1\", \"2\", \"3\", \"4\", \"31\"}));\r\n"
                + "    else \r\n"
                + "        if(transfer.validate(request))\r\n"
                + "            %>";
        assertEquals(
            "Raw String of the second JSP tag",
            expected,
            tag2.toHtml());
        assertTrue("Node 4 should be an HTMLJspTag", node[4] instanceof JspTag);
        JspTag tag4 = (JspTag) node[4];
        expected = "<%\r\n" + "%>";
        assertEquals(
            "Raw String of the fourth JSP tag",
            expected,
            tag4.toHtml());

    }
View Full Code Here

        // Register the jsp scanner
        parser.addScanner(new JspScanner("-j"));
        parseAndAssertNodeCount(1);
        //assertTrue("Node should be a jsp tag",node[1] instanceof HTMLJspTag);
        JspTag jspTag = (JspTag) node[0];
        assertEquals(
            "jsp toHTML()",
            "<% for (i=0;i<j;i++);%>",
            jspTag.toHtml());
    }
View Full Code Here

        // Register the Jsp Scanner
        parser.addScanner(new JspScanner("-j"));
        parseAndAssertNodeCount(4);
        // The first node should be an HTMLJspTag
        assertTrue("Third should be an HTMLJspTag", node[2] instanceof JspTag);
        JspTag tag = (JspTag) node[2];
        assertEquals("tag contents", "=object", tag.getText());
    }
View Full Code Here

        registerTag (new FrameSetTag ());
        registerTag (new FrameTag ());
        registerTag (new HeadingTag ());
        registerTag (new ImageTag ());
        registerTag (new InputTag ());
        registerTag (new JspTag ());
        registerTag (new LabelTag ());
        registerTag (new LinkTag ());
        registerTag (new MetaTag ());
        registerTag (new ObjectTag ());
        registerTag (new OptionTag ());
View Full Code Here

        createParser(
            "<%@ taglib uri=\"/WEB-INF/struts.tld\" prefix=\"struts\" %>\n"+
            jsp + "\n" +
            "<" + contents2 + ">\n<jsp:forward page=\"transferConfirm.jsp\"/><%\n"+
            "%>");
        parser.setNodeFactory (new PrototypicalNodeFactory (new JspTag ()));
        parseAndAssertNodeCount(8);
        // The first node should be a JspTag
        assertTrue("Node 1 should be a JspTag",node[0] instanceof JspTag);
        JspTag tag = (JspTag)node[0];
        assertStringEquals("Contents of the tag","%@ taglib uri=\"/WEB-INF/struts.tld\" prefix=\"struts\" %",tag.getText());

        // The second node should be a normal tag
        assertTrue("Node 3 should be a normal Tag",node[2] instanceof Tag);
        Tag htag = (Tag)node[2];
        assertStringEquals("Contents of the tag",contents,htag.getText());
        assertStringEquals("html",jsp,htag.toHtml());
        // The third node should be an JspTag
        assertTrue("Node 5 should be an JspTag",node[4] instanceof JspTag);
        JspTag tag2 = (JspTag)node[4];
        assertStringEquals("Contents of the tag",contents2,tag2.getText());
    }
View Full Code Here

            "<jsp:useBean id=\"transfer\" scope=\"session\" class=\"com.bank.PageBean\"/>\n"+
            "<%" +
            guts
            + "%><jsp:forward page=\"transferConfirm.jsp\"/><%\n"+
            "%>\n");
        parser.setNodeFactory (new PrototypicalNodeFactory (new JspTag ()));
        parseAndAssertNodeCount(8);
        // The first node should be a JspTag
        assertTrue("Node 1 should be a JspTag",node[0] instanceof JspTag);
        JspTag tag = (JspTag)node[0];
        assertEquals("Raw String of the first JSP tag","<%@ taglib uri=\"/WEB-INF/struts.tld\" prefix=\"struts\" %>",tag.toHtml());


        // The fifth node should be a JspTag
        assertTrue("Node 5 should be a JspTag",node[4] instanceof JspTag);
        JspTag tag2 = (JspTag)node[4];
        String expected = "<%" + guts + "%>";
        assertEquals("Raw String of the second JSP tag",expected,tag2.toHtml());
        assertTrue("Node 7 should be a JspTag",node[6] instanceof JspTag);
        JspTag tag4 = (JspTag)node[6];
        expected = "<%\n%>";
        assertEquals("Raw String of the fourth JSP tag",expected,tag4.toHtml());
    }
View Full Code Here

        createParser(
        "<h1>\n"+
        "This is a <%=object%>\n"+
        "</h1>");

        parser.setNodeFactory (new PrototypicalNodeFactory (new JspTag ()));
        parseAndAssertNodeCount(5);
        // The first node should be an JspTag
        assertTrue("Third should be an JspTag",node[2] instanceof JspTag);
        JspTag tag = (JspTag)node[2];
        assertEquals("tag contents","%=object%",tag.getText());
    }
View Full Code Here

                "return value.substring(indexs+9,indexe-2);\n" +
                "}\n" +
                "return value;\n" +
                "}\n" +
                "%>");
            parser.setNodeFactory (new PrototypicalNodeFactory (new JspTag ()));
            parseAndAssertNodeCount(1);
        }
    }
View Full Code Here

TOP

Related Classes of org.htmlparser.tags.JspTag

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.