Primefaces 2.2.M1 and @ViewScoped

UI Components for JSF
Post Reply
User avatar
townray
Posts: 37
Joined: 10 Dec 2009, 20:41

08 Sep 2010, 19:00

I upgraded my test application with primefaces 2.2.M1, but the "ViewScopeds ManagedBeans" pass by the constructor to all requests (ajax or non-ajax). Someone is going through the same problem? :?

I use Mojarra 2.0.2

thx.
Danilo G. Magrini - Brazil
http://twitter.com/daniloMagrini
Mojarra 2.0.3 / Glassfish v3 / Primefaces 2.2RC1 / Netbeans 6.9

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

08 Sep 2010, 20:36

ViewScope example is working at showcase;

http://www.primefaces.org/showcase/ui/pprCounter.jsf

Maybe you can try with mojarra-2.0.3 as showcase does.

User avatar
townray
Posts: 37
Joined: 10 Dec 2009, 20:41

08 Sep 2010, 22:36

I'll leave the reasons that caused me to have two forms in my application to don't make the post too long. I will then use a merely illustrative example.

Page code:

Code: Select all

        <p:outputPanel id="otp"
                       layout="block">
            <h:outputText value="Counter: #{mbTest.count}" />
            <h:form>
                    <p:commandButton value="Increment"
                                     actionListener="#{mbTest.increment}"
                                     update="otp"/>
            </h:form>
            <h:form>
                    <p:commandButton value="Decrement"
                                     actionListener="#{mbTest.decrement}"
                                     update="otp"/>

            </h:form>
        </p:outputPanel>
ManagedBean code:

Code: Select all

@ManagedBean(name = "mbTest")
@ViewScoped
public class MbTest implements Serializable {

    private int count;

    public MbTest() {
        System.out.println("CONSTRUCTOR EXECUTED!"); // Log is better =)
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public void increment() {
        count++;
    }

    public void decrement() {
        count--;
    }
}
Using version 2.1 of Primefaces everything works correctly. When I use the version 2.2.M1 the constructor is executed whenever alternate between the buttons. There seems to be a problem for Mojarra... or is it? :roll:
Danilo G. Magrini - Brazil
http://twitter.com/daniloMagrini
Mojarra 2.0.3 / Glassfish v3 / Primefaces 2.2RC1 / Netbeans 6.9

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

08 Sep 2010, 23:40

Instead of p:commandButton can you check with h:commandButton and f:ajax to see how it behaves? Thanks.

User avatar
townray
Posts: 37
Joined: 10 Dec 2009, 20:41

09 Sep 2010, 13:30

Same behavior. So we can say that the "problem" is in version 2.1 of primefaces... :?
Danilo G. Magrini - Brazil
http://twitter.com/daniloMagrini
Mojarra 2.0.3 / Glassfish v3 / Primefaces 2.2RC1 / Netbeans 6.9

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

09 Sep 2010, 23:23

So f:ajax and p:commandButton behave same in 2.2.M1? So yes 2.1 sounds like violating the JSF spec :)

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 38 guests