Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9064777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:20:24+00:00 2026-06-16T16:20:24+00:00

I am using JSF 2.0 and Primefaces 3.4.2, I have a datatable populated using

  • 0

I am using JSF 2.0 and Primefaces 3.4.2, I have a datatable populated using lazy load.

When I view scope for managedbean, then datatable selectedRow gives null pointer exception.
If I use session scope then I could get selectedRow in managedbean.

I am using CDI Spring annotations for specifying scope. I have used this method to create view scope.

Update 1

I have noticed another thing is using view scope when I paginate to second page and then comes back to first page, then I could get the selectedRow. If I select a row without paginating then I get null pointer exception.

JSF Page

<p:dataTable id="dataTable" var="req" lazy="true" value="#{emp.lazyModel}"
                paginator="true" rows="10" 
                             selection="#{emp.selectedRequest}"
                            selectionMode="single">                         
          <p:ajax event="rowSelect" listener="#{emp.onRowSelect}" />  

ManagedBean

@Named("emp")
@Scope("view")
public class EmployeesManagedBean implements Serializable {

    @PostConstruct
    public void init() {
        initTable();
    }

    private void initTable() {
        lazyModel = new LazyRequestDataModel(requestList, requestService);
    }

    public LazyDataModel<Employee> getLazyModel() {
        return lazyModel;

    }

I am getting nullpointer exception at this line in onRowSelect method

 Emp emp = (Emp) event.getObject()); 
 System.out.println(emp.getEmpNo() );

Full error stacktrace

java.lang.NullPointerException
    at net.test.managed.bean.RequestManagedBean.onRowSelect(RequestManagedBean.java:134)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.sun.el.parser.AstValue.invoke(AstValue.java:187)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
    at org.primefaces.component.behavior.ajax.AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxBehaviorListenerImpl.java:52)
    at org.primefaces.event.SelectEvent.processListener(SelectEvent.java:40)
    at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:106)
    at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:760)
    at javax.faces.component.UIData.broadcast(UIData.java:1071)
    at javax.faces.component.UIData.broadcast(UIData.java:1093)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T16:20:26+00:00Added an answer on June 16, 2026 at 4:20 pm

    I have managed to resolve this issue by using @ViewAccessScoped which is supported in CDI. Add the dependency in maven or directly download from http://myfaces.apache.org/extensions/cdi/download.html and put it in classpath.

    <dependency>
        <groupId>org.apache.myfaces.extensions.cdi.core</groupId>
        <artifactId>myfaces-extcdi-core-api</artifactId>
        <version>1.0.5</version>
        <scope>compile</scope>
    </dependency>
    

    One small problem still remains i.e. when application is deployed for the first time, I still do not get selected row value, for the subsequent selections I am able to get selected row value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSF+Primefaces 3.2 application. I am using p:rowExpansion within a p:dataTable. In
I am using PrimeFaces 2.2, with JSF 2.0.3. I have an xhtml view that
I have implemented a login form using JSF and PrimeFaces. I used this example
I'm using JSF 2.0 and PrimeFaces library. I have a page with several inputs
I am using PrimeFaces 3.2 with JSF 2 in a glassfish 3.1.2. I have
I have a problem using JSF 2.0, PrimeFaces and the tuckey.org UrlRewriteFilter. The problem
i am using jsf 2.1.1 and primefaces 3.0.M4. i have a sample jsf page
I have web application in which I am using JSF + Primefaces for UI.
I am using Primefaces 3.2 with jsf 2 and glassfish 3.1.2. I have a
I'm using primefaces 3.3.1 and JSF 2 (Mojarra 2.1.9). I have a page with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.