1
內容,這是我的自定義組件定義:的facelet自定義組件 - 防止渲染UI:插入自定義組件
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<c:if test="${empty required}">
<c:set var="required" value="false" />
</c:if>
<c:if test="${empty disabled}">
<c:set var="disabled" value="false" />
</c:if>
<c:if test="${not disabled}">
<div id="#{id}DIV">
<label for="#{id}" class="portlet-form-label">${label}</label>
<ui:insert name="field" />
<c:if test="${required}">*</c:if>
<strong class="portlet-msg-error" style="display: none;"><h:message for="#{id}" /></strong>
</div>
</c:if>
</ui:composition>
這是我如何使用它:
<my:editLineInsert id="itSIN" label="#{label['label.stocks.income']}" tip="#{label['message.default.tooltip']}" disabled="#{engine.disabled['itSIN']}" required="#{engine.required['itSIN']}" >
<ui:define name="field">
<h:inputText id="itSIN" value="#{order.income}" disabled="#{engine.disabled['itSIN']}" required="#{engine.required['itSIN']}" >
<f:converter converterId="javax.faces.BigDecimal" />
<f:validator validatorId="V12DGS6DECS" />
</h:inputText>
</ui:define>
</my:editLineInsert>
我有<ui:insert name="field" />
麻煩。它總是呈現。如果disabled = true,我只在視圖的頂部有<input type="text" disabled="disabled" value="" name="itSIN" id="itSIN"/>
元素。注意:我使用ui:insert傳遞jsf組件,因爲我不知道如何將驗證器傳遞給定製組件內的h:inputText。