Proposal for bookmarkable URLs creation facility for tabview

UI Components for JSF
Post Reply
ertiop93
Posts: 97
Joined: 29 May 2011, 16:14

06 Aug 2011, 00:26

I have a proposal for tabview to add a facility to create bookmarkable URLs for the each tab, out of the box.

It should update URLs in the address bar as the tab in a Tabview component change thereby providing a facility to create bookmark-able URLs very easily..

Does that make sense ? Can primefaces make this job easier for us ?
****************************
Using Primefaces 3.4 Snapshot with JSF(Myfaces) 2.1.8

****************************

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

06 Aug 2011, 01:41

Why don't you send the activeIndex as a view parameter and then bind the backing property to the tabview's activeIndex option. JSF2 does it for you already.

Alan
Posts: 102
Joined: 25 Oct 2010, 04:45

18 Aug 2011, 18:46

I had the same question but I don't understand the answer.

Is the suggestion to do this?

Code: Select all

<p:tabview activeIndex=#{request[activeTab]} ..
If that works so far so good, but how does the "activeTab=" string get appended to the URL that the user bookmarks?
Netbeans 7.1, GlassFish 3.1.1, MacOS X 10.6.8, Safari, Firefox

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

18 Aug 2011, 18:49

use f:viewParams, map it to a variable of a bean (for example: #{myPageBean.activeIndex}) and set activeIndex=#{myPageBean.activeIndex}
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

Alan
Posts: 102
Joined: 25 Oct 2010, 04:45

18 Aug 2011, 23:40

OK so far. I modified my page like this:

Code: Select all

 
           <ui:define name="content">
                <f:metadata>
                    <f:viewParam name="activeTab" value="#{login.activeTab}" />
                </f:metadata>
                <p:tabView activeIndex="#{login.activeTab}">
                    <p:tab title="Tab The First">
                        Stuff in the First Tab
                    </p:tab>
                    <p:tab title="Second Tab">
                        Second Tab Stuff Goes Here
                    </p:tab>
                    <p:tab title="Tab 3">
                        Everything about 3
                    </p:tab>
                </p:tabView>
            </ui:define>
If I modify the URL manually to append "activeTab=x" it will bring up tab x. Now what is needed is to add something to the p:tab elements so that when they are clicked, the URL currently visible gets changed so that if the user then selects "bookmark this page" in his browser that will be saved in the bookmark. Is there a best practice for that or do I have to add some javascript called by onTabChange?
Netbeans 7.1, GlassFish 3.1.1, MacOS X 10.6.8, Safari, Firefox

mask_hot
Posts: 34
Joined: 27 May 2011, 10:52

05 Nov 2011, 16:54

I have the same question : how to know the activeIndex?

Using Change Listener it is possible to get the tab Title but how to get the tab Index?

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 44 guests