webtier@glassfish.java.net

Re: Programmatic CommandButton+action method

From: <webtier_at_javadesktop.org>
Date: Wed, 08 Jul 2009 06:47:05 PDT

Your managed bean is request scoped, so a new instance is created for every request, which means that the init method (annotated with @PostConstruct) is invoked each time the button is pressed.

In this example you could simply remove the @RequestScoped annotation from the TestBean. Or you could clear the children of the pn component before adding the button.

[code]
pn.getChildren().clear();
pn.getChildren().add(btTest);
[/code]

/j
[Message sent by forum member 'janderssn' (janderssn)]

http://forums.java.net/jive/thread.jspa?messageID=354653