2 Replies Latest reply on Nov 21, 2008 4:24 PM by Brendon Davidson

    Dynamic tabbed form?

    Brendon Davidson Newbie


      I am currently trying to implement a dynamic tabbed form, but am experiencing some issues getting the data on the backend.

      I have a New Widget form. A widget consists of a name and a collection of items. For the collection of items, I would like a tabpanel where each tab represents an item (an item just has a name as well). A new Item link should cause a new tab to appear on the tab panel containing the inputtext for the name of that item.

      So, in my form, I start with an empty tabpanel and bind it to #{tabBean.itemTabs}. I also have an a4j:commandLink (the new item link) underneath the tabpanel with action set to #{widgetController.addItem}. I have another bean (widgetBean) that represents the new widget and contains a List of all the items in that widget. widgetBean is Serializable so that I can save its state with a4j:keepAlive.

      widgetController.addItem adds a new item to the list in widgetBean (widgetBean.items) and then calls tabBean.build which rebuilds the HtmlTabPanel tabBean.itemTabs based on the items in widgetBean.items (using setValueExpression to bind the new inputtext to widgetBean.items.name). The new item link has reRender set to reRender the tabPanel.

      So, this much actually works. Clicking the add item link adds a new tab to the tabpanel containing an inputtext.

      The problem is that the viewroot is never updated and therefore, i cannot get the data from the dynamically created form fields when the form is submitted. I hope that wasn't too confusing.

      Any help would be greatly appreciated.