users@woodstock.java.net

Re: dynamically adding components to page and Ajax issue

From: Dan Labrecque <Dan.Labrecque_at_Sun.COM>
Date: Mon, 04 Feb 2008 12:12:23 -0500

Have you tried using a session scoped bean? Once you add the button to
the JSF component tree, via your link action listener, it should be able
to handle actions regardless if Ajax is used. However, if the bean is
request scoped, the button will not be decoded because it was never
found in the JSF component tree.

Dan

autozoom wrote:
> hello,
> I have this scenario:
> my page contains a number of links, each of which is used to dynamically add
> components to the page, with a code snippet like this:
>
> Button button = new Button();
> JSFActionManager.setValueExpression(button, "text", "#{Page1.txt}");
> button.setStyle("left: 115px; top: 448px; position: absolute;");
> form1.getChildren().add(button);
>
> I call this code from the links' action listener.
>
> Now I found out that these dynamically created components don't react to
> Ajax functions like refresh() because, I think, the listener is called after
> the page's init().
>
> (if you try and add the code snippet to the init() method, the component
> correctly reacts to a client side resfresh() call)
>
> Then, how can I achieve this result? The action listener is *always* called
> after init(), when it's already too late to add components to the page. Does
> this mean that I cannot use Ajax function on these dynamically added
> components?
>
> Please let me know if my guess is right, I hope not.
>
> Thanks
> Mauro
>