How to handle specific namespace declaration in JSF template

橙三吉。 提交于 2019-12-11 07:35:27

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!