I have upgraded my application from primefaces 3.4.2 to primefaces 5.1 and JSF 2.1.10 to 2.1.29 version.My below logic use to work with old jars but after upgrade its showing unexpected behaviour.
I have a commandLink which loads a dialog box onclick() event.Dialog box contains dynamic data table which will be populated by preLoadMethod in bean.
Before upgrade to new jars on click of commandLink the dialog box displays the search results in dynamic table properly with no issues.After upgrade to new jars dialog box displays "No records found." message instead of search results on click of commandLink.I have checked that data is available at client side by entering some value in filter box which shows the filtered data and after removing the filtered value I can see the complete search results.When I closed the dialog box and then again click the commandlink I can see the search results in the datatable and then after some seconds the content will be refreshed and it shows the message "No records found".
1)xhtml code....
<html>
....
....
<h:body>
....
<h:form>
...
<h:panelGroup id="panelGroupId">
<p:commandLink id="searchId" onclick="dialogVar.show()" process="@this" global="false"
action="#{bean.preLoadMethod}" update="@none">
<f:setPropertyActionListener target="#{bean.selectedSearchId}" value="7" />
<f:setPropertyActionListener target="#{bean.componentId}" value="ipComponent:searchForm_7:resultsTable" />
<h:graphicImage styleClass="rollover imgAligntop" style="border:0;" name="search_on.png" library="images" />
</p:commandLink>
<p:tooltip for="panelGroupId" value="Search"></p:tooltip>
</h:panelGroup>
...
</h:form>
.....
<p:dialog id="dialogId" hideEffect="fade" modal="true" widgetVar="dialogVar" resizable="false" appendTo="@(body)"
position="230,120" draggable="true" minimizable="false" maximizable="false" header="Dialog">
<custom:searchComponent id="ipComponent" dialogName="searchDialog" searchId="7">
</custom:searchComponent>
<p:ajax event="close" listener="#{bean.closeDialog}" global="false"/>
</p:dialog>
...
</h:body>
</html>
2)Bean code
public void preLoadMethod() {
//Gets the data from database and populates the List(searchDataList,filteredResults,columns)
which will be used by datatable to populate
FacesContext facesContext = FacesContext.getCurrentInstance();
DataTable dynamicDataTable = (DataTable) facesContext.getViewRoot().findComponent(componentId+"_"+selectedSearchId);
if(dynamicDataTable != null) {
lovDataTable.setEmptyMessage("No records found.");
}
RequestContext context = RequestContext.getCurrentInstance();
String arr[] = {componentId+"_"+selectedSearchId};
Collection<String> updateFields = Arrays.asList(arr);
whereClause = "";
context.update(updateFields);
}
3)searchComponent.xhtml
<html>
....
...
<composite:interface.....
<composite:attribute name="searchId" required="true" />
</composite:interface>
<composite:implementation>
<h:form id="searchForm_#{cc.attrs.searchId}" onsubmit="return false;">
----
<p:dataTable id="resultsTable_#{cc.attrs.searchId}" var="search" paginator="true" rows="10" value="#{bean.searchDataList}"
selectionMode="single" pageLinks="5" paginatorPosition="both" rowIndexVar="rowIndexVar"
paginatorTemplate="Page {CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
paginatorAlwaysVisible="true"
filteredValue="#{bean.filteredResults}"
widgetVar="searchTable_#{cc.attrs.searchId}"
emptyMessage="Data is loading please wait...">
<p:columns id="searchColumns" value="#{bean.columns}" var="column" sortBy="#{search[column.property]}"
filterBy="#{search[column.property]}"
rendered="#{fn:length(bean.searchDataList) gt 0}"
filterMatchMode="startsWith"
>
<f:facet name="header">
#{column.header}
</f:facet>
<h:outputText value="#{search[column.property]}" id="searchText" >
</h:outputText>
</p:columns>
</p:dataTable>
----
</h:form>
---
</composite:implementation>
</html>