Book-markable tab?

UI Components for JSF
Alan
Posts: 102
Joined: 25 Oct 2010, 04:45

30 Nov 2010, 18:40

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?
Netbeans 7.1, GlassFish 3.1.1, MacOS X 10.6.8, Safari, Firefox

toymachiner62
Posts: 23
Joined: 25 Oct 2011, 22:33

09 May 2012, 22:58

I am also interested in how to bookmark tabs from a tabview element. Is there a good way to do this?

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

09 May 2012, 23:19

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

Hamsterbau
Posts: 409
Joined: 28 Dec 2011, 17:44

10 May 2012, 09:40

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 :(
Primefaces 8.0.7 (PF Extensions 8.0)
JSF: Mojarra 2.3.2 (Spec 2.3) - running on WildFly 22

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

10 May 2012, 11:05

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

Hamsterbau
Posts: 409
Joined: 28 Dec 2011, 17:44

10 May 2012, 11:43

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.
Primefaces 8.0.7 (PF Extensions 8.0)
JSF: Mojarra 2.3.2 (Spec 2.3) - running on WildFly 22

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

10 May 2012, 16:31

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
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

toymachiner62
Posts: 23
Joined: 25 Oct 2011, 22:33

10 May 2012, 23:05

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

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

10 May 2012, 23:22

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
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

10 May 2012, 23:47

Should be easy, create a viewparam and bind it to the property that is also bound to activeIndex of tabview.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 6 guests