Datatable filter and paginator ajax functionality broken

UI Components for JSF
Post Reply
LawrenceWong
Posts: 2
Joined: 14 Sep 2014, 17:25

14 Sep 2014, 17:53

Hi guys,

I am using Primefaces 5.0 and JSF 2.2.

I have a datatable table that is working perfectly on a pure .xhtml.

However when I tried it with a template, the filter and paginator functionality did not work.

I can't click on the page 2 or page 3 buttons.

The filter did not work when I key in values.

It's like a static table. See image below. Data has been omitted from image.

Image

I went to google and found out that someone was facing the same problem.
http://stackoverflow.com/questions/1109 ... include-ta

But I heard switching over to JSF2.2 resolve the issue.

I have attached my codes below.

Any idea on how to resolve this problem? :)


Mypage.xhtml

Code: Select all

    <?xml version='1.0' encoding='UTF-8' ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                    xmlns:h="http://xmlns.jcp.org/jsf/html"
                    xmlns:f="http://xmlns.jcp.org/jsf/core"
                    xmlns:p="http://primefaces.org/ui"
                    template="./template/defaultMaster.xhtml"
                    >
        <h:head>
            <title>XXXXXXXXX</title>
        </h:head>
    
        <ui:define name="content">
    
            <div class="row wrapper border-bottom white-bg page-heading">
                <div class="col-lg-9">
                    <h2>Admin Panel</h2>
                    <ol class="breadcrumb"> 
                        <li class="active">
                            <strong>Audit Log Viewer</strong>
                        </li>
                    </ol>
                </div>
            </div>
            <div class="wrapper wrapper-content">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="ibox float-e-margins">
                            <div class="ibox-title">
                                <h5>Audit Log Viewer</h5>
                                <div class="ibox-tools">
                                    <a class="collapse-link">
                                        <i class="fa fa-chevron-up"></i>
                                    </a>
                                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                                        <i class="fa fa-wrench"></i>
                                    </a>
                                    <ul class="dropdown-menu dropdown-user">
                                        <li><a href="#">Config option 1</a>
                                        </li>
                                        <li><a href="#">Config option 2</a>
                                        </li>
                                    </ul>
                                    <a class="close-link">
                                        <i class="fa fa-times"></i>
                                    </a>
                                </div>
                            </div>
                            <div class="ibox-content">
                                <h:body>
                                    <p:panel header="View Audit Logs">
    
                                        <h:form id="formAllCustomers">
    
                                            <p:dataTable id="dataTableAllCustomers" value="#{auditLogBean.allLogs}" var="auditlog"  rows="25" paginator="true"
                                                         resizableColumns="true">
    
                                                <p:column filterBy="#{auditlog.logUser}" filterMatchMode="contains" sortBy="#{auditlog.logUser}" headerText="User" >
                                                    <h:outputText value="#{auditlog.logUser}" />
                                                </p:column>
    
                                                <p:column filterBy="#{auditlog.logTime}" filterMatchMode="contains" sortBy="#{auditlog.logTime}" headerText="Time stamp">
                                                    <h:outputText value="#{auditlog.logTime}" />
                                                </p:column>
    
                                                <p:column filterBy="#{auditlog.logDetails}" filterMatchMode="contains" sortBy="#{auditlog.logDetails}" headerText="Details">
                                                    <h:outputText value="#{auditlog.logDetails}" />
                                                </p:column>
    
                                            </p:dataTable>
                                            <p:commandButton value="Go to home" id="gohome" action="home" ajax="false" />
                                            <h:outputText value="#{facesContext.externalContext.getSessionId(true)}" />
                                        </h:form>
    
                                    </p:panel>
                                </h:body>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </ui:define>
    </ui:composition>
defaultMaster.xhtml

Code: Select all

    <?xml version='1.0' encoding='UTF-8' ?> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
          xmlns:h="http://xmlns.jcp.org/jsf/html"
          xmlns:f="http://xmlns.jcp.org/jsf/core"
          xmlns:p="http://primefaces.org/ui"
          xmlns:jsf="http://xmlns.jcp.org/jsf"
          xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
          >
    
        <ui:composition>
            <h:head>
                <h:outputStylesheet name="./css/bootstrap.min.css" />  
                <h:outputStylesheet name="./font-awesome/css/font-awesome.css" />
                <h:outputStylesheet name="./css/animate.css" />
                <h:outputStylesheet name="./css/style.css" /> 
                <h:outputStylesheet name="./css/morris-0.4.3.min.css" />
                <h:outputStylesheet name="./css/jquery.gritter.css" /> 
    
                <h:outputScript name="./js/jquery-1.10.2.js" />
                <h:outputScript name="./js/bootstrap.min.js" />
                <h:outputScript name="./js/jquery.metisMenu.js" />
    
         
            </h:head>
            <h:body>
                <f:view>
                    <h:form>
                        <p:idleMonitor timeout="10000">
                            <p:ajax event="idle" listener="#{idleMonitorView.onIdle()}"/>
                        </p:idleMonitor>
                    </h:form>
                </f:view>
            </h:body>
       ........................ code committed because it's too long 
                    <ui:insert name="content">Content</ui:insert>
                </div>
            </div>
        </ui:composition>
    
    </html>

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

15 Sep 2014, 12:00

Your defaultMaster template is the cause.
If you are using an IDE like NetBeans create a new JSF Template using it and check how the resulting XHTML looks.
Using ui:composition in a template is ok but only if that template is itself the client of a another template.
You don't need to do that here.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: jaircalistrato and 54 guests