does the breadcrumb extension support bookmarkable links?

2012-01-18 Thread Daniel Watrous
I've been working with the breadcrumb components in the extensions
library today. Now that I have it working the way I need it to, I
noticed that none of the links are bookmarkable. I wondered if it were
possible to use this feature and still have links be bookmarkable?

I did some searching and found only a handful of references to
creating bookmarkable pages instead of panels, but before I went too
far down that road I wanted to ask if it's possible and straight
forward.

Thanks,
Daniel

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



Re: Absolute urls, bookmarkable links and web server proxy

2011-12-23 Thread infiniter
Actually the Apache rules are already set, but my issue is a bit different: I
need the bookmarkable links to show the required urls now.. These urls may
be even point to a different domain, but I don't want to be too invasive by
replacing my BookmarkablePageLinks with ExternalLinks.
I was thinking of overriding BookmarkablePageLink#getURL() or overriding
RequestCycle#urlFor()


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Absolute-urls-bookmarkable-links-and-web-server-proxy-tp4229418p4229802.html
Sent from the Users forum 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



Re: Absolute urls, bookmarkable links and web server proxy

2011-12-23 Thread Igor Vaynberg
apache rewrite rules are probably the easiest route

-igor

On Fri, Dec 23, 2011 at 10:12 AM, infiniter  wrote:
> After migrating part of a website, which is in multiple platforms, the
> business requires the urls to be preserved, which are different from the new
> ones...
> E.g.:
> New url: http:/www.example:8080/app/customer/john
> Required url: http:/www.example/john
>
> Basically the web server routes the urls to the new app, however I now need
> to make all my bookmarkable links show those absolute urls.
> Any recommendation?
>
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/Absolute-urls-bookmarkable-links-and-web-server-proxy-tp4229418p4229418.html
> Sent from the Users forum 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
>

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



Absolute urls, bookmarkable links and web server proxy

2011-12-23 Thread infiniter
After migrating part of a website, which is in multiple platforms, the
business requires the urls to be preserved, which are different from the new
ones...
E.g.:
New url: http:/www.example:8080/app/customer/john
Required url: http:/www.example/john

Basically the web server routes the urls to the new app, however I now need
to make all my bookmarkable links show those absolute urls.
Any recommendation?

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Absolute-urls-bookmarkable-links-and-web-server-proxy-tp4229418p4229418.html
Sent from the Users forum 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



Markup for BookMarkable links

2010-08-30 Thread Mike Dee

I'm coming up to speed on Wicket and came across something interesting that
seems somewhat basic.

I see a lot of examples in books and on the web that demonstrate the markup
for a bookmarkable link like this:

   # Search 

The code would be something like this:

  add( new BookmarkablePageLink( "searchLink", Search.class ) );

The page appears, with the link.  Clicking on the link does nothing.

Interestingly, removing the HREF attribute works. So the markup is this:

   Search 

Could the problem be:
a) Something in Wicket changed and some of the documentation is out of date?
b) The books and examples are just wrong?
c) Or am I a moron and doing something else wrong?


-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Markup-for-BookMarkable-links-tp2400422p2400422.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



Re: Bookmarkable Links & Session

2010-03-16 Thread Mauro Ciancio
Anteoine,
  thanks for the reply. It worked great.

Cheers.

On Tue, Mar 16, 2010 at 5:21 PM, Antoine van Wel
 wrote:
> When you have a stateless page, no session is created when you land on
> such a page first, or to be more precise: a temporary session is
> created. So that should explain the difference you see.
>
> Calling Session.get().bind() when logging in should fix that.
>
> Better, call Session.get().replaceSession() when logging in, that
> should both solve your problem and fix a potential security hole.
>
>
>
> Antoine
>
>
> On Tue, Mar 16, 2010 at 8:32 PM, Mauro Ciancio  wrote:
>> Hello everyone,
>>
>>  I'm developing an application that uses a lot of bookmarkable links
>> in order to
>> get pretty urls. When I log in with my user&password, I'm redirected
>> to the home page. This
>> behavior is ok, but the session appears to be not created, so i still see the
>> login link (and not the welcome message 'you are logged in').
>>
>>  However, if before login I browse a page that contains state and
>> then i go to the login page,
>> it works well.
>>
>> I guess the session is not being created, but it should be created
>> when I try to login.
>>
>> Any ideas?
>> Cheers.
>> --
>> Mauro Ciancio 
>>
>> -
>> 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
>
>



