ActionListener not attaching when from dynamic components

UI Components for JSF
Post Reply
tonico
Posts: 51
Joined: 22 Aug 2010, 00:15

14 Jun 2011, 14:10

Direct to the point, a commandButton or commandLink that resides inside a dynamically generated (binding) component is not getting attached to its respective ActionListener. Te same commandButton or commandLink gets attached to the ActionListener if statically defined in XHTML rather than from dynamic binding.

Question: Anyone experienced this ? Any visible/potential cause ?

Two buttons on a page:

button "a" ) statically defined in xhtml
button "b" ) derived from dynamic binding within a panel

Code: Select all

<p:outputPanel id="mainContent" rendered="true">
                   <mylib:selectorButton attrib_a="111" attrib_b="222" attrib_c="333" />
                   <p:panel binding="#{myBean.myDynamicPanel}" />                                
</p:outputPanel>
The button "b" in question is from the same type (mylib:selectorButton) and is just within the p:panel, with nothing else, and is simply generated dynamically by the following. The final HTML code of both buttons ( a and b ) is identical, except for the IDs.

Code: Select all

public UIComponent getComponent() {

            org.primefaces.component.panel.Panel uiPrimePanel = new org.primefaces.component.panel.Panel();
            uiPrimePanel.setId("blah123");
            uiPrimePanel.setRendered(true);
            uiPrimePanel.setHeader("test panel");

            MyLibButton testButton = new MyLibSelectorButton(this.facesContext, "111", "222", "333");

            uiPrimePanel.getChildren().add(testButton.getComponent());

            return uiPrimePanel;
}
In the end, one button is outside the panel and generated statically ( XHTML ) while the other through the above binding. When I click on the first button I can see on my logs a call to my ActionListner, but clicking the second button (dynamicall binding) it will not execute the ActionListener at all. Analyzing this through FIreBug I can see no validationFailed issues ( but are not failing ) and the posted content and responses are exactly the same. Overall, no data differences within any ajax communication exist. All I can think of is that somehow, because the second button was dynamic, something on the server side is not processing to attach ActionListeners to the IDs of related dynamic components.

The issue is not specific to only binding. If the bound component is outside a panel, it will work. As soon as it is inside a container such as a primefaces TabView or Panel, it will not work anymore.

Any help/hint/suggestion will be greatly appreciated. Thanks.
- Tonico
Primefaces 2.2.1 - Glassfish 3.1 - Mac OS X Lion

Urbiwanus
Posts: 27
Joined: 25 Apr 2011, 10:36

01 Sep 2011, 11:34

I have the same problem

I want to build a math. function builder, which generates an editable formula inside a backing bean

Did you find any solution yet ?

regards

Urbiwanus
Posts: 27
Joined: 25 Apr 2011, 10:36

02 Sep 2011, 11:28

Hi I figured following out

New Components must be created via

Code: Select all

FacesContext.getCurrentInstance().getApplication().createComponent(type)
i.e.

Code: Select all

FacesContext.getCurrentInstance().getApplication().createComponent(MenuButton.COMPONENT_TYPE)
The actionListener gets invoked as long as i dont clear the childlist of the parent component

For my scenario i need an empty child list
Does anyone have an idea

Regards

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 35 guests