re-load p:dataTable Lazy data got Exception!!

UI Components for JSF
Post Reply
kman
Posts: 57
Joined: 03 Nov 2010, 09:21
Location: Hong Kong

02 Dec 2010, 09:06

I need to reload/refresh p:DataTable's data at back-end Bean before the process went to front-end for re-rendering (i.e. the "Render Response" JSF request-processing-lifecycle).

However, always got the following exception:

Code: Select all

com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback visit
Severe: java.lang.ArithmeticException: / by zero

The case can be simulated while user clicked the button "Refresh MyDataTable" to invoke a refresh:

My Code: font-end xhtml:

Code: Select all

<h:form id="myFrm1">
    <p:commandButton title="Refresh MyDataTable"
        image="ui-icon ui-icon-refresh" type="submit" ajax="true" process="this"
        action="#{myBean.refreshMyDataTableData}"
        update="myFrm2:pnlgDummy" />
</h:form>

<h:form id="myFrm2">
    <h:panelGroup id="pnlgDummy">
        <p:dataTable widgetVar="myDataTable" value="#{myBean.dataTableLazyData}"
            var="record" paginator="true" rows="15" pageLinks="20" lazy="true" dynamic="true">
        </p:dataTable>
    </h:panelGroup>
</h:form>
My Code: back-end Bean, already set to "@SessionScoped":

Code: Select all

public void refreshMyDataTableData()
{
    this.dataTableLazyData = new LazyDataModel<EntityObjectClass>()
    {
        private static final long serialVersionUID = 1L;
    
        public List<Employee> load( int first, int pageSize, String sortField, boolean sortOrder, Map<String, String> filters )
        {
            this.setRowCount( getEntityObjectDbConnector().getAllRowCount() );
            return getEntityObjectDbConnector().getAll( first, pageSize );
        }
    } ;
}

Are there anything I was wrong?

My library used:
PrimeFaces 2.2 RC2 + Sun Mojarra 2.0.3 FCS (b03) + Sun GlassFish JSTL 1.2.
PrimeFaces 3.0M1, Sun Mojarra 2.0.4 FCS, Sun GlassFish JSTL 1.2,
Apache Log4J 1.2.16, EclipseLink 2.1.1.v20100817-r8050,
Eclipse Helios

lobz
Posts: 21
Joined: 17 Nov 2010, 13:49
Location: Hungary

02 Dec 2010, 13:16

I tried this approach too (reseting the datamodel) but it just does not work in PrimeFaces.

The right method I think is to call the resetPagination then the loadLazyData methods of the datatable itself.

kman
Posts: 57
Joined: 03 Nov 2010, 09:21
Location: Hong Kong

03 Dec 2010, 04:28

under the lack of a proper PrimeFaces Developer Manual articulating all the APIs, we can just dig something out more day-by-day by trial-and-error way, so painful indeed... and we had spent so many effort and time searched around the web for solution by googling (in return gave me result at PrimeFaces's forum)...

yes, lobz, seems resetPagination() and the loadLazyData() can stop our thirst but think it's not a proper solution totally.

in addition, following might be considered also, as referenced to the thread ["No records found." in <p:datatable>should not be selectable]: http://primefaces.prime.com.tr/forum/vi ... f=3&t=5131:
//Load lazy data initially
if(table.isLazy() && !table.initiallyLoaded()) {
table.loadLazyData();
table.markAsLoaded();
}
anyway, following threads collections will give us such short-term painkiller solution:
PrimeFaces 3.0M1, Sun Mojarra 2.0.4 FCS, Sun GlassFish JSTL 1.2,
Apache Log4J 1.2.16, EclipseLink 2.1.1.v20100817-r8050,
Eclipse Helios

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 43 guests