Reputation: 1713
I'm getting this "Base is null: item" jsf1.1 error in datatable that I just couldn't quite figure out. It is a two level datatable and the error is happening on the 2nd level datatable. The first level datatable is bind to the value of ArrayList deviceListDeviceReferences. In this datatable, it has a column that contains another datatable. This 2nd level datatable is bind to the value of ArrayList holderNameMasks. This value it retrived from DeviceReferenceJTO, which is basically the row item from the first datatable.
Below is what a snippet of the html:
<h:dataTable border="0" cellspacing="0"
value="#{deviceReferenceBean.deviceListDeviceReferences" var="item"
rendered="#{not empty deviceReferenceBean.deviceListDeviceReferences }"
binding="#{deviceReferenceBean.deviceListDeviceReferencesTable}"
>
<h:column>
<h:outputText value="Holder Name:" />
<!-- device heading -->
<h:outputText value="#{item.deviceLabel }" styleClass="DeviceReferenceTitleBarBorder" style="width:100%; height:30px; background-color:#f9f9f9"/>
<!-- holder name -->
<h:panelGrid columns="2" rendered="#{item.hasHolderNameMasks}" >
<h:outputText value="Holder Name:" />
<h:dataTable border="0" cellspacing="0"
value="#{item.holderNameMasks}" var="holderMaskItem"
rendered="#{not empty deviceReferenceBean.deviceListDeviceReferences and item.hasHolderNameMasks}"
binding="#{item.holderNameMasksTable}"
>
<h:column>
<h:outputText value="#{holderMaskItem.fieldLabel}" />
</h:column>
<h:column>
<h:panelGrid columns="1">
<h:inputText value="#{holderMaskItem.fieldValue}" />
<h:outputText value="#{holderMaskItem.instruction }" rendered="#{holderMaskItem.hasInstruction"/>
</h:panelGrid>
</h:column>
</h:dataTable>
</h:panelGrid>
</h:column>
</h:dataTable>
Below is what the component looks like:
<HtmlForm enctype="application/x-www-form-urlencoded" id="_idJsp323" rendered="true" styleClass="MAForm" submitted="false" transient="false">
<HtmlDataTable border="0" cellspacing="0" first="0" id="_idJsp324" rendered="#{not empty deviceReferenceBean.deviceListDeviceReferences }=true" rowIndex="-1" rows="0" transient="false" var="item" binding="#{deviceReferenceBean.deviceListDeviceReferencesTable}">
<UIColumn id="_idJsp325" rendered="true" transient="false">
<HtmlOutputText escape="true" id="_idJsp326" rendered="true" style="width:100%; height:30px; background-color:#f9f9f9" styleClass="DeviceReferenceTitleBarBorder" transient="false"/>
<HtmlPanelGrid border="-2147483648" columns="2" id="_idJsp327" rendered="#{item.hasHolderNameMasks}=true" transient="false">
<HtmlOutputText escape="true" id="_idJsp328" rendered="true" transient="false" value="Holder Name:"/>
</HtmlPanelGrid>
</UIColumn>
</HtmlDataTable>
</HtmlForm>
Upvotes: 0
Views: 3820
Reputation: 1108722
The culprit is here:
<h:dataTable
binding="#{item.holderNameMasksTable}"
>
The binding
(and id
) attributes of UI components are resolved during view build time (that moment when JSF parses the XHTML file into a component tree). However, the #{item}
is only available during view render time (that moment when JSF encodes the component tree to HTML output). Thus, there where you're using binding="#{item.xxx}"
would always fail because the #{item}
is null
. Note that this is exactly what the exception is trying to tell you.
You've 2 options:
binding
attribute altogether.#{deviceReferenceBean}
instead. It's available during view build time.Upvotes: 1