I am working on a JSF project. It's using JSF-2 version.
I have a test.xhtml
which includes another XHTML, below is the code:-
<ui:include src="/WEB-INF/genericTag.xhtml" >
<ui:param name="cache" value="ProjectQueryCache"></ui:param>
</ui:include>
I passed ProjectQueryCache value via the variable cache. In the genericTag.xhtml
is having below piece of code:-
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<p:dataTable id="genericId" var="queryRow"
value="#{genericManagedBean.fetchQueryList()}" style="margin-bottom:40px"
scrollable="true" scrollWidth="100%" scrollHeight="350" rows="10"
paginator="true"
paginatorTemplate="{Previous} {Next} " >
<f:facet name="header">
<h:outputText value="Projects" style="font-weight:bold; font-size:16; color:#336699"/>
</f:facet>
<f:facet name="{Previous}">
<p:commandButton value="Previous" actionListener="#{genericDatatableManagedBean.previous()}" />
</f:facet>
<f:facet name="{Next}">
<p:commandButton value="Next" actionListener="#{genericDatatableManagedBean.next()}" />
</f:facet>
<f:param name="cacheName" id="cacheName" value="#{cache}" />
<p:column headerText="Project id" sortBy="#{queryRow.project_id}" filterBy="#{queryRow.project_id}"
filterMatchMode="contains" width="100" style="font-size:9PT">
<h:outputText value="#{queryRow.project_id}" />
</p:column>
<p:column headerText="Project name" sortBy="#{queryRow.project_name}" filterBy="#{queryRow.project_name}"
filterMatchMode="contains" width="100" style="font-size:9PT">
<h:outputText value="#{queryRow.project_name}" />
</p:column>
</p:dataTable>
</ui:composition >
But in the managedBean GenericManagedBean
of the genericTag.xhtml, I am not getting the value of variable #{cache} in f:param
, it's always coming as null.
Below is the managedBean code,
@ManagedBean(name = "genericManagedBean")
@SessionScoped
public class GenericManagedBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = -1L;
public void fetchQueryList() {
try {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
Map<String, String> params = externalContext.getRequestParameterMap();
String name = params.get("cacheName");
System.err.println(name);
System.out.println("fetchQueryList() - ended....");
} catch (Exception e) {
Throwable cause = e.getCause();
throw new ELException(cause);
}
}
}
Please suggest to me how to fix this issue. I checked this answer already here, f:param is null in bean jsf , but it's not working for me. Any help?