11 Replies Latest reply: Aug 28, 2013 5:00 AM by Saif Khan RSS

    Selected tab based on command navigation item

    979970

      Hi,

      I have a jsf(jspx) page with a navigation pane which has three navigation items. Now clicking on any of the navigation item another jsf page will appear in a new window. This page has three tabs. Now I want to show a tab selected based on the navigation item clicked. I have a managed bean where I have set disclosed property of the show detail items based on the navigation item clicked. But it is throwing null pointer exception.

              public void firstitemClicked() {

              this.getTab1().setDisclosed(false); //this line is throwing a error

              this.getTab2().setDisclosed(true);

              this.getTab3().setDisclosed(false);

             }

       

      And this method is getting called from the navigation item which is on the first page.

        • 1. Re: Selected tab based on command navigation item
          Stephen J.

          What version of Jdeveloper/ADF are you using?

           

          I'm not sure if there's enough code there to tell what's wrong, but it sounds like maybe you need to look in to calling a task flow with a parameter.

          • 2. Re: Selected tab based on command navigation item
            979970

            Hi,

            I'm using JDeveloper 11.0.0.7

            Actually I have links in one page and clicking on a link will open a page in a new window. The new page has panel tabs. Now I want to select a tab based on the link clicked. For that I have written the above method in a managed bean but it is throwing null pointer exception.

            • 3. Re: Selected tab based on command navigation item
              Saif Khan

              Hi 979970,

               

              I believe u r trying to access the tabs in the code which are not initialized yet. I mean to say, in order to do some action on the ur tabs, you must have ur tabbed page to be rendered first.

               

              Instead how you can achieve the requirement is..

               

              Lets consider the below steps for 2nd tab of ur page

               

              1. In your bean, declare 3 boolean variables (Ex: private boolean tab2Disclosed = false) and generate getters and setters to these.

              2. Set disclosed property of your af:showDetailedItem as #{yourScope.yourBeanName.tab2Disclosed}

              3. Now lets say, on click of your first navigation item on the 1st page, you want 2nd tab of 2nd page to be a default tab. Write the below code.

               

                    public void firstitemClicked() {

                                this.setTab1Disclosed(false);;

                                this.setTab2Disclosed(true);

                                this.setTab3Disclosed(false);

                     }

               

              Similarly handle the logic for other 2 tabs as well.

               

              Tip: Please update your display name in Control Panel Settings

              • 4. Re: Selected tab based on command navigation item
                0bf591d8-d242-41a0-b34e-c7f3a927f5aa

                Are you getting the component instance of the tab (  this.getTab1() )   ??

                • 5. Re: Selected tab based on command navigation item
                  979970

                  Hi Saif,

                  I'll try as per your suggestion.

                  Thanks very much

                   

                  --

                  Surojit

                  • 6. Re: Selected tab based on command navigation item
                    979970

                    Saif,

                    It's working but when I enabled the useWindow(useWindow="true") option on the navigationItem it stopped working.

                    The code is:

                    <af:navigationPane id="np1">

                                                <af:commandNavigationItem text="commandNavigationItem 1"

                                                                          id="cni1"

                                                                          action="dialog:tab"

                                                                          actionListener="#{DemoBackingBean.first}"

                                                                          useWindow="false"

                                                                          windowHeight="700"

                                                                          windowWidth="650"/>

                    -------------------------------------------------------

                    --------------------------------------------------

                    I was testing using JDev 11.1.1.0.5

                    • 7. Re: Selected tab based on command navigation item
                      Saif Khan

                      Hi,

                       

                      It is working for me (11.1.1.5). Check your browser if the popups are blocked and try again by unblocking the popups. That might be the problem. Else, try running the URL from diffrerent browser. If it works, mark this thread as "Answered"

                       

                      Thanks,

                      Saif.

                      • 8. Re: Selected tab based on command navigation item
                        979970

                        Hi,

                        The pop up is coming. The problem is in the pop up the desired tab is not getting selected. But if I set the useWindow = false, then it is working well. Can you give some idea?

                        • 9. Re: Selected tab based on command navigation item
                          Saif Khan

                          Surojit,

                           

                          Make the boolean type as "static".

                           

                          In your DemoBackingBean, make the variable to "static" which we missed before.


                          private static boolean first = false;

                           

                          Tip: I would rather use "af:setActionListener" intead of writing code for such requirement

                           

                          Thanks,

                          Saif

                          • 10. Re: Selected tab based on command navigation item
                            979970

                            Saif,

                            Can you please share with me the logic behind it?

                            • 11. Re: Selected tab based on command navigation item
                              Saif Khan

                              In your 1st page:

                               

                              <af:navigationPane id="np1">

                                          <af:commandNavigationItem text="NavigationItem 1" id="cni1"

                                                                    useWindow="true" windowHeight="700"

                                                                    windowWidth="650" action="dialog:go">

                                            <af:setActionListener from="first" to="#{pageFlowScope.tabbedPage}"/>

                                          </af:commandNavigationItem>

                                          <af:commandNavigationItem text="NavigationItem 2" id="cni2"

                                                                    action="dialog:go" useWindow="true"

                                                                    windowHeight="700" windowWidth="650">

                                            <af:setActionListener  from="second" to="#{pageFlowScope.tabbedPage}"/>

                                          </af:commandNavigationItem>

                                          <af:commandNavigationItem text="NavigationItem 3" id="cni3"

                                                                    action="dialog:go" useWindow="true"

                                                                    windowHeight="700" windowWidth="650">

                                            <af:setActionListener from="third" to="#{pageFlowScope.tabbedPage}"/>

                                          </af:commandNavigationItem>

                                        </af:navigationPane>

                               

                              In 2nd page:

                               

                              <af:panelTabbed id="pt1">

                                        <af:showDetailItem text="showDetailItem 1" id="sdi1"

                                                           disclosed="#{pageFlowScope.tabbedPage eq 'first'}"/>

                                        <af:showDetailItem text="showDetailItem 2" id="sdi2"

                                                           disclosed="#{pageFlowScope.tabbedPage eq 'second'}"/>

                                        <af:showDetailItem text="showDetailItem 3" id="sdi3"

                                                           disclosed="#{pageFlowScope.tabbedPage eq 'third'}"/>

                                      </af:panelTabbed>

                               

                              Thanks,

                              Saif