JSF DOM Name 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:name(domBean.textNode)}"/>
For the demo we need a DOM document that contains a node, the following code snippet is used tocreate such a simple document. It is a document that contains node, named 'test'.
/**
* 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
The name of the node is "test"