未显示验证消息的复合JSF 2.2组件
我正在使用公司设计定制JSF2.2组件。 我对输入文本有问题。 问题是,如果我使用我的组件并希望指定未显示验证消息的复合JSF 2.2组件,jsf,jsf-2.2,composite-component,myfaces,Jsf,Jsf 2.2,Composite Component,Myfaces,我正在使用公司设计定制JSF2.2组件。 我对输入文本有问题。 问题是,如果我使用我的组件并希望指定,它将不起作用。因为组件的id不同 <h:message for="input"/> <custom:input id="input" required="true"/> 若我在组件内部指定它,它可以工作,但这不是我想要的。它应该是灵活的,以防任何人想要在不同的地方使用消息,而不是我在组件中指定的位置 组件定义(带消息): 你有办法解决这个问题吗 <!D
,它将不起作用。因为组件的id不同
<h:message for="input"/>
<custom:input id="input" required="true"/>
若我在组件内部指定它,它可以工作,但这不是我想要的。它应该是灵活的,以防任何人想要在不同的地方使用消息,而不是我在组件中指定的位置
组件定义(带消息):
你有办法解决这个问题吗
<!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://xmlns.jcp.org/jsf/html"
xmlns:cc="http://xmlns.jcp.org/jsf/composite"
xmlns:p="http://xmlns.jcp.org/jsf/passthrough">
<!-- INTERFACE -->
<cc:interface name="input" expert="true">
<cc:attribute name="id" required="false"/>
<cc:attribute name="label" />
<cc:attribute name="value" />
<cc:attribute name="title" />
<cc:attribute name="readonly" default="false" type="java.lang.Boolean" />
<cc:attribute name="required" default="false" type="java.lang.Boolean" />
<cc:attribute name="rendered" default="true" type="java.lang.Boolean" />
<cc:attribute name="placeholder" type="java.lang.String"/>
<cc:clientBehavior name="click" targets=":#{cc.id}" event="click" default="true"/>
<cc:clientBehavior name="change" targets=":#{cc.id}" event="change" default="true"/>
<cc:clientBehavior name="blur" targets=":#{cc.id}" event="blur" default="true"/>
<cc:clientBehavior name="keyup" targets=":#{cc.id}" event="keyup" default="true"/>
</cc:interface>
<cc:implementation>
<h:panelGrid rendered="#{cc.attrs.rendered}" columns="2" id="panel" styleClass="customInputWrapper">
<h:outputLabel title="#{cc.attrs.title}"
value="#{cc.attrs.label}#{cc.attrs.required ? ' *' : ''}" for="#{cc.attrs.id}" />
<h:inputText id="#{cc.attrs.id}" styleClass="customInput" value="#{cc.attrs.value}" p:placeholder="#{cc.attrs.placeholder}" readonly="#{cc.attrs.readonly}" title="#{cc.attrs.title}" required="#{cc.attrs.required}"/>
<h:message for="#{cc.attrs.id}" />
<h:outputStylesheet library="custom" name="customComponentsStyle.css"/>
</h:panelGrid>
</cc:implementation>
</html>