I've opened a JIRA[1] for improving TabbedPanel to support multiple panels per page. I'll try and submit a patch over the next few days.
Bob [1]: https://issues.apache.org/jira/browse/CLK-753 On 2011/02/16 09:56 AM, Bob Schellink wrote: > Or rather only one TabbedPanel per page is supported. There are at least two > problem areas: > > - the internal ActionLink is simply called "tabLink", thus clicking on a tab > will be processed by > all TabPanels. My guess is that the tabLink should have the TabbedPanel name > appended to it's own > name to differentiate between different panels on the page > - a special parameter called tabPanelIndex can be used to programmatically > switch tabs. Again this > parameter needs to be namespaced properly > > If someone wants to work on this feature please open a JIRA and patch and we > can include it for > 2.3.0 final. > > Kind regards > > Bob > > On 2011/02/15 23:34 PM, Bob Schellink wrote: >> Looking at TabbedPanel code it doesn't look like nested panels is supported. >> The fact that it worked >> in 2.1.0 seems somehow based on the fact that stateful pages are used. >> >> There was an optimization in 2.2.0 so that only the active panel gets >> processed, not all panels as >> in 2.1.0. The issue was that Panel implementations could be expensive and >> access the DB, so only >> processing the active Panel makes sense. This optimization however exposes >> the issue you are running >> into. >> >> You could put together your own proper nested TabbedPanel or customize >> TabbedPanel by overriding >> initActivePanel() and removing the two lines which deactivates all panels: >> >> // panel.setActive(false); >> >> Hope this helps. >> >> Kind regards >> >> Bob >> >> >> On 2011/02/15 18:21 PM, sdiener wrote: >>> >>> Thanks Bob! >>> >>> I am using stateful pages, so I appreciate the warning about 2.3.0. I'll >>> make sure I keep that in mind going forward. >>> >>> I'm afraid I don't quite understand what you're suggesting about adding the >>> inner panel to the outer panel :-( . I created a simplified version of my >>> problem: >>> >>> -------- >>> SamplePage.java (the main page that contains the outer TabbedPanel >>> containing Tab 1 and Tab 2: >>> public class SamplePage extends Page { >>> >>> private TabbedPanel tabbedPanel = new TabbedPanel("tabbedPanel"); >>> private Tab1Panel tab1Panel; >>> private Tab2Panel tab2Panel; >>> >>> public SamplePage() { >>> setStateful(true); >>> >>> tab1Panel = new Tab1Panel("tab1Panel", "Tab 1"); >>> tab2Panel = new Tab2Panel("tab2Panel", "Tab 2"); >>> >>> tabbedPanel.add(tab1Panel); >>> tabbedPanel.add(tab2Panel); >>> >>> addControl(tabbedPanel); >>> } >>> } >>> >>> -------- >>> Sample.htm: >>> <html> >>> <head> >>> $headElements >>> </head> >>> <body> >>> $tabbedPanel >>> $jsElements >>> </body> >>> </html> >>> >>> -------- >>> Tab1Panel.java (The first tab of the outer TabbedPanel that contains it's >>> own TabbedPanel containing Tab 3 and Tab 4): >>> public class Tab1Panel extends Panel { >>> private TabbedPanel tab1TabbedPanel = new >>> TabbedPanel("tab1TabbedPanel"); >>> private Tab3Panel tab3Panel; >>> private Tab4Panel tab4Panel; >>> >>> public Tab1Panel(String name, String label) { >>> super(name, "/sample/Tab1Panel.htm"); >>> setLabel(label); >>> >>> tab3Panel = new Tab3Panel("tab3Panel", "Tab 3"); >>> tab4Panel = new Tab4Panel("tab4Panel", "Tab 4"); >>> >>> tab1TabbedPanel.add(tab3Panel); >>> tab1TabbedPanel.add(tab4Panel); >>> >>> add(tab1TabbedPanel); >>> } >>> } >>> >>> -------- >>> Tab1Panel.htm: >>> $tab1TabbedPanel >>> >>> -------- >>> Tab2Panel.htm (The second tab of the outer TabbedPanel, just contains a >>> Submit button with a print statement): >>> public class Tab2Panel extends Panel { >>> Form form = new Form("form"); >>> Submit theButton = new Submit("theButton", "Click Me", this, >>> "onClickTheButton"); >>> public Tab2Panel(String name, String label) { >>> super(name, "/sample/Tab2Panel.htm"); >>> setLabel(label); >>> >>> form.add(theButton); >>> >>> add(form); >>> } >>> >>> public boolean onClickTheButton() { >>> System.out.println("The button in Tab 2 was clicked"); >>> return true; >>> } >>> } >>> >>> -------- >>> Tab2Panel.htm: >>> $form >>> >>> -------- >>> Tab3Panel.java (The first tab of the inner TabbedPanel, contains a Submit >>> button with a print statement): >>> public class Tab3Panel extends Panel { >>> Form form = new Form("form"); >>> Submit theButton = new Submit("theButton", "Click Me", this, >>> "onClickTheButton"); >>> public Tab3Panel(String name, String label) { >>> super(name, "/sample/Tab3Panel.htm"); >>> setLabel(label); >>> >>> form.add(theButton); >>> >>> add(form); >>> } >>> >>> public boolean onClickTheButton() { >>> System.out.println("The button in Tab 3 was clicked"); >>> return true; >>> } >>> } >>> >>> -------- >>> Tab3Panel.htm: >>> $form >>> >>> -------- >>> Tab4Panel.java (The second tab of the inner TabbedPanel, just contains a >>> Submit button with a print statement): >>> public class Tab4Panel extends Panel { >>> Form form = new Form("form"); >>> Submit theButton = new Submit("theButton", "Click Me", this, >>> "onClickTheButton"); >>> public Tab4Panel(String name, String label) { >>> super(name, "/sample/Tab4Panel.htm"); >>> setLabel(label); >>> >>> form.add(theButton); >>> >>> add(form); >>> } >>> >>> public boolean onClickTheButton() { >>> System.out.println("The button in Tab 4 was clicked"); >>> return true; >>> } >>> } >>> >>> --------- >>> Tab4Panel.htm: >>> $form >>> >>> ----------------------------------- >>> >>> >>> Below is an image of what these TabbedPanels look like initially: >>> >>> http://click.1134972.n2.nabble.com/file/n6028187/tabbedPanelSample.jpg >>> >>> >>> ----------------------------------- >>> >>> In Click 2.1.0, this works perfectly. I can click Tab 4 and the Tab4Panel >>> is displayed. However, if I run this same sample using Click 2.2.0, when I >>> click Tab 4 nothing happens. >>> >>> If I get a reference to the inner TabbedPanel, "tab1TabbedPanel", from >>> Tab1Panel and use addControl to add it to SamplePage, I can get >>> functionality back in the tabs ... but unfortunately when I click the Submit >>> buttons in the individual Panels, the "onClickTheButton" method is called >>> twice. So, this workaround isn't quite right. >>> >>> Based on my sample code, I was hoping that you could tell me if I had made a >>> huge error somewhere that is causing my problems, or if perhaps there is a >>> workaround I could use with Click 2.2.0 to restore the correct functionality >>> I was seeing in Click 2.1.0. >>> >>> Thanks again! >> >> > >
