如何在JSF模板中处理特定的名称空间声明 [英] How to handle specific namespace declaration in JSF template

查看:110
本文介绍了如何在JSF模板中处理特定的名称空间声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可供所有其他页面使用的主模板.

I have a master template that are used by all the other pages.

想象一下,我有一些页面在使用PrimeFaces组件,而另一些页面在使用facelets.此刻,我必须像这样在主模板中声明所有名称空间:

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">

这意味着没有PrimeFaces组件的页面仍将具有PrimeFaces命名空间声明.这是个好主意吗?

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?

推荐答案

这意味着没有PrimeFaces组件的页面仍将具有PrimeFaces命名空间声明.这是个好主意吗?

这完全没有害处. Facelets会在呈现HTML时将它们修剪掉.如果未在当前模板中的任何地方使用命名空间声明,则可以将其保留.请注意,名称空间声明仅适用于当前模板,不适用于包含/装饰的模板.

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.

我们如何将非通用名称空间从主模板中排除并在特定页面中声明?

您可以这样做.那应该不成问题.

You can just do so. That should not form a problem.

这篇关于如何在JSF模板中处理特定的名称空间声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