0

I was able to see data in the datatable before adding the lazy attribute. After I added the lazy attribute, the datatable is empty, because my debug points were never reached which are inside the load method of LazyDataModel. In other words load method is not called, I see the control until this.searchResults in my search()

I just get my results from web services (which work just fine) I have looked at most of the links here and here. I made sure the lazy attribute and setRowCount are set. May be someone can help me out to figure out the problem. I am using PrimeFaces 6.0, CDI, JSF 2.2, Deltaspike 1.7.2

Here is my JSF

    // other input form fields
    <p:panel style="border-style : none;" styleClass="panelClass">
        <h:panelGrid columns="2">
            <!-- <h:commandButton action="#{search.search}" value="Search" styleClass="button_small_white" /> -->
            <p:commandButton action="#{search.search}" ajax="true" update=":mainform:searchResultTable" value="Search" styleClass="button_small_white" />
            <h:commandButton action="#{search.clear}" value="Clear" styleClass="button_small_white" />                  
        </h:panelGrid>
    </p:panel>
    <br /><p:dataTable value="#{search.searchResults}" var="rec" 
                        rowKey="rec.numTxt"
                        paginator="true" rows="10" 
                        paginatorTemplate=" Display {RowsPerPageDropdown} Records   {FirstPageLink} 
                        {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}  "
                        rowsPerPageTemplate="10,25,50,100" 
                        paginatorPosition="top"  
                        rendered="#{not empty search.searchResults}"
                        id="searchResultTable"
                        widgetVar="searchTable" 
                        lazy="true" 
                        summary="RE Search Results are shown below">

                <p:ajax event="page" listener="#{search.search}" update=":mainform:searchResultTable"  />            
                <p:column headerText="">
                    <p:selectBooleanCheckbox value="#{rec.select}" />
                </p:column>
                ...
            </p:dataTable>  

Controller

@Named("search")
@Stateful
@GroupedConversationScoped
@ConversationGroup(SearchGrp.class)
public class ReSearchController extends BaseWebServicesSearchController<ReSearchSummary>
    implements ReGrp, ReSearchControllerLocal {


@Inject
private GroupedConversation conversation;

@Inject
private WindowContext windowContext;

private LazyDataModel<ReSearchSummary> searchResults;

...

@PostConstruct 
@Override
public void init() {
    // code for initializing my web services
    search();
}

@Override
public String search(){

    this.searchResults = new LazyDataModel<ReSearchSummary>() {

        private static final long serialVersionUID = 4168363870903585956L;

        @Override
        public List<ReSearchSummary> load(int first, int pageSize, String sortField, SortOrder sortOrder,
                Map<String, Object> filters) {

            List<ReSearchSummary> resultsList = null;

            resultsList = search(first, pageSize);

            // rowCount
            setRowCount(getResultCount());
            // I do not need sorting oor filters os did not use them

            return resultsList;
        }
    };
    searchResults.setRowCount(getResultCount());
    return "/cr-re-search.xhtml?faces-redirect=true";
}

@Override
public ArrayList<ReSearchSummary> search(int first, int pageSize){
    // this is my webservice call, this works fine if I call it indepedently
    // criteria gets the form inputs
    return doSearch(criteria.getForm(), pageSize, first);
}
...
}

Update: Converted h:commandButton to p:commandButton for the search button

<p:commandButton action="#{search.search}" ajax="true" update=":mainform:searchResultTable" value="Search" styleClass="button_small_white" />

And added p:ajax inside p:dataTable

<p:ajax event="page" listener="#{search.search}" update=":mainform:searchResultTable"  />
Avinash Moram
  • 67
  • 2
  • 13
  • Start, for finding the root cause, by dropping these: `@Stateful @GroupedConversationScoped @ConversationGroup(SearchGrp.class)` and since you are not using ajax, use @SessionScoped. And your search() redirects to a (different?) page. Weird construct... Simplify and see if it works then (it does in the PrimeFaces showcase) – Kukeltje Jun 08 '17 at 20:00
  • @Kukeltje I need all of them, this is part of migration from seam, we still want to retain the EJB and use and we are replacing the seam conversations with deltaspike ones, but I will still try to remove them and give it a try. My search returns to the same page, that was a redundant thing I have to remove. – Avinash Moram Jun 08 '17 at 21:07
  • Why not use ajax then for the update of the datatable? – Kukeltje Jun 08 '17 at 21:15
  • I have edited the code to try ajax, but the control still doesn't go into the load method. – Avinash Moram Jun 08 '17 at 22:02

0 Answers0