-- 
Mauro Ciancio 

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



Re: Bookmarkable Links & Session

2010-03-16 Thread Antoine van Wel
When you have a stateless page, no session is created when you land on
such a page first, or to be more precise: a temporary session is
created. So that should explain the difference you see.

Calling Session.get().bind() when logging in should fix that.

Better, call Session.get().replaceSession() when logging in, that
should both solve your problem and fix a potential security hole.



Antoine


On Tue, Mar 16, 2010 at 8:32 PM, Mauro Ciancio  wrote:
> Hello everyone,
>
>  I'm developing an application that uses a lot of bookmarkable links
> in order to
> get pretty urls. When I log in with my user&password, I'm redirected
> to the home page. This
> behavior is ok, but the session appears to be not created, so i still see the
> login link (and not the welcome message 'you are logged in').
>
>  However, if before login I browse a page that contains state and
> then i go to the login page,
> it works well.
>
> I guess the session is not being created, but it should be created
> when I try to login.
>
> Any ideas?
> Cheers.
> --
> Mauro Ciancio 
>
> -
> 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



Bookmarkable Links & Session

2010-03-16 Thread Mauro Ciancio
Hello everyone,

  I'm developing an application that uses a lot of bookmarkable links
in order to
get pretty urls. When I log in with my user&password, I'm redirected
to the home page. This
behavior is ok, but the session appears to be not created, so i still see the
login link (and not the welcome message 'you are logged in').

  However, if before login I browse a page that contains state and
then i go to the login page,
it works well.

I guess the session is not being created, but it should be created
when I try to login.

Any ideas?
Cheers.
-- 
Mauro Ciancio 

-
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-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



Re: Passing hidden parameters / bookmarkable links

2009-04-15 Thread Jeremy Thomerson
You can't - it's either in the URL and accessible or not.  If you only want
to pass the group name, then the group name needs to be unique so that you
can look it up.  Otherwise, you have to pass the ID and the name.  At that
point, the name is just for SEO or prettyness - whatever - because the ID is
what you'll have to use.

You can also do something like foo.com/group/234-groupName

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



On Wed, Apr 15, 2009 at 9:10 AM, Henrique Boregio wrote:

> I am developing a system that has "groups" and want to make them
> accesible via user-friendly urls such as
>
> www.mysite.com/group/GROUPNAME
>
> On a web page, I have a list of groups which are all links to their
> group pages, such as:
> www.mysite.com/group/groupA
> www.mysite.com/group/groupB
> ...
>
> This is implemented as such:
> PageParameters parameters = new PageParameters();
> parameters.put("groupName", aGroup.getName());
> add(new BookmarkablePageLink("groupName", GroupHomePage.class,
> parameters));
>
> and also mounting a BookmarkablePage in my Wicket Application
> mountBookmarkablePage("/groups", GroupHomePage.class);
>
> and in my GroupHomePage class, I have:
> public GroupHomePage (final PageParameters parameters) {
>
>String groupName = parameters.getString("groupName");
>int groupId = GroupDAO.getGroupId(groupName);
> }
>
> So as you can see, I basically retrieve the groupName and go fetch the
> groupId from the database.
> I already know the groupId from the page I was coming from so there is
> no need to go back to the databse.
>
> How can I pass this groupId parameter to GroupHomePage without
> compromising the user-friendly links such as
> www.mysite.com/group/groupName?
> Thanks.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Passing hidden parameters / bookmarkable links

2009-04-15 Thread Henrique Boregio
I am developing a system that has "groups" and want to make them
accesible via user-friendly urls such as

www.mysite.com/group/GROUPNAME

On a web page, I have a list of groups which are all links to their
group pages, such as:
www.mysite.com/group/groupA
www.mysite.com/group/groupB
...

