Re: AW: AW: Tabbed Panel with bookmarkable links

2009-04-29 Thread Vladimir K

But it is also a bug in the TabbedPanel which should work well without tabs.


Christian Helmbold-2 wrote:
 
 
  What if you use two different tabbed panels on the same page?
 
 
 Good point! It doesn't work with two panels on the same page! I don't
 know why 
 and how to fix it.
 
 It was a mistake in my test code, that lead to this error. I accidentally
 added the tabs of my second tabbed panel to the first one. Multiple
 BookmarkableTabbedPanels work fine now.
 
 Regards
 Christian
 
 
 
 
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Tabbed-Panel-with-bookmarkable-links-tp22418170p23295407.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



AW: AW: Tabbed Panel with bookmarkable links

2009-03-12 Thread Christian Helmbold

The development of the bookmarkable tabbed panel component is continued on 
http://wicketskunkworks.org. We decided to use a Google Code project for now 
but we plan to make the final component available via wicket stuff or maybe in 
the extensions tree of the core distribution (i don't know if there is any 
relation between wicketstuff and the extensions of the core framework).

Regards
Christian






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



Re: AW: Tabbed Panel with bookmarkable links

2009-03-12 Thread Martijn Dashorst
Why start yet another project when the intention is to move it to stuff anyway?

Martijn

On Thu, Mar 12, 2009 at 12:22 PM, Christian Helmbold
christian.helmb...@yahoo.de wrote:

 The development of the bookmarkable tabbed panel component is continued on 
 http://wicketskunkworks.org. We decided to use a Google Code project for now 
 but we plan to make the final component available via wicket stuff or maybe 
 in the extensions tree of the core distribution (i don't know if there is any 
 relation between wicketstuff and the extensions of the core framework).

 Regards
 Christian






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





-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.5 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

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



Re: AW: Tabbed Panel with bookmarkable links

2009-03-12 Thread Brill Pappin
I don't think we know that it will be moved... right now we only know  
that we two need it.


- Brill

On 12-Mar-09, at 7:28 AM, Martijn Dashorst wrote:

Why start yet another project when the intention is to move it to  
stuff anyway?


Martijn

On Thu, Mar 12, 2009 at 12:22 PM, Christian Helmbold
christian.helmb...@yahoo.de wrote:


The development of the bookmarkable tabbed panel component is  
continued on http://wicketskunkworks.org. We decided to use a  
Google Code project for now but we plan to make the final component  
available via wicket stuff or maybe in the extensions tree of the  
core distribution (i don't know if there is any relation between  
wicketstuff and the extensions of the core framework).


Regards
Christian






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






--
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.5 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

-
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



Re: AW: Tabbed Panel with bookmarkable links

2009-03-11 Thread Jeremy Thomerson
Use wicket-stuff.  It makes sense for this.  You might even consider just
adding this to minis in WS.
http://wicket-stuff.svn.sourceforge.net/viewvc/wicket-stuff/trunk/wicketstuff-core/minis-parent/

--
Jeremy Thomerson
http://www.wickettraining.com



On Tue, Mar 10, 2009 at 10:25 AM, Christian Helmbold 
christian.helmb...@yahoo.de wrote:


  Instead of competing, why don't we set up a project some place and check
 both
  solutions in under different packages?
  We can then refactor them into one and take the best of both :)

 I agree. Is there an existing place in the wicket project to do this?

 I've discovered some troubles in my solution when multiple tabbed panes are
 used in one page. The state of other panels is not hold correctly in the
 URLs and so the tabbed panels influence each other.





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




AW: Tabbed Panel with bookmarkable links

2009-03-10 Thread Christian Helmbold

 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
   *litabParameterName = component id/li
   *lidefaultTabIndex = 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,
  ListITab 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, 
ListITab 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



AW: AW: Tabbed Panel with bookmarkable links

2009-03-10 Thread Christian Helmbold

  What if you use two different tabbed panels on the same page?

 
 Good point! It doesn't work with two panels on the same page! I don't know 
 why 
 and how to fix it.

It was a mistake in my test code, that lead to this error. I accidentally added 
the tabs of my second tabbed panel to the first one. Multiple 
BookmarkableTabbedPanels work fine now.

Regards
Christian






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



Re: AW: Tabbed Panel with bookmarkable links

2009-03-10 Thread Brill Pappin
Instead of competing, why don't we set up a project some place and  
check both solutions in under different packages?

