JavaServerFaces
Version vom 28. Januar 2013, 08:58 Uhr von Hamatoma (Diskussion | Beiträge)
Einbinden von JS-Dateien
Dateibaum:
- webapp
- WEB-INF
- resources
- js
- common.js
- js
XML-Code:
<body< <h:outputScript library="js" name="myice.js" />
Dump eines DOM-Knotens
function dumpNode(node, level){ var indent = ""; for (var ii = 1; ii <= level; ii++) indent = indent + " "; var rc = indent + "Tag: " + node.tagName + "\n"; if (node && node.hasChildNodes()){ var child = node.firstChild; while(child){ rc = rc + indent + dumpNode(child, level + 1); child = child.nextSibling; } } while(node){ node = node.nextSibling; if (node) rc = rc + dumpNode(node, level); } return rc; }
I18N
in faces-config.xml:
<application> <resource-bundle> <base-name>i18n.messages</base-name> <var>i18nMsg</var> </resource-bundle> <locale-config> <default-locale>en</default-locale> <supported-locale>de</supported-locale> </locale-config> </application>
Sprachdatei resources/i18n/messages_en.properties
greetings=Greetings
Sprachdatei resources/i18n/messages_de.properties
greetings=Grüße
sample.xhtml:
<h:outputText value="#{i18nMsg.greetings}" />
Alternative I18n
sample.jsf:
<f:loadBundle var="bundle" basename="messages.BookstoreMessages" /> <h:outputText value="#{bundle.greetings}" />