This is implemented as such:
PageParameters parameters = new PageParameters();
parameters.put("groupName", aGroup.getName());
add(new BookmarkablePageLink("groupName", GroupHomePage.class, parameters));

and also mounting a BookmarkablePage in my Wicket Application
mountBookmarkablePage("/groups", GroupHomePage.class);

and in my GroupHomePage class, I have:
public GroupHomePage (final PageParameters parameters) {

String groupName = parameters.getString("groupName");
int groupId = GroupDAO.getGroupId(groupName);
}

So as you can see, I basically retrieve the groupName and go fetch the
groupId from the database.
I already know the groupId from the page I was coming from so there is
no need to go back to the databse.

How can I pass this groupId parameter to GroupHomePage without
compromising the user-friendly links such as
www.mysite.com/group/groupName?
Thanks.

-
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
 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-12 Thread Brill Pappin

We already set it up as WIcket Skunkworks :)

There are couple of reasons to set up something new.
1) We have not earned the right to commit to one of the official  
extension projects. It's a meritocratic thing after all.
2) At the moment it's hacked code and not a real component... some  
experimentation is needed (hence skunkworks).


This way we can monkey with a component that we only know that we two  
need. if it works well and others want it, we can migrate it to wicket  
stuff.


I imaging there is quite a lot of Wicket code out there that people  
have put together but is not at component quality, but none the less  
has promise. Let this be the place where it gets experimented upon.


- Brill

On 11-Mar-09, at 12:47 PM, Jeremy Thomerson wrote:

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





-
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
 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



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-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
>
>


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



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:
   * 
   *tabParameterName = component id
   *defaultTabIndex = 0
   * 
 * @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 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, 
List 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



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:
   * 
   *tabParameterName = component id
   *defaultTabIndex = 0
   * 
 * @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 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 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



Re: Tabbed Panel with bookmarkable links

2009-03-10 Thread James Carman
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  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
>>  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:
>>>  * 
>>>  *    tabParameterName = component id
>>>  *    defaultTabIndex = 0
>>>  * 
>>>    * @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 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 tabs,
>>>       int defaultTabIndex,
>>>       String 

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



Re: Tabbed Panel with bookmarkable links

2009-03-10 Thread Brill Pappin

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
 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:
  * 
  *tabParameterName = component id
  *defaultTabIndex = 0
  * 
* @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 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 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

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:
  * 
  *tabParameterName = component id
  *defaultTabIndex = 0
  * 
* @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 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 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

> > 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



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.


WicketMessage: Error attaching this container for rendering: [Page class = 
com.helmbold.wicki.view.ArticlePage, id = 2, version = 0]
Root cause:
java.lang.ArrayIndexOutOfBoundsException: 0
 at 
org.apache.wicket.extensions.markup.html.tabs.TabbedPanel.isTabVisible(TabbedPanel.java:397)
 at 
org.apache.wicket.extensions.markup.html.tabs.TabbedPanel.onBeforeRender(TabbedPanel.java:219)
 at org.apache.wicket.Component.internalBeforeRender(Component.java:1049)
 at org.apache.wicket.Component.beforeRender(Component.java:1083)
 at 
org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1716)
 at org.apache.wicket.Component.onBeforeRender(Component.java:3837)
 at org.apache.wicket.Page.onBeforeRender(Page.java:1478)
 at org.apache.wicket.Component.internalBeforeRender(Component.java:1049)
 at org.apache.wicket.Component.beforeRender(Component.java:1083)
 at org.apache.wicket.Component.prepareForRender(Component.java:2216)
 at org.apache.wicket.Component.prepareForRender(Component.java:2243)
 at org.apache.wicket.Page.renderPage(Page.java:905)
 at 
org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.respond(BookmarkablePageRequestTarget.java:262)
 at 
org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:105)
 at 
org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1200)
 at org.apache.wicket.RequestCycle.step(RequestCycle.java:1271)
 at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1370)
 at org.apache.wicket.RequestCycle.request(RequestCycle.java:501)
 at 
