jsf - 如何停用 JSF 标签 (Primefaces)

标签 jsf primefaces jsf-2.2 blacklist

我的 UI 使用 Primefaces 5.x(在 myFaces 2.2.x 上),并且我想禁用/停用一些 JSF 标签以避免错误。

有我可以使用的黑名单或白名单吗?

最佳答案

标准 JSF/PrimeFaces API 中没有这样的东西。

快速而肮脏的解决方法将覆盖 web 应用程序的 faces-config.xml 中的组件注册。由此您将组件类设置为非 UIComponent类(它最终会在使用时抛出ClassCastException),或自定义UIComponent这会抛出例如IllegalArgumentException在其构造函数中。

例如如果您想避免使用 <p:selectOneMenu> component其中有 component type of org.primefaces.component.SelectOneMenu :

<component>
    <component-type>org.primefaces.component.SelectOneMenu</component-type>
    <component-class>java.lang.Object</component-class>
</component>

替代方案是 manually visit the component tree构建完成后,根据 Set<Class<UIComponent>> 中的白/黑名单检查每个组件类。 。

更干净的替代方案是 override Application#createComponent() 根据白/黑名单检查组件类型。

另一种选择是编辑 PrimeFaces taglib/config XML 以删除不需要的组件并重建 JAR。

关于jsf - 如何停用 JSF 标签 (Primefaces),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30081489/

相关文章:

jsf-2 - primefaces 对话框不工作

jsf - 应用程序范围 bean 中的实用方法

jsf - 在 View 之间共享组件 - 如何改进我的设计?

jsf - 启用选择时的 javax.faces.FacesException : DataModel must implement org. primefaces.model.SelectableDataModel

ajax - 带有浏览器历史记录/标签的 PrimeFaces Ajax 导航

java - 菜单系统教程

jquery - 验证阻止命令按钮

java - 使用 JSF primefaces 和 Google App Engine 数据存储的 CRUD 最佳实现是什么

mysql - 使用 JSF 从 MySQL 中删除行

jquery - Primefaces selectOneButton : set selected option via JS/jquery