【发布时间】:2012-09-21 06:39:08
【问题描述】:
我正在尝试创建复合组件。我在composite:interface 部分定义了 4 个属性。这是代码
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface >
<composite:attribute name="id" />
<composite:attribute name="maxlength" />
<composite:attribute name="required"/>
<composite:attribute name="value" />
</composite:interface>
<composite:implementation xmlns:kc="http://java.sun.com/jsf/composite/components/kaysComposite">
<p:inputTextArea id="#{cc.attrs.id}" value="#{cc.attrs.value}" maxlength="#{cc.attrs.maxlength}" required="#{cc.attrs.required}" counterTemplate="{0} / #{cc.attrs.maxlength}" counter="#{cc.attrs.id}_counter"/>
<h:outputText id="#{cc.attrs.id}_counter"/>
</composite:implementation>
</html>
这是我使用我的组件的页面
<kc:kaysInputTextArea id="gpAdres" value="#{someBean.variable}" maxlength="250" required="true"/>
<p:message for="gpAdres" />
奇怪的部分是 required 属性不起作用,但其他部分工作正常。我找不到它为什么会这样。
【问题讨论】: