我创建了一个组件
<cc:interface>
......
</cc:interface>
<cc:implementation>
<cc:implementation>
<div id="#{cc.clientId}" style="margin: 0; padding: 0; width: 100%;">
...
<p:inputText id="texto" value="#{cc.attrs.value}"
readonly="#{cc.attrs.readonly}"
required="#{cc.attrs.required}"
maxlength="#{cc.attrs.maxlength}">
</p:inputText>
...
</div>
</cc:implementation> </cc:implementation>此组件在模板中使用,如下所示
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:util="http://java.sun.com/jsf/composite/util"
......
<p:outputLabel val="name" for="foo">
<util:texto id="foo" val="#{bean.text}" required="true" />
......
</html>但是,在提交表单上,如果p:outputlabel中的for="foo:texto"将图标绘制为红色但不需要图标,则组件foo没有红色边框,p:outputLabel也不显示所需的图标
请告诉我,解决方案是什么,谢谢
PD:请原谅我的英语很差。
发布于 2016-07-27 21:42:48
首先,将所有输入组件放入表单h:中。然后,试试这个:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:p="http://primefaces.org/ui">
<cc:interface>
<cc:attribute name="value" />
<cc:attribute name="readonly" />
<cc:attribute name="required" />
<cc:attribute name="maxlength" />
</cc:interface>
<cc:implementation>
<div id="#{cc.clientId}:_div" style="margin: 0; padding: 0; width: 100%;">
<p:inputText id="_input"
value="#{cc.attrs.value}"
required="#{cc.attrs.required}"
maxlength="#{cc.attrs.maxlength}" />
</div>
</cc:implementation>
</html>查看:
<h:form id="abcForm">
<app:test id="abcText"
value="#{some.thing}"
required="true"
maxlength="60" />
</h:form>这样,您就可以通过ids:abcForm:abcText:_div和abcForm:abcText:_input.来访问inputText和div在我的测试中,当提交为空时,inputText变红。
https://stackoverflow.com/questions/38601167
复制相似问题