jsf - PrimeFaces 组件的自定义渲染器未注册

标签 jsf primefaces custom-renderer

我已经编写了一个自定义渲染器类来修复 Primefaces 问题#5869,现在尝试在我正在开发的网站上使用它。我已经通过包括来做到这一点

<renderer>
        <component-family>org.primefaces.component</component-family>
        <renderer-type>org.primefaces.component.inputtext.InputTextRenderer</renderer-type>
        <renderer-class>at.ac.uibk.library.utils.fixedInputTextRenderer</renderer-class>
    </renderer>

在我的 faces-config.xml 中。 但是用js仍然可以插入超过指定的字符限制。

我在fixedInputTextRenderer中添加了这些行,它应该进行必要的检查

if (submittedValue != null) {
        int maxlength = inputText.getMaxlength();

        if (maxlength > 0 && submittedValue.length() > maxlength) {
            submittedValue = submittedValue.substring(0, maxlength);
        }
        inputText.setSubmittedValue(submittedValue);
    }

最佳答案

指定<renderer-type>错误的是:

<renderer-type>org.primefaces.component.inputtext.InputTextRenderer</renderer-type>

根据VDL documentation <p:inputText> 它默认注册在 org.primefaces.component.InputTextRenderer .

Component information

Info Value
Component Type org.primefaces.component.InputText
Handler Class None
Renderer Type org.primefaces.component.InputTextRenderer
Description None

因此进行相应调整:

<renderer-type>org.primefaces.component.InputTextRenderer</renderer-type>

请注意,组件类型和渲染器类型实际上并不代表 FQN,而只是键/标识符。它们看起来像 FQN 确实是强制唯一性的一个不幸的副作用,这确实会让初学者感到困惑。

另请参阅:

关于jsf - PrimeFaces 组件的自定义渲染器未注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65718999/

相关文章:

java - 在 richfaces 中使用自定义 skin.properties 文件时无法找到 skinning.css 和 packed.css

jsf - 如何在 JSF Datatable 中生成动态列?

jsf - Primefaces ajax事件更改不调用监听器

javascript - 如何在模态中显示 primefaces 图表?

jsf - PrimeFaces 组件的自定义渲染器在 Tomcat 中可以正常工作,但在 Websphere 中不能

jsf - PrimeFaces CSS 皮肤未显示在登录页面中,还有 JavaScript 未定义错误

jsf-2 - 带分页的 Primefaces dataTable rowIndexVar

java - JSF Composite 组件无法在 Mojarra 2.1.9 上运行

jsf - 自定义 JSF 组件渲染器 : how to render HTML around another element

c# - 如何在 Xamarin Shell 中自定义顶部选项卡 (ShellSection) 的外观?