We can then refactor them into one and take the best of both :)

- Brill

On 10-Mar-09, at 8:27 AM, Christian Helmbold 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
  *litabParameterName = component id/li
  *lidefaultTabIndex = 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,
 ListITab 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,
   ListITab 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



AW: AW: Tabbed Panel with bookmarkable links

2009-03-10 Thread Christian Helmbold

 Instead of competing, why don't we set up a project some place and check both 
 solutions in under different packages?
 We can then refactor them into one and take the best of both :)

I agree. Is there an existing place in the wicket project to do this?

I've discovered some troubles in my solution when multiple tabbed panes are 
used in one page. The state of other panels is not hold correctly in the URLs 
and so the tabbed panels influence each other. 





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



AW: Tabbed Panel with bookmarkable links

2009-03-10 Thread Christian Helmbold

The problem is that the tabbed panels have to know the state of other panels to 
generate correct stateful links. So we need some object that keeps track of all 
tabbed panels and their states. This object must be initialized before the 
newLink method is called. But this method is called during construction, so it 
can not know other tabbed panels when the first tabbed panel is constructed.

This object can be pageParameters. The only problem is, that this object 
doesn't reflect the actual state in every case, because it is also used for url 
construction. The solution is to remove items from pageParameters after url 
construction if they don't reflect the state.

And here comes the solution. It is now possible to use multiple 
BookmarkableTabbedPanels within one page.



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
   *litabParameterName = component id/li
   *lidefaultTabIndex = 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,
  ListITab 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, 
ListITab 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);
  
  /* Overwrite tabIndexes only used for link cunstruction, but doesn't
   * reflect the actual state.
   */
  if (index != getSelectedTab())
pageParameters.put(tabParameterName,  + getSelectedTab());
}

if (index == getSelectedTab())
  link.setEnabled(false);

return link;
  }
  
}


Regards
Christian






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



AW: AW: Tabbed Panel with bookmarkable links

2009-03-10 Thread Christian Helmbold

In my code were two little bugs. If the constructor with parameter 
defaultTabIndex was used, the active tab was always set to this value 
regardless what tab the use clicked on. The other issue affected the specified 
parameter name that stores the active tab. It did not work in the constructor 
chain. This problem could be solved by rearrangement of constructors or by 
simple remove this parameter. I've choosen the last possibility to keep thinks 
simple.

 I post my corrected code again here, becaus someone could find it with a 
search engine and I don't want left him alone with broken code. The further 
development will be better placed in a code repository.

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
   *litabParameterName = component id/li
   *lidefaultTabIndex = 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,
  ListITab tabs,
  PageParameters pageParameters)
  {
super(id, tabs);
this.pageParameters = pageParameters;
this.tabParameterName = id;
System.err.println(pageParameters);
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.
   * @param unbookmarkableTabIndex Indexes of tabs with standard (no
   * bookmarkable) links. First tab has index 0.
 */
public BookmarkableTabbedPanel(
String id, 
ListITab tabs,
int defaultTabIndex,
PageParameters pageParameters,
int ...unbookmarkableTabIndex) 
{
this(id, tabs, pageParameters);
this.defaultTabIndex = defaultTabIndex;
if (!pageParameters.containsKey(tabParameterName))
  setSelectedTab(defaultTabIndex);
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); // keep URLs short
  else
pageParameters.put(tabParameterName,  + index);
  link = new BookmarkablePageLink(
  linkId, getPage().getClass(), pageParameters);
  
  /* Overwrite parameters only used for link cunstruction, but doesn't
   * reflect the actual state.
   */
  if (index != getSelectedTab())
pageParameters.put(tabParameterName,  + getSelectedTab());
}

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



Re: AW: AW: Tabbed Panel with bookmarkable links

2009-03-10 Thread Brill Pappin
Yes, because you no longer have the previous state... I have the same  
problem, but maybe some ideas for a solution.


- Brill

On 10-Mar-09, at 11:25 AM, Christian Helmbold wrote:



Instead of competing, why don't we set up a project some place and  
check both

solutions in under different packages?
We can then refactor them into one and take the best of both :)


I agree. Is there an existing place in the wicket project to do this?

I've discovered some troubles in my solution when multiple tabbed  
panes are used in one page. The state of other panels is not hold  
correctly in the URLs and so the tabbed panels influence each other.






-
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