org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:455)
 at 
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:288)
 at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
 at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
 at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
 at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
 at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
 at java.lang.Thread.run(Thread.java:619)
Complete stack:
org.apache.wicket.WicketRuntimeException: Error attaching this container for 
rendering: [Page class = com.helmbold.wicki.view.ArticlePage, id = 2, version = 
0]
 at 
org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1728)
 at org.apache.wicket.Component.onBeforeRender(Component.java:3837)
 at org.apache.wicket.Page.onBeforeRender(Page.java:1478)
 at org.apache.wicket.Component.internalBeforeRender(Component.java:1049)
 at org.apache.wicket.Component.beforeRender(Component.java:1083)
 at org.apache.wicket.Component.prepareForRender(Component.java:2216)
 at org.apache.wicket.Component.prepareForRender(Component.java:2243)
 at org.apache.wicket.Page.renderPage(Page.java:905)
 at 
org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.respond(BookmarkablePageRequestTarget.java:262)
 at 
org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:105)
 at 
org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1200)
 at org.apache.wicket.RequestCycle.step(RequestCycle.java:1271)
 at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1370)
 at org.apache.wicket.RequestCycle.request(RequestCycle.java:501)


Regards
Christian






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



Re: Tabbed Panel with bookmarkable links

2009-03-10 Thread James Carman
What if you use two different tabbed panels on the same page?

On Tue, Mar 10, 2009 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:
>   * 
>   *    tabParameterName = component id
>   *    defaultTabIndex = 0
>   * 
>     * @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 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 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: 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:
   * 
   *tabParameterName = component id
   *defaultTabIndex = 0
   * 
 * @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 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 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



Re: Tabbed Panel with bookmarkable links

2009-03-09 Thread Brill Pappin

Cool... I just did exactly the same thing!
Since others seem to need it, this might be worth refining over on  
wicket-stuff.


I did my version slightly different in that I used the existing one as  
a basis and created a PageTabbedPanel IPageTab and AbstractPageTab.
The main difference is in the newTabContainer() method (and of course  
the support in the IPageTab interface).


I actually have two levels of tabs however in this current app and I  
have not satisfactorily resolved the second layer of tabs (obviously  
if I use the same thing on the second level, the tabs for the first  
are going to vanish). I was thinking that for multi layer page based  
tabs you could nest them.


Anyway, let me know if your interested, or if any other Wicket guru's  
are interested...


- Brill


On 9-Mar-09, at 1:32 PM, Christian Helmbold wrote:



Hello,

I've written a component which provides bookmarkable links for a  
tabbed panel. The link to the currend tab is disabled and the url to  
the default tab contains no tab information to keep URLs short.


It works so far, but since this is my first wicket component I'd  
like to know your suggestions to improve the code.


A possible improvement could be to replace the tab number by its  
name. So they would look like

http://some.url/app/PageX?tab=edit instead of
http://some.url/app/PageX?tab=1.
But to do this, it would be necessary to generate a map containing  
the tab names as keys and their indexes as values. This would be  
done on every request, because the tabbed panel is regenerated on  
every request. Is there a way to avoid the regeneration of the map?  
Maybe tab names in URLs are not really important, but I think a user  
would prefer a self-explanatory words in URLs.


I tried to use getPage().getPageParameters() in the constructor, but  
getPage() didn't work there. It works in the newLink(...) method.  
Why does it not work in the constructor?


Another question is: Is it a good idea to use this function within a  
component? If it is not a good idea, I have to add a page argument  
to the constructor instead of using getPage() in the newLink(...)  
method.


May this component be incompatible with other strategies than  
MixedParamUrlCodingStrategy? If this component is universal I'd like  
to contribute it to the wicket extensions sub project.




