Page 1 of 3

Book-markable tab?

Posted: 30 Nov 2010, 18:40
by Alan
I have a page with a <p:tabView> element in it with several tabs. What I want to do is add a request parameter to the URL for the page so that when the view is constructed a selected tab is displayed, rather than just the first tab.

So if the URL "./util.xhtml" shows the page with the first tab, the URL "./util.xhtml?tab=foo" shows the page with the tab with title="foo". Is there any way to do this?

BTW, how about a "bookmark this page" component for Primefaces? Or is there one already I missed?

Re: Book-markable tab?

Posted: 09 May 2012, 22:58
by toymachiner62
I am also interested in how to bookmark tabs from a tabview element. Is there a good way to do this?

Re: Book-markable tab?

Posted: 09 May 2012, 23:19
by kukeltje
Use the bookmarkable options of jsf2. You can populate a bean field with a value from a url. And when you use this same field to set the selected tab, you have 'bookmarkable tabs'.

Re: Book-markable tab?

Posted: 10 May 2012, 09:40
by Hamsterbau
metadata and includeviewparams can help to implement such a thing. But you have some work to do before :)
Another problem is, that if you want to use your browser to bookmark a page, the URL must be changed. And therefore you need a page request for each tab change :(

Re: Book-markable tab?

Posted: 10 May 2012, 11:05
by kukeltje
Hamsterbau wrote:Another problem is, that if you want to use your browser to bookmark a page, the URL must be changed. And therefore you need a page request for each tab change :(
Well, not always. You can make the tab title a link as well and if you make that the correct link, you can right-click on the header and do 'bookmark this as...'. Our users got that quickly

Re: Book-markable tab?

Posted: 10 May 2012, 11:43
by Hamsterbau
That's write, but what i meant with "if you want to use your browser to bookmark a page" is the default behaviour or shortcut of the current used browser, taking the current URL as bookmark.
There are also solutions for different browser types using JavaScript to create a bookmark. But it depends on the used browser.

Re: Book-markable tab?

Posted: 10 May 2012, 16:31
by andyba
Unless you cause tab changes to also change the current URL you will not be able to have the page bookmarked easily.
So each tab change is going to require that the browser location is rewritten with the activeTab as a get parameter in it which will cause a complete round trip to the server.
Or you can add a bookmark widget on that page (plenty of JQuery ones about) and set it up to use the current URL with the activeTab as a get parameter in it.

The rest is then simply about capturing the get param in the page and setting the appropriate bean property

Re: Book-markable tab?

Posted: 10 May 2012, 23:05
by toymachiner62
I know there's jQuery plugins to create bookmarkable tabs and i think it'd be nice to just have an attribute on the tabView to set the tabs to be bookmarkable or not. Idea for future primefaces release??

Re: Book-markable tab?

Posted: 10 May 2012, 23:22
by Oleg
Not sure, but I think it's not easy with PF own TabView widget. In PF Extensions I use jQuery Tabs in tabbed Layout and done bookmarkable tabs very easy. Showcase: http://fractalsoft.net/primeext-showcas ... gement.jsf

Re: Book-markable tab?

Posted: 10 May 2012, 23:47
by cagatay.civici
Should be easy, create a viewparam and bind it to the property that is also bound to activeIndex of tabview.