Manorrock.com / Demo JSF

JSF DOM Text 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 xmlns:dom="http://www.manorrock.com/jsf/dom"
        value="#{dom:text(domBean.textNode)}"/>
                    
For the demo we need a DOM document that contains a text node, the following code snippet is used to create such a simple document. It is a document that contains a text node, with the text 'This is the text'.
        /**
         * Get the DOM node for the text example.
         *
         * @return the text node.
         */
        public Node getTextNode() {
            Node result = null;

            try {
                String xml = "<test>This is the text</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

This is the text

Up