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

  • SEARCH
  • Home
  • 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 7969433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:14:11+00:00 2026-06-04T07:14:11+00:00

I have PrimeFaces dataTable that is been filled by a Ajax call. When I

  • 0

I have PrimeFaces dataTable that is been filled by a Ajax call.

When I click on a column title, to order its values, the values disappear.

<p:commandButton value="Pesquisar" actionListener="#{requestController.listRequests}" update="dataTable" />

Here is my view:

<p:dataTable id="dataTable" var="order" value="#{requestController.backing.requestsList}"
                         paginator="true" rows="10"
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}">
                <p:column sortBy="#{order.companyRequest}">
                    <f:facet name="header">
                        <h:outputText value="Pedido" />
                    </f:facet>
                    <h:outputText value="#{order.companyRequest}" />
                </p:column>

                <p:column sortBy="#{order.company.companyName}">
                    <f:facet name="header">
                        <h:outputText value="Cliente" />
                    </f:facet>
                    <h:outputText value="#{order.company.companyName}" />
                </p:column>

                <p:column sortBy="#{order.emissionDate}">
                    <f:facet name="header">
                        <h:outputText value="Data" />
                    </f:facet>
                    <h:outputText value="#{order.emissionDate}">
                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                    </h:outputText>
                </p:column>
                <p:column sortBy="#{order.requestSituation.description}">
                    <f:facet name="header">
                        <h:outputText value="Status" />
                    </f:facet>
                    <h:outputText value="#{order.requestSituation.description}" />
                </p:column>
                <p:column>
                    <f:facet name="header">
                    </f:facet>
                    <h:form>
                        <h:commandLink value="Detalhes"/>
                    </h:form>
                </p:column>
            </p:dataTable>

EDIT

RequestController

@ManagedBean
@RequestScoped
public class RequestController implements Serializable
{

    private RequestBacking backing;

    public RequestController()
    {
        backing = new RequestBacking();
    }

    public void changeEventListener(ValueChangeEvent e)
    {
        backing.requestSearchType = e.getNewValue().toString();
    }

    public void change()
    {
        switch (backing.requestSearchType)
        {
            case "data":
                backing.mask = "99/99/9999";
                backing.maskSize = "10";
                break;
            case "cnpj":
                backing.mask = " 99.999.999/9999-99";
                backing.maskSize = "20";
                break;
            default:
                backing.mask = "";
                backing.maskSize = "50";
        }
    }

    public void listRequests() throws ParseException
    {

        CompanyVO companyVO = new CompanyVO();
        switch (backing.requestSearchType)
        {
            case "cnpj":
                companyVO.setCnpj(backing.requestSearchValue);
                break;
            case "cliente":
                companyVO.setCompanyName(backing.requestSearchValue);
                break;
            case "pedido":
                backing.requestVO.setCompanyRequest(Integer.parseInt(backing.requestSearchType));
                break;
        }
        SupplierVO supplierVO = new Support().getUserSession().getSupplier();
        backing.requestVO.setEmissionDate(new Support().convertDate(backing.requestSearchValue));
        backing.requestVO.setSupplier(supplierVO);
        backing.requestVO.setCompany(companyVO);

        backing.requestsList = new ArrayList<>(backing.getBo().getRequest(backing.requestVO));

        if (backing.requestsList.isEmpty())
        {
            FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, "Nenhum registro encontrado!", null);
            FacesContext.getCurrentInstance().addMessage(null, facesMessage);
            backing.requestsList = null;
        }
    }

..backing getter and setter
}

My requestsList is on my RequestBacking where I have all my getters and setters, please correct me if there is a better way of doing this, I’m using it because it leaves my controller cleaner.

public List<RequestVO> requestsList;
  • 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-04T07:14:11+00:00Added an answer on June 4, 2026 at 7:14 am

    Apparently the value="#{requestController.backing.requestsList}" didn’t return the same value as it did on the initial request. That can happen if it’s a request scoped bean and/or if the requestsList is populated on every request based on a request based variable.

    That’s just a design mistake. Put the managed bean in the view scope and make sure that you aren’t doing any business logic in a getter method. The nested class backing is also suspicious or it must be a poor naming.

    See also:

    • Why JSF calls getters multiple times
    • How to choose the right bean scope?

    Update in a nutshell, your bean should look something like this:

    @ManagedBean
    @ViewScoped
    public class Orders {
    
        private String query; // +getter +setter
        private List<Order> results; // +getter (no setter required)
    
        @EJB
        private OrderService service;
    
        public void search() {
            results = service.search(query);
        }
    
        // Add/generate normal getters/setters (don't change them!)
    }
    

    and your view should look like this:

    <h:form>
        <p:inputText value="#{orders.query}" />
        <p:commandButton value="Search" action="#{orders.search}" update=":tableForm" />
    </h:form>
    <h:form id="tableForm">
        <p:dataTable value="#{orders.results}" var="order" ... rendered="#{not empty orders.results}">
            ...
        </p:dataTable>
        <h:outputText value="No results found" rendered="#{facesContext.postback and empty orders.results}" />
    </h:form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a non-editable DataTable built with PrimeFaces. The table is initially filled with
I have a h:dataTable that displays ProfileNotification like below: <h:dataTable value=#{myBean.profileNotifications} var=item rendered=#{myBean.renderProfileNotification}> <h:column>
I have a PrimeFaces dataTable that gets refreshed on actions of various controls of
I have a inputTextarea that I refresh using PrimeFaces' AJAX poll. When the inputTextarea
I have an application that contains commandLinks within a Primefaces dataTable. The commandLinks link
I have a question regarding primefaces datatable component. I want to bind a DataTable
I am new to jQuery. I have PrimeFaces dataTable. when it is converted to
I have a modal ConfirmDialog that is shown over a modal Dialog using PrimeFaces
I have a primefaces datatable: <p:dataTable id=idCrawledDataTable var=crawledData value=#{crawlerCorpusTreatmentBean.crawledDataModel} rowKey=#{crawledData.id} rows=10 scrollable=true scrollHeight=300 selection=#{crawlerCorpusTreatmentBean.crawledData}
Primefaces Datatable let you configure the filtering type you use for a column, using

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.