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 7946577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:11:42+00:00 2026-06-04T01:11:42+00:00

I am developing application with JSF 2.0 and Primefaces 3.2, I am running into

  • 0

I am developing application with JSF 2.0 and Primefaces 3.2, I am running into the following problem:
ActionListeners not invoked if the content is loaded dynamically with ajax request.

Main layout:

<div id="content">
    <h:form name="content_form" id="content_form">
        <ui:insert name="content" />
    </h:form>
</div>

Index page (contents are loaded dynamically based on menu actions):

<ui:composition template="layout.xhtml">
    <ui:define name="content">
        <ui:include src="#{ajaxViewBean.viewName}" /> 
    </ui:define>
</ui:composition>

Menu actions is generated as follows:

        FacesContext context = FacesContext.getCurrentInstance();
        MethodExpression methodExpression = context
                .getApplication()
                .getExpressionFactory()
                .createMethodExpression(
                        context.getELContext(),
                        "#{ajaxViewBean.setViewName('" + navItem.getUrl()
                                + "')}", null,
                        new Class[] { ActionEvent.class });
        displayMenuItem.setUpdate(":content_form");
        displayMenuItem
                .addActionListener(new MethodExpressionActionListener(
                        methodExpression));

Upon clicking menu items it call AjaxViewBean “Request scope” to set the current view page and update the “content_form” in the main layout

Included Pages (in which action listener not working)

  • First Try – File Upload (uploadFile.xhtml)

    <h:body>
    <h:form enctype="multipart/form-data">
    
        <p:fileUpload fileUploadListener="#{fileUploadController.handleFileUpload}"  
                      mode="advanced"  
                      update="messages"   
                      multiple="true"  
                      sizeLimit="100000"   
                      allowTypes="/(\.|\/)(gif|jpe?g|png)$/"/>  
    
        <p:growl id="messages" showDetail="true"/>  
    </h:form>
    

    fileUploadController is never invoked.
    If I requested the uploadfile.xhtml directly, or included it on the first load, I can upload the file so I am sure that upload is working file and everything is configured correctly in web.xml.

  • Second Try – Menu action listener in the include page

    <h:body>
    <h:form>
        <p:menu type="tiered" style="width:180px">
            <p:submenu label="Ajax Menuitems" icon="ui-icon-refresh">
                <p:menuitem value="Save"
                    actionListener="#{ajaxViewBean.setViewName()}" update="messages"
                    icon="ui-icon-disk" />
                <p:menuitem value="Update" actionListener="#{buttonBean.update}"
                    update="messages" icon="ui-icon-arrowrefresh-1-w" />
            </p:submenu>
        </p:menu>
    </h:form>
    

    Also the event in action listener is never firing, although it’s firing in the main page with is generated dynamically from the code mentioned above

Maven Dependencies:

<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-api</artifactId>
    <version>2.1.4</version>
</dependency>
<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-impl</artifactId>
    <version>2.1.4</version>
</dependency>
<dependency>
    <groupId>javax.servlet.jsp.jstl</groupId>
    <artifactId>jstl-api</artifactId>
    <version>1.2</version>
</dependency>
<dependency>
    <groupId>com.sun.facelets</groupId>
    <artifactId>jsf-facelets</artifactId>
    <version>1.1.14</version>
</dependency>
<dependency>
    <groupId>javax.el</groupId>
    <artifactId>el-api</artifactId>
    <version>2.2</version>
</dependency>
<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>el-impl</artifactId>
    <version>2.2</version>
</dependency>
<dependency>
    <groupId>org.primefaces</groupId>
    <artifactId>primefaces</artifactId>
    <version>3.2</version>
</dependency>
<dependency>
    <groupId>commons-fileupload</groupId>
    <artifactId>commons-fileupload</artifactId>
    <version>1.2.2</version>
</dependency>
<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.3</version>
</dependency>  

Can someone please advice if I am missing something, or how can I solve this ?

Actually this is my first post in Stackoverflow, so I hope that I made myself clear and the format is not messed up

  • 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-04T01:11:44+00:00Added an answer on June 4, 2026 at 1:11 am

    Fixed!, and I am posting the answer (maybe can be useful for someone)
    Steps as follows:

    • Make sure there’s no violation as per this URL: commandButton/commandLink/ajax action/listener method not invoked or input value not updated
    • Use Partial status saving method as false as per this URL: http://balusc.blogspot.com/2011/09/communication-in-jsf-20.html

      <context-param>
        <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
        <param-value>false</param-value>
      </context-param>
      

    Something to highlight:

    • Globally disabling the partial state saving has however the disadvantage that the view state size will grow in size. So if you’re using server side state saving method, then the server’s memory usage will increase, or if you’re using client side state saving method, then the network bandwidth usage will increase. Basically, you get the same view state information as it was in JSF 1.x. If possible, you can also just disable the partial state saving on a per-view basis by the following context parameter in web.xml
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

we're developing an application using JSF 2.0 (primefaces) and Hibernate 3.6.1 We're following the
I am developing a Java enterprise application and I am usign JSF, mostly Primefaces.
I'm developing a web application using Spring, JSF 2 and Primefaces 3. I want
I am developing an application with JSF and PrimeFaces. I have a managed been,
I'm developing an application in JSF 2.0. I'm also using the Primefaces component library.
I am developing a Java web application using Hibernate and JSF/primefaces. am sometimes getting
I am developing a web application based on JSF technology. I use Eclipse as
I am developing a Java Web Application using JSF, Spring and Hibernate. I need
I'm developing a JSF web application, with the current 2.1.7 JSF version . Actually,
I'm developing a file upload with JSF. The application saves three dates about the

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.