2

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>
Matt Handy
  • 29,855
  • 2
  • 89
  • 112
Ketan Bhavsar
  • 5,338
  • 9
  • 38
  • 69

1 Answers1

3

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.

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.

You need <t:dataList> instead of <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>

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks a lot. As I always accept you will surely give some answer... :) Thanks a lot... I started in JSF with existing build source code so not much aware about basics... Can you help me to understand words `during view build time` - `based on the view source code` and `during view render time`. As well one more word `components tree`. Sorry for bombarding questions... :( – Ketan Bhavsar May 02 '12 at 17:23
  • Have you read the "See also" link? The "view build time" is the process when a JSP or XHTML file get converted to `UIViewRoot` with all components as children (this is the component tree). The "view render time" is the process which runs during render response phase wherein `encodeAll()` method is called on `UIViewRoot` and thus all its children will generate HTML. – BalusC May 02 '12 at 17:26
  • Oh Yeah! I just read it slowly with stable mind and I got concept... You are master mind... awsome... Once again Thanks a lot. – Ketan Bhavsar May 02 '12 at 17:34