0

I had problems with Primefaces rating component, so I created a simple example to narrow down the problem source:

Bean:

@ViewScoped
@ManagedBean
public class TestBean {
    private int rating;

    public void onrate(RateEvent rateEvent) {
        int rate = (int) rateEvent.getRating();
        this.rating = rate;
    }
    ...
}

Page:

<html ...>
    <h:body>
        <ui:composition template="./template.xhtml">
            <ui:define name="content">
                Rating = #{testBean.rating}
                <p:rating value="#{testBean.rating}">
                    <f:param name="sessionId" value="5"/>
                    <p:ajax event="rate" listener="#{testBean.onrate}"/>
                </p:rating>
            </ui:define>
        </ui:composition>
    </h:body>
</html>

When I click any of the stars, the rateEvent.getRating() value is 0. Previously I had this problem with the @RequestScoped bean, but the problem remains even now with the wider scope.

What might be the problem?

Thanks.

vtomic85
  • 590
  • 1
  • 11
  • 32

0 Answers0