Manorrock.com / Demo JSF

JSF DOM Map demo

How to get this working

To get this working on your own page, look below for the example snippet
used to get the demo on this page working.
        <h:outputText value="#{dom:text(dom:map(domBean.listNode)['a'])}"/> <br/>
        <h:outputText value="#{dom:text(dom:map(domBean.listNode)['c'])}"/> <br/>
        <h:outputText value="#{dom:text(dom:map(domBean.listNode)['b'])}"/> <br/>
                    
For the demo we need a DOM document that contains a list of nodes, the following code snippet is used to create such a simple document. It is a document that contains 3 nodes, {A, B, C}. Note the demo and code snippet above access the list by using the node names a, c and b.
        /**
         * Get the DOM node for the list and map example.
         *
         * @return the list node.
         */
        public Node getListNode() {
            Node result = null;

            try {
                String xml = "<test><a>A</a><b>B</b><c>C</c></test>";
                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                DocumentBuilder builder = factory.newDocumentBuilder();
                Document document = builder.parse(
                        new InputSource(new StringReader(xml)));
                result = document.getFirstChild();
            } catch (Exception exception) {
            }

            return result;
        }

                    

Actual demo

A
C
B

Up