Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

creating dynamic menu from database query

ZeeShan Ali ShobanMar 29 2016 — edited Mar 30 2016

hi all ,

i am using j developer 11.1.2.3.39 gR2

and working on creating dynamic menu from database table ,

  1. for this i have  two tables in database one fro Modules and other is for SubModule 
  2. the Module table is main table as master and the submodule is child , i have create viwlink between these two tables and impliment my logic
  3. i have successfully able to create the main menu by following these tutorial  "http://biemond.blogspot.com/2008/11/dynamic-menu-based-on-roles-database.html"
  4. but when i try to add the menu item (subModule) in corresponding menu (module)  then this not working ,

the problem is 

how can i get the child rows of a child view by using parent view through bean

here is the modified bean according to my requirement .

where i am wrong ??

public class MenuBean implements Serializable {

    private RichMenuBar initmenu;

    public void createMenu(PhaseEvent phaseEvent) {

       

        // check the menu is already added 

        AppModuleImpl menuAM = getAm(); 

        System.out.println("in cretae menu metode");

                boolean addMenu = true; 

                for (Iterator iterator = initmenu.getChildren().iterator(); iterator.hasNext();) { 

                    UIComponent component = (UIComponent) iterator.next(); 

                    if ( component.getId().startsWith("menuId")){ 

                        addMenu = false; 

                    } 

                }  

                if (addMenu) {

                    MyMenuImpl menuView =  (MyMenuImpl)menuAM.getMyMenu1(); 

                    SubMyImpl  Sub = menuAM.getSubMy1();

                    menuView.executeQuery(); 

                    while (menuView.hasNext()) { 

                        MyMenuRowImpl menuItem =  (MyMenuRowImpl)menuView.next(); 

                        System.out.println("in finding child");

                      

                     

                        Boolean menuFound = false; 

                        RichMenu menu = new RichMenu(); 

                        String menuId = "menuId" + menuItem.getModId().toString(); 

         

                        // check if the main menu is already added 

                        for (Iterator iterator = initmenu.getChildren().iterator(); iterator.hasNext(); ) { 

                            UIComponent component = (UIComponent)iterator.next(); 

                            if (component.getId().equalsIgnoreCase(menuId)) { 

                                menuFound = true; 

                                menu = (RichMenu)component; 

                            } 

                        } 

                        if (!menuFound) { 

                            // new main menu 

                            RichMenu newMenu = new RichMenu(); 

                            newMenu.setId(menuId); 

                            newMenu.setText(menuItem.getMenuName()); 

                            System.out.println("the menu " + menuItem.getMenuName() );

                            //newMenu.setIcon(menuItem.getMenuIcon()); 

                            initmenu.getChildren().add(newMenu); 

                            menu = newMenu; 

                        } 

                        //---------------------------------------------------------------------------------------

                        RowIterator submod = menuItem.getSubMy1();

                      

                        while (submod.hasNext()){

                            SubMyRowImpl subMenu = (SubMyRowImpl)menuItem.getSubMy1();

                            Row subRow = submod.next();

                            String subName = (String)subRow.getAttribute("Sub");

                           

                           

                        Boolean menuItemFound = false; 

                        String menuItemId = subName;

                        // check if the menu item is already added 

         

                        for (Iterator iterator = menu.getChildren().iterator(); 

                             iterator.hasNext(); ) { 

                            UIComponent component = (UIComponent)iterator.next(); 

                            if (component.getId().equalsIgnoreCase(menuItemId)) { 

                                menuItemFound = true; 

                            } 

                        } 

                        if (!menuItemFound) { 

                            RichCommandMenuItem richMenuItem = new RichCommandMenuItem(); 

                            richMenuItem.setId(menuItemId); 

                            richMenuItem.setText(subName); 

                            System.out.println("the sub value name" + subName);

                           // richMenuItem.setActionExpression(getMethodExpression(menuItem.getAction())); 

                            //richMenuItem.setIcon(menuItem.getIcon()); 

                            menu.getChildren().add(richMenuItem);  

                        }

                        }

                     

                      

                    } 

                    menuView.remove(); 

                } 

      

      

   

    }

   

  

               }

}

any idea ???

This post has been answered by ZeeShan Ali Shoban on Mar 30 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 27 2016
Added on Mar 29 2016
8 comments
1,649 views