Preserving extendeddatatable nested in tabpanel
rednose Nov 28, 2011 9:33 AMI want to create a web application that works similiar to a file explorer like dolphin, where you can have several tabs that contain tables to display some files. But when resizing the column width it comes to an error. To do so I create a page using this code
{code:xml}
<h:form id="tabsForm">
<rich:tabPanel
id="tabPanel"
switchType="ajax"
itemChangeListener="#{yTabPanelBean.activeItemChanged}"
activeItem="#{yTabPanelBean.selectedTab}">
<rich:tab
name="t1"
header="tab 1">
<rich:extendedDataTable>
<rich:column>
<f:facet name="header">header</f:facet>
</rich:column>
</rich:extendedDataTable>
</rich:tab>
<rich:tab
name="t2"
header="tab 2">
<rich:extendedDataTable>
<rich:column>
<f:facet name="header">header2</f:facet>
</rich:column>
</rich:extendedDataTable>
</rich:tab>
</rich:tabPanel>
</h:form>
{code}
and
{code}
@ManagedBean
@SessionScoped
public class YTabPanelBean {
private String selectedTab = "t1";
public Object getSelectedTab() { return selectedTab;}
public void setSelectedTab(Object selectedTab) { this.selectedTab = (String) selectedTab;}
public void activeItemChanged(ItemChangeEvent event) {
FacesContext
.getCurrentInstance()
.getExternalContext()
.log("YTabPanelBean.activeItemChanged: \n\t" + event.getOldItemName()
+ " ---> " + event.getNewItemName());
setSelectedTab(event.getNewItemName());
}
}
{code}
The error can be created following this
One of the tabs is selected
then I resize the column width of the displayed table
then I switch to the other tab
then I resize the column of the new table
and see an NullPointerException thrown in SortingFilteringRowsRenderer.updateAttribute(). However when refreshing the page after switching tabs no exception is thrown.
Is there something wrong with my code?
updateAttribute() is called from ExtendedDataTableRenderer.updateWidthOfColumns(). When I observe this method I can see that 'widthEntry' carries an id. I inspected the ids in both cases, when the application is running without showing an error (i.e. with refreshing) in comparison to the other case with error and found that there must be the problem.
In case the exception will be thrown its still the id that corresponds to the previously selected tab.
Do I have to change something or is it richfaces? Any suggestion?