【问题标题】:JSF t:datatable and c:forEach looks like conflictJSF t:datatable 和 c:forEach 看起来像冲突
【发布时间】:2012-05-02 17:03:54
【问题描述】:

我有 <t:datatable> 里面的 <c:forEach> 里面的项目 <c:forEach> 有列表。 (我从后端 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>

下面没有反映任何东西... :(

<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>

【问题讨论】:

    标签: java jsf


    【解决方案1】:

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

    在您的特定情况下,在 &lt;c:forEach&gt; 运行的那一刻,${insuranceBean} 将始终评估为 null,因为它已被定义为当时未运行的 JSF &lt;t:dataTable&gt; 组件的 var .

    您需要&lt;t:dataList&gt; 而不是&lt;c:forEach&gt;

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

    另见:

    【讨论】:

    • 非常感谢。正如我一直接受的那样,你肯定会给出一些答案...... :) 非常感谢......我从 JSF 开始使用现有的构建源代码,所以对基础知识不太了解......你能帮我理解单词during view build time - based on the view source codeduring view render time。还有一个词components tree。抱歉轰炸问题... :(
    • 您是否阅读过“另请参阅”链接? “查看构建时间”是 JSP 或 XHTML 文件转换为 UIViewRoot 并将所有组件作为子组件(这是组件树)的过程。 “查看渲染时间”是在渲染响应阶段运行的过程,其中在 UIViewRoot 上调用 encodeAll() 方法,因此其所有子级都将生成 HTML。
    • 哦,是的!我只是用稳定的头脑慢慢阅读它,我得到了概念......你是头脑大师......很棒......再次非常感谢。
    猜你喜欢
    • 2012-02-04
    • 1970-01-01
    • 2012-08-15
    • 2010-09-16
    • 2011-08-04
    • 1970-01-01
    • 2014-02-04
    • 1970-01-01
    • 2012-02-02
    相关资源
    最近更新 更多