Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8320823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:47:39+00:00 2026-06-08T22:47:39+00:00

I have problem to let user know about exceptions occurred in PrimeFaces LazyDataModel#load method.

  • 0

I have problem to let user know about exceptions occurred in PrimeFaces LazyDataModel#load method.

I am loading there data from database and when an exception is raised, I have no idea how to inform the user about it.

I tried to add FacesMessage to FacesContext, but message is not shown on the Growl component, even if Growl is set to autoUpdate="true".

Using PrimeFaces 3.3.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T22:47:41+00:00Added an answer on June 8, 2026 at 10:47 pm

    It doesn’t work because load() method is invoked during Render Response phase (you can check this by printing FacesContext.getCurrentInstance().getCurrentPhaseId()), when all messages have already been processed.

    The only workaround that worked for me is to load the data within the “page” event listener of the DataTable.

    html:

    <p:dataTable value="#{controller.model}" binding="#{controller.table}">
         <p:ajax event="page" listener="#{controller.onPagination}" />
    </p:dataTable>
    

    Controller:

    private List<DTO> listDTO;
    private int rowCount;
    private DataTable table;
    
    private LazyDataModel<DTO> model = new LazyDataModel<DTO>() {
            @Override
            public List<DTO> load(int first, int pageSize, String sortField,
                    SortOrder sortOrder, Map<String, String> filters) {
                setRowCount(rowCount);
                return listDTO;
            }
        };
    
    public void onPagination(PageEvent event) {
        FacesContext ctx = FacesContext.getCurrentInstance();
        Map<String, String> params = ctx.getExternalContext()
                .getRequestParameterMap();
    
        // You cannot use DataTable.getRows() and DataTable.getFirst() here,
        // it seems that these fields are set during Render Response phase
        // and not during Update Model phase as one can expect.
    
        String clientId = table.getClientId();
        int first = Integer.parseInt(params.get(clientId + "_first"));
        int pageSize = Integer.parseInt(params.get(clientId + "_rows"));
    
        try {
            listDTO = DAO.query(first, pageSize);
            rowCount = DAO.getRowCount();
        } catch (SQLException e) {
            ctx.addMessage(null,
                    new FacesMessage(FacesMessage.SEVERITY_ERROR,
                        "SQL error",
                        "SQL error"));
        }
    }
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've run into this problem with testing. Let's assume I have two models, User
The problem: let's say I have two tables Client , and Product , in
The underlying problem - let's say my documents have categories and timestamps . If
I have a problem with Facebook. Let me explain what I'm trying to do.
I have a problem with the Microsoft EnterpriseLibrary validation framework. Let's say we have
I have a problem that I can't resolve. Let's say I have this map
I have a problem with forwarding to a .jsp page. Let me describe my
Here is my problem: I have an array of model class(Let's say, 'addressModel' with
I have some kind of problem with jQuery selectors. Let's say i want to
Let's say we have two concave 2d polygons(A, B), that don't intersect. The problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.