JSF t:datatable和c:forEach看起来像冲突 [英] JSF t:datatable and c:forEach looks like conflict

查看:89
本文介绍了JSF t:datatable和c:forEach看起来像冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有<t:datatable>,其中<c:forEach>中的<c:forEach>个项目具有列表. (我从后端bean进行了检查.)

I have <t:datatable> inside which <c:forEach> items inside <c:forEach> have list. (I checked from backend bean).

<t:dataTable id="insuranceListTable" rowIndexVar="row" width="100%"
styleClass="table" cellspacing="0" border="0"
value="#{insuranceBackingBean.allInsurancesByPatientId}"
var="insuranceBean">
<h:column>
<f:facet name="header">
    <f:verbatim>Drug Formulary</f:verbatim>
</f:facet>
<h:panelGroup id="formularyInformation">
    <h:panelGroup rendered="#{!empty insuranceBean.response4CheckDrugFormulary.reactionList[0].warningList}">
        <c:forEach items="${insuranceBean.response4CheckDrugFormulary.reactionList[0].warningList}" var="warning">
            <b><span title="${warning.warningText}"><c:out value=" [${warning.warningCode}] "></c:out></span></b>
        </c:forEach>
    </h:panelGroup>
    &nbsp;&nbsp;
    <a4j:commandLink onclick="setVisibleAlternativeListGrid();" rendered="#{!empty insuranceBean.response4CheckDrugFormulary.reactionList[0].drugAlternativeList.alternativeList}">
        <a href="#" id="alternative">Alternative [<h:outputText value="#{insuranceBean.response4CheckDrugFormulary.reactionList[0].drugAlternativeList.count}"></h:outputText>]</a> &nbsp;
    </a4j:commandLink>
    <a4j:commandLink onclick="setVisibleAlternativeListGrid();" rendered="#{!empty insuranceBean.response4CheckDrugFormulary.reactionList[0].coPayList}">
        &nbsp;<a href="#" id="coPay">Co-Pay</a>
    </a4j:commandLink>
</h:panelGroup> 
</h:column>
</t:dataTable>

下面没有任何反应...:(

Below doesn't reflect any thing... :(

<c:forEach items="${insuranceBean.response4CheckDrugFormulary.reactionList[0].warningList}" var="warning">
        <b><span title="${warning.warningText}"><c:out value=" [${warning.warningCode}] "></c:out></span></b>
    </c:forEach>

推荐答案

JSTL标记在视图构建期间运行,其中JSF组件树是基于视图源代码生成的. JSF组件在视图渲染期间运行,其中基于JSF组件树生成HTML输出.换句话说,JSTL标记和JSF组件不会像您期望的那样同步运行.

JSTL tags runs during view build time wherein the JSF component tree is produced based on the view source code. JSF components runs during view render time wherein HTML output is produced based on the JSF component tree. In other words, JSTL tags and JSF components doesn't run in sync as you'd expect from the coding.

在您的特定情况下,在<c:forEach>运行时,${insuranceBean}始终会评估为null,因为这被定义为当时未运行的JSF <t:dataTable>组件的var

In your particular case, at the moment <c:forEach> runs, the ${insuranceBean} will always evaluate to null, because that's been definied as var of JSF <t:dataTable> component which isn't running at that moment.

您需要<t:dataList>而不是<c:forEach>.

<t:dataList value="#{insuranceBean.response4CheckDrugFormulary.reactionList[0].warningList}" var="warning">
    <b><span title="#{warning.warningText}"><h:outputText value=" [#{warning.warningCode}] " /></span></b>
</t:dataList>

另请参见:

  • JSF2 Facelets中的JSTL ...有意义吗?
  • See also:

    • JSTL in JSF2 Facelets... makes sense?
    • 这篇关于JSF t:datatable和c:forEach看起来像冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