10 Replies Latest reply: Apr 8, 2014 6:49 AM by user8959800 RSS

    [SOLVED] Show/hide options in af:navigationPane

    user8959800

      Hi.

       

      I'm using JDeveloper 11.1.1.7.0

       

      I have followed this tutorial http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_43/jdtut_11r2_43.html to create a basic and plain left-side menu in my application.

      This tutorial shows more advance topics, but I have created a simple left-side menu, with a list.

       

      I haved created an unbounded task flow, drag/drop a wildcard, then the views, then the control flows, ... It works perfect

      In the JSF template, in the left-side, I have this code:

       

      <af:navigationPane id="pt_np1" hint="list" value="#{supervision_menu}" var="supervisionInfo">
                          <f:facet name="nodeStamp">
                            <af:commandNavigationItem text="#{supervisionInfo.label}" id="pt_cni1"
                                                      destination="#{supervisionInfo.destination}"
                                                      action="#{supervisionInfo.doAction}"/>
                          </f:facet>
                        </af:navigationPane>
      
      

       

      I need an advanced feature, and I want to show/hide some options, based on a parameter.

      I need to execute a view object with this parameter, process the results, so I get the information to know which options could be shown or hidden.

       

      So, my questions are:

      • How could I force to execute this check as the first step of this flow?
      • In generated menu.xml and in af:commandNavigationItem, there are visible  attribute. Where should I place the condition?

       

      Any help would be very appreciated. Thanks





        • 1. Re: Show/hide options in af:navigationPane
          Alejandro Tovar Lanz

          Hi User,

           

          What is what you need to check? I mean, are you going to call a method that is in your Business Components? In any case, I believe you should put the condition in the visible property in menu.xml. To each of the itemNode you put the condition. Then again, we need to know more about how is the condition to tell you the what is the best way to proceed.

           

          Regards

          • 2. Re: Show/hide options in af:navigationPane
            user8959800

            Hi Alejandro.

             

            I'll try to explain the flow I want:

            • Receive by URL parameter a user ID.
            • Invoke two ViewObjects to get name, etc... and roles (admin, simple user).
            • Force to go to the home view of the menu.
            • Related to his roles, I want to show or hide some options on the left-side.

             

            All views are based on a template. The left-side menu is in the template.

             

            Thank you. Regards

            • 3. Re: Show/hide options in af:navigationPane
              Alejandro Tovar Lanz

              Hi,

               

              That is perfectly doable. Now, in what stage are you at the moment? Are you using ADF Security to handle authentication? Is your application deployed in Weblogic? Depending on the answers to this questions you will have different approach to take.

               

              Regards

              • 4. Re: Show/hide options in af:navigationPane
                user8959800

                Hi Alejandro and thank you again.

                 

                I'm using WebLogic, but I'm not using ADF Security. Both conditions must stay the same.

                 

                Thank you again

                • 5. Re: Show/hide options in af:navigationPane
                  Alejandro Tovar Lanz

                  Hi User,

                   

                  I was about to give you this http://www.oracle.com/technetwork/developer-tools/adf/learnmore/48-sitemenu-protection-169190.pdf in there talk about what you need to do. However, since you are not allowed to change the approach, you will need to somehow access to the UserID and ExecuteWithParams your 2 viewObjects with the previously created and applied ViewCriterias based on the UserID. After that, I am not sure how can you use the visible property of the menu.xml but if you can get hold of your ViewObject attributes then you will need to do the comparison to show/hide it depending on the role.

                  • 6. Re: Show/hide options in af:navigationPane
                    user8959800

                    Hi Alejandro, and thank you again.

                     

                    Finally I have to change my approach, and have another problem/question.

                     

                    I have a bounded flow with a required parameter (user id), and some views.

                    The first action in the flow is check user roles. Then, it's navigating to the home view, with links to all views.

                    All of these views are based on a template, which have a left-side with af:goLink, like this:

                     

                    <af:panelGroupLayout id="pt_pgl6" layout="vertical">
                                        <af:spacer width="20" height="10" id="pt_s6"/>
                                        <af:goLink text="ALWAYS VISBILE" id="pt_glfijo"
                                                   destination="/faces/views/fijo/evalProc1.jspx" />
                                        <af:goLink text="Link Eval 1" id="pt_gl1"
                                                   destination="........." visible="#{pageFlowScope.rolInspector}"/>
                                        <af:goLink text="Link Eval 2" id="pt_gl2"
                                                   destination="........." visible="#{pageFlowScope.rolSupervisor}"/>
                                        <af:goLink text="Link ADMIN" id="pt_gl3"
                                                   destination="........."
                                                   visible="#{pageFlowScope.rolAdministrador}"
                                                   targetFrame="_self"/>
                    </af:panelGroupLayout>
                    

                     

                    Well, this have some troubles for me:

                    • visible options work the first time. When click a goLink, pageFlowScope is lost and conditional goLinks don't show.
                    • When using af:link and clicking left-side options, the views loaded with the same state it had the last time (combo selection, table, input text...). I need to load clean views, as it was the first time.
                    • Making a menu with unbounded task flow is so easy, but it's not possible to pass parameters to unbounded flows.

                     

                    So, any suggestion would be very appreciated.

                    • 7. Re: Show/hide options in af:navigationPane
                      Alejandro Tovar Lanz

                      Hi,

                       

                      For the sound of it you might want to use dynamic regions;

                       

                      https://blogs.oracle.com/shay/entry/adf_dynamic_regions_switching_just

                       

                      The thing is that you are navigating away from the context where the menu is, (you are kind of leaving your taskflow) when navigating using the goLink. Have a look to dynamic regions and that might help you to accomplish your use case.

                       

                      Regards

                      • 8. Re: Show/hide options in af:navigationPane
                        user8959800

                        Hi Alejandro, and thank you again

                         

                        Dynamic Regions are a very good suggestion. But another problem still remains and it's very important for me:

                        1. Go to left-side menu, option1 and set some data: select an option in af:selectOneChoice, write in af:inputText...
                        2. Go to left-side menu, option2 and set some data in a similar way.
                        3. Go back to view1, and the view remains as I left it before: same selection in selectOneChoice, same text in inputText...

                         

                        Well, how can I reset content in that kind of navigation (left-menu, go to an option, then to another, then come back to the first option)?

                        Manually in a load-event method? Or is there any standard or easier way to do it?

                         

                        And another question: suppose one left-side option goes to a flow with some pages.

                        1. Go to left-side menu, option 1: the flow. Navigate some pages and go ahead.
                        2. In the middle of the flow, click left-side menu, option 2: a simple form.
                        3. Go back to option 1:
                          1. Which page should it be loaded? First page in the flow or the page I left it before?
                          2. If the answer is the page I left it before, how can I restart the flow?

                         

                        Any help would be very appreciated.

                        Thank you again, Alejandro.

                        • 9. Re: Show/hide options in af:navigationPane
                          Alejandro Tovar Lanz

                          Hi,

                           

                          Lets start with the last question. If you are in the middle of a flow and click another option in the left-side and then go back to option 1; you should be at the beginning of the flow and not at the point where you left, the taskflow is restarted.

                           

                          For the other question about the values remaining after coming back, I believe if the inputText is binded to an attribute of a view object iterator in your datacontrol, this change will remain there assuming you left the default configuration of the taskflow to share the datacontrol with the calling task flow.

                           

                          What is behind your inputText or selectOneChoice? Where are their values being stored?

                           

                          Regards

                          • 10. Re: Show/hide options in af:navigationPane
                            user8959800

                            Hi Alejandro and thank you again.

                             

                            It's a bounded task, and if I navigate from option 2 to option 1 (and viceversa), there must be navigation flow (arrow) defined from one to another.

                            It that arrow does not exist, it does not navigate.

                             

                            So, is it possible to be at the middle of a bounded flow, click on the left-side and restart again? Does it work with a af:goLink? I have been trying to go with an af:goLink but it failed and gave me an 404 error. I have configured flow to be restartable and acces by URL.

                            Is there any example to do this?

                             

                            In the other hand, Alejandro, behind input text and SOC, there are iterators and ViewObjects. I should reset them on each page load, but I'm trying to go to the pages as it was the first access, if it's possible.

                             

                            So, a little summary is:

                            • Bounded task flow: a home page, three options/page from home page, and then, each option does its stuff.
                            • Left-side menu with these three options.
                            • Maybe I am in the middle of the first-option flow, and then click the second option, and I'm trying to avoid to put lots of navigation flows (arrows) to cover each possible navigation (it's not mantainable).

                             

                            Thank you Alejandro.