It may not be worth it.  Having multiple tabbed panels on the same
page may not be a very common usecase.  Perhaps it's better to settle
for YAGNI in this case and if it really does comes up and someone
wants to solve the issue, then address it then.  But, for now, a good
Javadoc warning might suffice.  It might not be worth cluttering up
the code (no idea what it'd take to fix).

On Tue, Mar 10, 2009 at 11:14 AM, Brill Pappin <br...@pappin.ca> wrote:
> That is exactly the problem I *do* have :)
> Have not resolved it yet, but I was thinking or allowing them to be nested
> to its actually one tab panel, but with multiple levels.
>
> - Brill
>
> On 10-Mar-09, at 8:41 AM, James Carman wrote:
>
>> What if you use two different tabbed panels on the same page?
>>
>> On Tue, Mar 10, 2009 at 8:27 AM, Christian Helmbold
>> <christian.helmb...@yahoo.de> wrote:
>>>
>>>> Since others seem to need it, this might be worth refining over on
>>>> wicket-stuff.
>>>
>>> I think it's worth to build a universal bookmarkable tabbed panel. Brill,
>>> please post your solution so we can look what is better in your or in my
>>> solution and built the ultimative BookmarkableTabbedPanel.
>>>
>>> I refined my first version a bit and added the following features:
>>> * Reliable handling of user input (tab number).
>>> * Possibility to mix bookmarkable and stateful links.
>>> * Parameter name to distinguish tabs is now the component id by default.
>>> This will avoid conflicts with multiple BookmarkableTabbedPanels.
>>>
>>> But I'm not sure if mixing bookmarkable and stateful links is a good
>>> idea.
>>>
>>> Current version:
>>>
>>> -----------------------------------------------------------------------------------------------------------
>>> package com.helmbold.wicket.components;
>>>
>>> import java.util.ArrayList;
>>> import java.util.List;
>>> import org.apache.wicket.PageParameters;
>>> import org.apache.wicket.extensions.markup.html.tabs.ITab;
>>> import org.apache.wicket.extensions.markup.html.tabs.TabbedPanel;
>>> import org.apache.wicket.markup.html.WebMarkupContainer;
>>> import org.apache.wicket.markup.html.link..BookmarkablePageLink;
>>>
>>>
>>> public class BookmarkableTabbedPanel extends TabbedPanel
>>> {
>>>
>>>   private PageParameters pageParameters;
>>>   private String tabParameterName;
>>>   private int defaultTabIndex = 0;
>>>  private List unbookmarkableTabIndex = new ArrayList();
>>>
>>>
>>>  /**
>>>  * Using this constructor the following defaults take effect:
>>>  * <ul>
>>>  *    <li>tabParameterName = component id</li>
>>>  *    <li>defaultTabIndex = 0</li>
>>>  * </ul>
>>>    * @param id component id
>>>    * @param tabs list of ITab objects used to represent tabs
>>>  * @param pageParameters Container for parameters to a requested page. A
>>>  * parameter for the selected tab will be inserted.
>>>    */
>>>  public BookmarkableTabbedPanel(
>>>         String id,
>>>         List<ITab> tabs,
>>>         PageParameters pageParameters)
>>>  {
>>>   super(id, tabs);
>>>   this.pageParameters = pageParameters;
>>>   this.tabParameterName = id;
>>>
>>>   if (pageParameters.containsKey(tabParameterName))
>>>   {
>>>     String tab = pageParameters.getString(tabParameterName);
>>>     try
>>>     {
>>>       setSelectedTab(Integer.parseInt(tab));
>>>     }
>>>     catch (NumberFormatException e)
>>>     {
>>>       setSelectedTab(defaultTabIndex);
>>>     }
>>>   }
>>>   else
>>>     setSelectedTab(defaultTabIndex);
>>>  }
>>>
>>>
>>>   /**
>>>    * @param id component id
>>>    * @param tabs list of ITab objects used to represent tabs
>>>    * @param defaultTabIndex Set the tab to by displayed by default. The
>>> url
>>>    * for this tab will not contain any tab specific information. If you
>>> want to
>>>    * display the first tab by default, you can use the constructor
>>> without this
>>>    * parameter.
>>>  * @param pageParameters Container for parameters to a requested page. A
>>>  * parameter for the selected tab will be inserted.
>>>    */
>>>   public BookmarkableTabbedPanel(
>>>       String id,
>>>       List<ITab> tabs,
>>>       int defaultTabIndex,
>>>       String tabParameterName,
>>>   PageParameters pageParameters,
>>>   int ...unbookmarkableTabIndex)
>>>   {
>>>       this(id, tabs, pageParameters);
>>>       this.defaultTabIndex = defaultTabIndex;
>>>       setSelectedTab(defaultTabIndex);
>>>       this.tabParameterName = tabParameterName;
>>>   for(int element : unbookmarkableTabIndex)
>>>     this.unbookmarkableTabIndex.add(element);
>>>   }
>>>
>>>
>>>   @Override
>>>  protected WebMarkupContainer newLink(String linkId, int index)
>>>  {
>>>   WebMarkupContainer link;
>>>
>>>   // create default (not bookmarkable) links for the specified tabs.
>>>   if (unbookmarkableTabIndex.contains(index))
>>>     link = super.newLink(linkId, index);
>>>   // create bookmarkable links
>>>   else
>>>   {
>>>     if (index == defaultTabIndex)
>>>       pageParameters.remove(tabParameterName);
>>>     else
>>>       pageParameters.put(tabParameterName, "" + index);
>>>     link = new BookmarkablePageLink(
>>>             linkId, getPage().getClass(), pageParameters);
>>>   }
>>>
>>>   if (index == getSelectedTab())
>>>     link.setEnabled(false);
>>>
>>>   return link;
>>>  }
>>>
>>> }
>>>
>>> -----------------------------------------------------------------------------------------------------------
>>>
>>>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>>> For additional commands, e-mail: users-h...@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to