4 Replies Latest reply: Jan 17, 2013 3:26 AM by 985424 RSS

    Database driven menu problem

    Bilal
      Hi All,

      Oracle JDeveloper 11g Release 2.

      I am creating application menu from the database in adf page.

      The table has the following data:
      ===================================================
      Financials
      --Setup                                                                                          
      ----Financial Calendar
      ----Financial Books
      ----Cost Centers
      ----Chart of Accounts
      --Transactions                                                                                   
      --Reports                                                                                        
      Payroll
      --Setup                                                                                          
      --Transaction                                                                                    
      --Reports                                                                                        
      Inventory
      Assets
      Account Payables
      Account Receivables
      Control Panel
      ========================================

      I have created an application using the following steps:

      1. I created a view object topMenus in the model project.
      2. I created a view link to related the menuID and menuBaseID.
      3. I added the view object and viewlink in the application module.
      4. In the view project, I created a page and then created tree binding for it.
      5. I have added the following code to generate the dynamic menu:

      =========================================================================
      <af:panelAccordion id="acc" discloseMany="false" discloseNone="false">
      <af:forEach items="#{bindings.topMenus.children}" var="moduleMenu">
      <af:showDetailItem text="#{moduleMenu.MenuLabel}" id="sdi1">
      <af:forEach items="#{moduleMenu.children}" var="componentMenu">
      <af:showDetailHeader id="sdh1" text="#{componentMenu.MenuLabel}" size="4"
      type="stretch">
      <af:panelList id="pl1">
      <af:forEach items="#{componentMenu.children}" var="taskMenu">
      <af:commandLink id="cl1" text="#{taskMenu.MenuLabel}"></af:commandLink>
      </af:forEach>
      </af:panelList>
      </af:showDetailHeader>
      </af:forEach>
      </af:showDetailItem>
      </af:forEach>
      </af:panelAccordion>
      ===========================================================================

      5. When I run the form, this is giving the following hierarchy using panelAccordion, detailItem, and commandLink components.

      Financials
      --Setup                                                                                          
      ----Financial Calendar
      Payroll
      --Setup                                                                                          
      Inventory
      Assets
      Account Payables
      Account Receivables
      Control Panel

      ===================
      A closer look reveals that it is showing only one entry for all the level except level 1.
      I dont know how to make this to work fine.

      Any help will be highly appreciated.
      Thanks ... Best Regards
      Bilal

      Edited by: Bilal on Dec 2, 2011 9:21 AM
        • 1. Re: Database driven menu problem
          Muhammed Soyer
          Hi Bilal,

          Try to generate unique ids for each component that you generate in the For Each.
          <af:panelAccordion id="acc" discloseMany="false" discloseNone="false">
          <af:forEach items="#{bindings.topMenus.children}" var="moduleMenu" varStatus="varStatus">
          <af:showDetailItem text="#{moduleMenu.MenuLabel}" id="sdi${varStatus.index}">
          <af:forEach items="#{moduleMenu.children}" var="componentMenu">
          <af:showDetailHeader id="sdh1" text="#{componentMenu.MenuLabel}" size="4"
          type="stretch">
          <af:panelList id="pl1">
          <af:forEach items="#{componentMenu.children}" var="taskMenu">
          <af:commandLink id="cl1" text="#{taskMenu.MenuLabel}"></af:commandLink>
          </af:forEach>
          </af:panelList>
          </af:showDetailHeader>
          </af:forEach>
          </af:showDetailItem>
          </af:forEach>
          </af:panelAccordion>
          • 2. Re: Database driven menu problem
            Bilal
            Hi Muhammad Soyer,

            First of all thanks for the response and guidance.

            I have tried changing the code for the unique IDs, but still giving the same output. The updated code is as below:

            <af:panelAccordion id="acc" discloseMany="false" discloseNone="false">
            <af:forEach items="#{bindings.topMenus.children}" var="moduleMenu" varStatus="topMenuVarStatus">
            <af:showDetailItem text="#{moduleMenu.MenuLabel}" id="sdi#{topMenuVarStatus.index}">
            <af:forEach items="#{moduleMenu.children}" var="componentMenu" varStatus="componentMenuVarStatus">
            <af:showDetailHeader id="sdh#{componentMenuVarStatus.index}" text="#{componentMenu.MenuLabel}" size="4"
            type="stretch">
            <af:panelList id="pl#{componentMenuVarStatus.index}">
            <af:forEach items="#{componentMenu.children}" var="taskMenu" varStatus="taskMenuVarStatus">
            <af:commandLink id="cl#{taskMenuVarStatus.index}" text="#{taskMenu.MenuLabel}"></af:commandLink>
            </af:forEach>
            </af:panelList>
            </af:showDetailHeader>
            </af:forEach>
            </af:showDetailItem>
            </af:forEach>
            </af:panelAccordion>
            ----

            See if I am still missing some important part. Any help will be highly appreciated.

            Thanks ... Best Regards
            Bilal
            • 3. Re: Database driven menu problem
              Bilal
              Hi Muhammad Soyer!

              Finally I have done with generating the dynamic menus from the database table.

              The problem was due to the cardinality specification in viewlink. I changed it to 1..* and its done....
              -------
              The code is now as below:

              <af:panelAccordion id="acc" discloseMany="false" discloseNone="false">
              <af:forEach items="#{bindings.topMenus.children}" var="moduleMenu" varStatus="topMenuVarStatus">
              <af:showDetailItem text="#{moduleMenu.MenuLabel}" id="sdi#{topMenuVarStatus.index}">
              <af:forEach items="#{moduleMenu.children}" var="componentMenu" varStatus="componentMenuVarStatus">
              <af:showDetailHeader id="sdh#{topMenuVarStatus.index}#{componentMenuVarStatus.index}" text="#{componentMenu.MenuLabel}" size="4"
              type="flow">
              <af:panelList id="pl#{topMenuVarStatus.index}#{componentMenuVarStatus.index}">
              <af:forEach items="#{componentMenu.children}" var="taskMenu" varStatus="taskMenuVarStatus">
              <af:commandLink id="cl#{topMenuVarStatus.index}#{componentMenuVarStatus.index}#{taskMenuVarStatus.index}" text="#{taskMenu.MenuLabel}"></af:commandLink>
              </af:forEach>
              </af:panelList>
              </af:showDetailHeader>
              </af:forEach>
              </af:showDetailItem>
              </af:forEach>
              </af:panelAccordion>

              -----

              Thanks for all the support you extended.

              Best Regards
              Bilal
              • 4. Re: Database driven menu problem
                985424
                Hi Bilal,

                Would you tell me how did u create database driven menu? Is there any detailed tutorial or docs on this subject which you prefer to me?

                Thanks for your help.