JSF DOM Attribute 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/taglib/jsf/dom"
value="#{dom:attribute(domBean.attributeNode, 'test')}"/>
For the demo we need a DOM document that contains an attribute the following code snippet is used to create such a simple document. It is a document with one node and one attribute named 'test'.
/**
* Get the DOM node for the attribute example.
*
* @return the attribute node.
*/
public Node getAttributeNode() {
Node result = null;
try {
String xml = "<node test=\"This is an attribute\"/>";
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 value of the "test" attribute is "This is an attribute"