Is the PF 5.2.1 DataTable Selection attribute broken?

UI Components for JSF
Post Reply
RElliott
Posts: 94
Joined: 07 Feb 2014, 00:39

04 May 2015, 03:39

I upgraded from PrimeFaces 5.1.13 to 5.2.1 this weekend and noticed that my dialog in which I search for and select a user is broken. The following is my dialog that works correctly in 5.1.13 but sets editorUser to null in PrimeFaces 5.2.1.

Code: Select all

<p:dialog
    header="Enter Search"
    widgetVar="user-select-dialog"
    modal="true">
    <h:form id="user-search-form">
        <pm:field>
            <p:outputLabel
                value="User Name:"
                for="user-name" />
            <p:inputText
                id="user-name"
                value="#{userSelector.userName}"
                label="User Name Search"
                pt:autofocus="true">
            </p:inputText>
            <p:commandButton
                icon="ui-icon-search"
                styleClass="ui-nodisc-icon elis-button"
                actionListener="#{userSelector.updateLazyUsers}"
                process="@form"
                update="@form :#{p:component('users-table')}" />
        </pm:field>
    </h:form>
    <h:form id="user-select-form">
        <p:dataTable
            id="users-table"
            value="#{userSelector.lazyUsers}"
            var="user"
            rowKey="#{user.id}"
            selection="#{userCreater.user.editorUser}"
            selectionMode="single"
            lazy="true"
            rows="10"
            tableStyleClass="ui-table-columntoggle">
            <p:ajax
                event="rowSelect"
                process="@form"
                update=":#{p:component('editorUser')}"
                oncomplete="PF('user-select-dialog').hide();" />
            <p:column
                headerText="User Name"
                priority="1">
                <h:outputText value="#{user.name}" />
            </p:column>
            <p:column
                headerText="Descripton"
                priority="2">
                <h:outputText value="#{user.description}" />
            </p:column>
        </p:dataTable>
    </h:form>
</p:dialog>
PrimeFaces 7.0.1, Glassfish 5.1.0, Oracle JDK 8, Eclipse 2016-02

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

06 May 2015, 03:07

Errors?

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

12 May 2015, 14:13

no errors?

RElliott
Posts: 94
Joined: 07 Feb 2014, 00:39

14 May 2015, 23:42

I apologize for the delay. I have been out of the office for the last week.

I verified that I am still having the issue with PrimeFaces 5.2.2. The following is the full stack track that I receive after selecting a row from my table:

Code: Select all

javax.el.ELException: /security/ELISUserCreater.xhtml @258,61 selection="#{elisUserCreater.user.editorUser}": java.lang.NullPointerException
	at com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:139)
	at org.primefaces.component.datatable.DataTable.processUpdates(DataTable.java:727)
	at javax.faces.component.UIForm.processUpdates(UIForm.java:281)
	at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:577)
	at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
	at javax.faces.component.UIForm.visitTree(UIForm.java:381)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
	at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:403)
	at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:266)
	at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:60)
	at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:1252)
	at com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.java:78)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282)
	at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
	at java.lang.Thread.run(Thread.java:745)
Caused by: javax.el.ELException: java.lang.NullPointerException
	at javax.el.BeanELResolver.setValue(BeanELResolver.java:447)
	at com.sun.faces.el.DemuxCompositeELResolver._setValue(DemuxCompositeELResolver.java:255)
	at com.sun.faces.el.DemuxCompositeELResolver.setValue(DemuxCompositeELResolver.java:281)
	at com.sun.el.parser.AstValue.setValue(AstValue.java:252)
	at com.sun.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:294)
	at org.jboss.weld.el.WeldValueExpression.setValue(WeldValueExpression.java:64)
	at com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:131)
	... 46 more
Caused by: java.lang.NullPointerException
	at com.elliottlogic.elis.ejb.core.ELISEntity.setEditorUser(ELISEntity.java:114)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at javax.el.BeanELResolver.setValue(BeanELResolver.java:442)
	... 52 more
PrimeFaces 7.0.1, Glassfish 5.1.0, Oracle JDK 8, Eclipse 2016-02

RElliott
Posts: 94
Joined: 07 Feb 2014, 00:39

25 May 2015, 17:44

After the PrimeFaces 5.2.3 release, I decided to dig into this issue to figure out why my selection dialog works with 5.1.13 and and not with any of the 5.2.x releases. I eventually discovered that the root cause of the problem was buried in the LazyDataModel's getRowData(String rowKey) method.

The following is my original method that works in 5.1.13 but not 5.2.x. The reason that it does not work is that the .equals method on my Long ID does not match the rowKey String passed to the method and therefore the method always returns null.

Code: Select all


    @Override
    public ELISUser getRowData(String rowKey) {
        for (ELISUser user : users) {
            if (user.getId().equals(rowKey)){
                return user;
            }
        }
        return null;
    }	

The following is my new code that works in 5.2.x.

Code: Select all

    @Override
    public ELISUser getRowData(String rowKey) {
        for (ELISUser user : users) {
            if (user.getId().equals(new Long(rowKey))){
                return user;
            }
        }
        return null;
    }		
My guess is that the LazyDataModel changed the string value slightly that it passes to the getRowData which resulted in the Long.equals not matching the passed in String.
PrimeFaces 7.0.1, Glassfish 5.1.0, Oracle JDK 8, Eclipse 2016-02

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 36 guests