【发布时间】:2017-01-05 03:28:01
【问题描述】:
我想在 JSF(带有 primefaces)中创建我的自定义复合组件,该组件在输入前显示标签并在末尾添加一条消息。
为了做到这一点,这是我的源代码:
复合:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface componentType="customInput">
<composite:attribute name="label" />
<composite:attribute name="value" />
</composite:interface>
<composite:implementation>
<h:panelGrid columns="3">
<h:outputText value="#{cc.attrs.label}:" />
<p:inputText id="abcde" value="#{cc.attrs.value}" />
<p:message for="abcde" />
</h:panelGrid>
</composite:implementation>
</html>
支持 bean:
@FacesComponent(value = "customInput")
public class CustomInput extends InputText implements NamingContainer {
@Override
public String getFamily() {
return UINamingContainer.COMPONENT_FAMILY;
}
}
到目前为止,一切都很好。现在我想使用 p:inputText 组件继承的事件。比如:
<pch2:PchInputText2 label="Name" id="test2" value="#{testBean.test}">
<p:ajax event="blur" listener="#{chantierFormBean.updateMap()}" />
<p:ajax event="change" listener="#{chantierFormBean.updateMap()}" />
</pch2:PchInputText2>
我知道我可以通过添加来传递这些事件
<composite:clientBehavior name="change" event="change" targets="abcde" />
到复合:接口部分,但是我必须为每个事件添加一个客户端行为(将来)。难道没有一种方法可以传递primefaces inputtext继承的所有事件吗?
提前致谢
【问题讨论】:
标签: jsf events inheritance primefaces composite-component