PrimeFaces 组件的自定义渲染器未注册
Custom renderer for PrimeFaces component not registering
我已经编写了自定义渲染器 Class 来修复 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>
在我的脸上-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 of <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,而只是 keys/identifiers。它们看起来像 FQN 确实是强制唯一性的不幸副作用,这确实会让初学者感到困惑。
另请参阅:
- What is the relationship between component family, component type and renderer type?
- How to findout component-family and renderer-type of a JSF component
我已经编写了自定义渲染器 Class 来修复 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>
在我的脸上-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 of <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,而只是 keys/identifiers。它们看起来像 FQN 确实是强制唯一性的不幸副作用,这确实会让初学者感到困惑。
另请参阅:
- What is the relationship between component family, component type and renderer type?
- How to findout component-family and renderer-type of a JSF component