package com.helmbold.wicket.components;

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 = "tab";
   private int defaultTabIndex = 0;


 /**
  * Using this constructor the following defaults take effect:
  * 
  *tabParameterName = "tab"
  *defaultTabIndex = 0
  * 
* @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 tabs,
 PageParameters pageParameters)
 {
   super(id, tabs);
   this.pageParameters = pageParameters;

   if (pageParameters.containsKey(tabParameterName))
   {
 String tab = pageParameters.getString(tabParameterName);
 setSelectedTab(Integer.parseInt(tab));
   }
   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 tabs,
   int defaultTabIndex,
   String tabParameterName,
   PageParameters pageParameters)
   {
   this(id, tabs, pageParameters);
   this.defaultTabIndex = defaultTabIndex;
   setSelectedTab(defaultTabIndex);
   this.tabParameterName = tabParameterName;
   }


   @Override
 protected WebMarkupContainer newLink(String linkId, int index)
 {
   if (index == defaultTabIndex)
 pageParameters.remove(tabParameterName);
   else
 pageParameters.put(tabParameterName, "" + index);

   WebMarkupContainer link = new BookmarkablePageLink(
   linkId, getPage().getClass(), pageParameters);
   if (index == getSel

Tabbed Panel with bookmarkable links

2009-03-09 Thread Christian Helmbold

Hello,

I've written a component which provides bookmarkable links for a tabbed panel. 
The link to the currend tab is disabled and the url to the default tab contains 
no tab information to keep URLs short. 

It works so far, but since this is my first wicket component I'd like to know 
your suggestions to improve the code.

A possible improvement could be to replace the tab number by its name. So they 
would look like 
http://some.url/app/PageX?tab=edit instead of 
http://some.url/app/PageX?tab=1. 
But to do this, it would be necessary to generate a map containing the tab 
names as keys and their indexes as values. This would be done on every request, 
because the tabbed panel is regenerated on every request. Is there a way to 
avoid the regeneration of the map? Maybe tab names in URLs are not really 
important, but I think a user would prefer a self-explanatory words in URLs.

I tried to use getPage().getPageParameters() in the constructor, but getPage() 
didn't work there. It works in the newLink(...) method. Why does it not work in 
the constructor? 

Another question is: Is it a good idea to use this function within a component? 
If it is not a good idea, I have to add a page argument to the constructor 
instead of using getPage() in the newLink(...) method.

May this component be incompatible with other strategies than 
MixedParamUrlCodingStrategy? If this component is universal I'd like to 
contribute it to the wicket extensions sub project.



package com.helmbold.wicket.components;

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 = "tab";
private int defaultTabIndex = 0;


  /**
   * Using this constructor the following defaults take effect:
   * 
   *tabParameterName = "tab"
   *defaultTabIndex = 0
   * 
 * @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 tabs,
  PageParameters pageParameters)
  {
super(id, tabs);
this.pageParameters = pageParameters;

if (pageParameters.containsKey(tabParameterName))
{
  String tab = pageParameters.getString(tabParameterName);
  setSelectedTab(Integer.parseInt(tab));
}
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 tabs,
int defaultTabIndex,
String tabParameterName,
PageParameters pageParameters)
{
this(id, tabs, pageParameters);
this.defaultTabIndex = defaultTabIndex;
setSelectedTab(defaultTabIndex);
this.tabParameterName = tabParameterName;
}


@Override
  protected WebMarkupContainer newLink(String linkId, int index)
  {
if (index == defaultTabIndex)
  pageParameters.remove(tabParameterName);
else
  pageParameters.put(tabParameterName, "" + index);
  
WebMarkupContainer link = new BookmarkablePageLink(
linkId, getPage().getClass(), pageParameters);
if (index == getSelectedTab())
  link.setEnabled(false);
return link;
  }
  
}


Regards,
Christian

 -- 
http://www.groovy-forum.de






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



Re: bookmarkable links

2009-02-19 Thread Jeremy Thomerson
bookmarkable links are bookmarkable - you can come back to them even after
session is destroyed or send to a friend and they can come to them

links are not bookmarkable - relative only to your session - and stateful

On Thu, Feb 19, 2009 at 10:55 AM, Matías Tito  wrote:

> Hi, I am beginnig on Wicket. Well, my questions is:
>
> Diferences beetwen bookmarkablelink and links
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


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


bookmarkable links

2009-02-19 Thread Matías Tito
Hi, I am beginnig on Wicket. Well, my questions is:

Diferences beetwen bookmarkablelink and links


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



Re: Session Expiration. UnauthorizedComponentInstantiationException. PageExpiredException. IllegalStateException. Ajax and Bookmarkable links.

2008-02-06 Thread mattsmith

Here's what we ended up doing to address this (since there didn't seem to be
a consistent approach to handling the variety of scenarios from the the
framework's perspective):

1.  Disabled the back button by agressively expiring visited pages (negating
a huge benefit of using wicket in the first place :).  
2.  Remove the bookmarkablePage link from the equation.
3.  onRuntimeException() in our custom request cycle handles the various
exceptions (PageExpired, Unauthorized,etc)
4.  custom modification to our web session to prevent feedback message
clearing in some cases of #3 where the message was getting too aggressively
cleared.
5.  we are not using the expired page setting that comes with wicket because
it didn't seem to cover the variety of scenarios mentioned.

We would have really liked to see this handling offered with some default
mechanism in wicket (For common scenarios mentioned in my prior msg).

- Matt


Matt Smith-20 wrote:
> 
> A co-worker and I are looking into how to provide a consistent
> handling of session expiration with an AuthenticatedWebApplication.
> 
> If a session expires, ideally, we'd like to provide a consistent
> behavior of redirecting to a login page with a helpful message (i.e. -
> "Your session expired, please re-login"), re-authenticate, and then
> proceed to the original request regardless of what type of request is
> made of the server.
> 
> Examples of the scenarios we'd like to handle consistently are:
> 1.   User logs in.  Session expires, then user clicks a wicket
> generated Page link.
> 2.   User logs in.  Session expires, then user clicks the back button
> in the browser and then clicks on a wicket generated component link.
> 3.   User logs in.  User performs an action which results in them
> being redirected to a bookmarkable page.  The session expires, then
> user submits a form
> 4.   User logs in.  User performs an action which results in them
> being redirected to a bookmarkable page.  The session expires, then
> user clicks a wicket generated link on the current page.
> 5.   User logs in.  User performs an action which results in them
> being redirected to a bookmarkable page.  The session expires, then
> user triggers an AJAX request of the server.
> 6.   User logs in.  The session expires.  User then triggers an AJAX
> request of the server.
> 7.   User logs in.  The session expires, then user gets redirected to
> login page (thus creating a new session).   User then clicks back and
> clicks on a wicket generated link, gets redirected to a login page,
> clicks back, clicks a wicket generated link.
> 
> The examples above seem to cause various behaviors in:
> #1.  The Web app's UnauthorizedComponentInstantiation listener is
> fired and given the page the user was on as an argument (thus
> redirecting them directly to the page without a message).
> #2 throws an UnauthorizedComponentInstantiationException
> #3 throws a PageExpiredException
> #4 throws a PageExpiredException
> #5 throws a PageExpiredException
> #6 throws an IllegalStateException (unmatched key/value pairs).
> #7  A WicketRuntimeException exception is thrown ("component not found
> in page")(because the page id in the link is referring to a different
> page in the current/new session than the page it referred to in the
> old session).  It seems that using nextnumber id's (starting at 0)
> allows for potential overlap in id's between a new session and an old
> session.
> 
> We are able to handle PageExpiredException consistently by overriding
> onRuntimeException() in our own custom RequestCycle.
> 
> Is there a way we can specify some consistent behavior for the other
> scenarios?
> 
> - Matt
> http://netsmith.blogspot.com
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Session-Expiration.-UnauthorizedComponentInstantiationException.-PageExpiredException.-IllegalStateException.-Ajax-and-Bookmarkable-links.-tp15272371p15306738.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Session Expiration. UnauthorizedComponentInstantiationException. PageExpiredException. IllegalStateException. Ajax and Bookmarkable links.

2008-02-04 Thread Matt Smith
A co-worker and I are looking into how to provide a consistent
handling of session expiration with an AuthenticatedWebApplication.

If a session expires, ideally, we'd like to provide a consistent
behavior of redirecting to a login page with a helpful message (i.e. -
"Your session expired, please re-login"), re-authenticate, and then
proceed to the original request regardless of what type of request is
made of the server.

Examples of the scenarios we'd like to handle consistently are:
1.   User logs in.  Session expires, then user clicks a wicket
generated Page link.
2.   User logs in.  Session expires, then user clicks the back button
in the browser and then clicks on a wicket generated component link.
3.   User logs in.  User performs an action which results in them
being redirected to a bookmarkable page.  The session expires, then
user submits a form
4.   User logs in.  User performs an action which results in them
being redirected to a bookmarkable page.  The session expires, then
user clicks a wicket generated link on the current page.
5.   User logs in.  User performs an action which results in them
being redirected to a bookmarkable page.  The session expires, then
user triggers an AJAX request of the server.
6.   User logs in.  The session expires.  User then triggers an AJAX
request of the server.
7.   User logs in.  The session expires, then user gets redirected to
login page (thus creating a new session).   User then clicks back and
clicks on a wicket generated link, gets redirected to a login page,
clicks back, clicks a wicket generated link.

The examples above seem to cause various behaviors in:
#1.  The Web app's UnauthorizedComponentInstantiation listener is
fired and given the page the user was on as an argument (thus
redirecting them directly to the page without a message).
#2 throws an UnauthorizedComponentInstantiationException
#3 throws a PageExpiredException
#4 throws a PageExpiredException
#5 throws a PageExpiredException
#6 throws an IllegalStateException (unmatched key/value pairs).
#7  A WicketRuntimeException exception is thrown ("component not found
in page")(because the page id in the link is referring to a different
page in the current/new session than the page it referred to in the
old session).  It seems that using nextnumber id's (starting at 0)
allows for potential overlap in id's between a new session and an old
session.

We are able to handle PageExpiredException consistently by overriding
onRuntimeException() in our own custom RequestCycle.

Is there a way we can specify some consistent behavior for the other scenarios?

- Matt
http://netsmith.blogspot.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: tabbedpanel and bookmarkable links

2007-08-27 Thread Swaroop Belur
Oops a typo


>> .In that link you will have to override newUrl method to return what u
want.

Read as

.In that link you will have to override getURLmethod to return what u want.

-swaroop

On 8/28/07, Swaroop Belur <[EMAIL PROTECTED]> wrote:
>
>
> Link i think calls  getUrl method to get its url to invoke.
> So probabley you will have to override newLink method in tab panel
> to return ur custom link component .In that link you will have to override
>
> newUrl method to return what u want.
>
> -swaroop
>
>
>
>
>
> On 8/28/07, wired <[EMAIL PROTECTED]> wrote:
> >
> >
> > (version 1.2.6)
> >
> > Does anyone have any quick workaround to making the link in each tab of
> > a
> > TabbedPanel bookmarkable?
> >
> > Many thanks.
> > --
> > View this message in context:
> > http://www.nabble.com/tabbedpanel-and-bookmarkable-links-tf4337745.html#a12355907
> > Sent from the Wicket - User mailing list archive at Nabble.com.
> >
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
>
>


-- 

Regards
Swaroop Belur
http://sbelur.wordpress.com/
http://jdec.sourceforge.net/


Re: tabbedpanel and bookmarkable links

2007-08-27 Thread Swaroop Belur
Link i think calls  getUrl method to get its url to invoke.
So probabley you will have to override newLink method in tab panel
to return ur custom link component .In that link you will have to override
newUrl method to return what u want.

-swaroop





On 8/28/07, wired <[EMAIL PROTECTED]> wrote:
>
>
> (version 1.2.6)
>
> Does anyone have any quick workaround to making the link in each tab of a
> TabbedPanel bookmarkable?
>
> Many thanks.
> --
> View this message in context:
> http://www.nabble.com/tabbedpanel-and-bookmarkable-links-tf4337745.html#a12355907
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


--


tabbedpanel and bookmarkable links

2007-08-27 Thread wired

(version 1.2.6)

Does anyone have any quick workaround to making the link in each tab of a
TabbedPanel bookmarkable?

Many thanks.
-- 
View this message in context: 
http://www.nabble.com/tabbedpanel-and-bookmarkable-links-tf4337745.html#a12355907
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]