问题
I have a master template that are used by all the other pages.
Imagine that I some of pages that are using PrimeFaces components, and some are using facelets. At the moment I have to declare all the namespaces in the master template like this:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
This means that the pages without PrimeFaces components will still have the PrimeFaces namespace declaration. Is this an good idea?
How can we leave the non-common namespace out from the master template and declare it in the specific pages?
回答1:
This means that the pages without PrimeFaces components will still have the PrimeFaces namespace declaration. Is this an good idea?
This doesn't harm at all. Facelets will trim them out anyway while rendering HTML. You can leave the namespace declarations away if it's not been used anywhere in the current template. Note that the namespace declarations only applies to the current template, not to the included/decorated templates.
How can we leave the non-common namespace out from the master template and declare it in the specific pages?
You can just do so. That should not form a problem.
来源:https://stackoverflow.com/questions/9435254/how-to-handle-specific-namespace-declaration-in-jsf-template