1
votes

I am developing a fairly large web application. Suddenly the other day, primefaces ajax only work out once and then not work more.

This problem applies to all primefaces ajax call through the entire application.

I've tried everything and even tried to make a new jsf project in netbeans with the code that you see below. And the same thing, backbean method is called only once. I can see the call in the scriptconsolen firefox, but the backbean method is never called, I get no error.

What could this be caused by? If I replace the primefaces ajax call against the regular jsf ajax, it works.

My set:

  • NetBeans 7.3
  • JSF 2.2
  • PrimeFaces 3.5
  • GlassFish 3.1.2

I've also tried with the following set and get the same results:

  • Netbeans 7.4
  • JSF 2.2
  • PrimeFaces 3.5
  • GlassFish 4.0

add() only calls at first click. Backbean:

package temp;

import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean(name = "backbean")
@SessionScoped
public class Backbean implements Serializable{

    private int value = 0;
    private int temp = 0;

    public Backbean()
    {

    }

    public void setTemp(int temp)
    {
        this.temp = temp;
    }

    public int getTemp()
    {
        return temp;
    }

    public void add()
    {
       value += temp;
       temp = 0;
    }

    public void setValue(int value)
    {
        this.value = value;
    }

    public int getValue()
    {
        return value;
    }


}

View:

<?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://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>

    </h:head>
    <h:body>

            <h:form>
                <h:inputText value="#{backbean.temp}"/>
                <h:outputText value="#{backbean.value}"/>


                <h:commandButton value="Test" type="button">
                   <p:ajax listener="#{backbean.add()}"  update="@form" process="@form" />
                </h:commandButton>
            </h:form>

    </h:body>
</html>

solution: I tried to replace the primefaces 3.5 the primefaces 4.0 and then worked ajax calls as they should.

Why?

1
Out of sheer curiosity, why are you still using PrimeFaces 3.5? 5.0 was released a few months ago.RevanProdigalKnight
Yes the solution was to use a higher version of the prime faces, would rather avoid having to redo the charts that are 3.5 dependingJohan Nordli

1 Answers

1
votes

Depend on what you are trying to achieve here, If you want to use JSF h:commandButton then replace p:ajax with f:ajax and add action="#{backbean.add()}" to your h:commandButton (removed the listener) from your p:ajax and replace the update with render and process with execute

If you want to use p:commandButton than remove the p:ajax and add the action="#{backbean.add()}" update="@form" process="@form" to your p:commandButton

In general: Use <p:ajax inside primefaces components and use <f:ajax inside pure JSF components