1

これは私のカスタムコンポーネント定義です:

<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"/>、ビューの上部に要素だけが表示されます。注: カスタム コンポーネント内の h:inputText にバリデータを渡す方法がわからないため、ui:insert を使用して jsf コンポーネントを渡します。

4

1 に答える 1

1

私の推測では<c:if>、コンポーネント ツリーの構築段階で評価され、その後評価されなくなるため、期待どおりに機能していないと思われます。このページを見てください。

個人的には facelets で JSTL タグを使用することは避けています。<c:if>タグの代わりに使用することも<ui:fragment><h:panelGroup>「rendered」属性を使用することもできます。

于 2009-10-02T09:42:24.587 に答える