Datatable facet header is not displayed using PrimeFaces Mobile

842 Views Asked by At

I use inside a PrimeFaces Mobile page a dataTable where I set a header which is not displayed. In the normal page (not mobile) it works like in the documentation described.

Example

...
<f:view renderKitId="PRIMEFACES_MOBILE" />
...
<h:body>

<h:form>
    <p:dataTable var="item" value="#{eintraege.getLazyModel(null)}"
        paginator="true" rows="20" selectionMode="single"
        selection="#{eintraege.selected}" rowKey="#{item.id}"
        id="table-auftrag" lazy="true"
        emptyMessage="Keine Einträge gefunden" filteredValue="#{item}"
        widgetVar="eintragTable" sortBy="#{item.datumFormated}"
        sortOrder="descending">

        <p:ajax event="rowSelect" listener="#{eintraege.openMobile}" />

        <f:facet name="header">
            <p:outputPanel>
                <p:inputText id="globalFilter"
                    onkeyup="PF('eintragTable').filter()"
                    placeholder="Suchbegriff eingeben" style="width: 100%" />
            </p:outputPanel>
        </f:facet>

        <p:column headerText="" id="image">
            <h:outputLink value="#{request.contextPath}/mobile/eintrag.xhtml"
                rendered="#{item.hasImage()}">
                <f:param name="id" value="#{item.id}" />
                    <p:graphicImage value="/images/thumb?id=#{item.id}" />
            </h:outputLink>
        </p:column>

...

EDIT: changed "c:" to "f:"

UPDATE Today I wrote a little dirty workaround to solve this problem for the meantime to go online with the mobile page.

I added an new inputText with a onkeyup event which updates the dataTable. Additionally i have to change the lazy loading method a little bit to insert the value from the inputText which is now outside of the dataTable.

The page:

<p:inputText id="globalFilter" onkeyup="PF('eintragTable').filter()"
    placeholder="Suchbegriff eingeben" />

<p:dataTable ...

The LazyDataModel class:

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

...

if (filters.keySet().isEmpty()) {
    UIComponent component = FacesContext.getCurrentInstance()
        .getViewRoot().findComponent("form:globalFilter");
    if (component != null) {
        Object value = component.getAttributes().get("value");
        filters.put("globalFilter", value);
    }
}
0

There are 0 best solutions below