[Logo] Enterprise Client Community
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
generate menubar dynamically out of funtiontree  XML
Forum Index -> Development
Author Message
hartmann

Power User

Joined: 20/08/2008 16:27:48
Messages: 73
Offline

Hi,

we use the workplace concept to define a functiontree through xml configuration file.

Now we have users who want a menubar instead of the functiontree. And they want to choose this option dynamically in tha application.

What would be the most convenient way to do that?

I tried to build it up from the functiontree, but unfortunately some relevant attributes (name, actionslistener, ...) are not accessable.

Regards, Horst
hartmann

Power User

Joined: 20/08/2008 16:27:48
Messages: 73
Offline

Hi,

I think it would be enough if I could access the attributes 'text' and 'jspPage'.

Regards
Horst
hartmann

Power User

Joined: 20/08/2008 16:27:48
Messages: 73
Offline

Hi again,

I've nearly solved the problem myself:

Code:
 private void initDynamicMenuBar(List<FunctionTree> functionTrees) {
         dynamicMenuBar = new ROWDYNAMICCONTENTBinding();
         dynamicMenuBar.setContentNodes(new ArrayList<ComponentNode>());
         MENUBARNode menuBarNode = new MENUBARNode();
         dynamicMenuBar.getContentNodes().add(menuBarNode);
         for (FunctionTree functionTree : functionTrees) {
             FIXGRIDTreeBinding<FunctionNode> binding = functionTree.getFtree();
             FunctionNode item = (FunctionNode) binding.getRootNode();
             addMenuNode(menuBarNode, item);
         }
     }
 
     private void addMenuNode(ComponentNode parentNode, FunctionNode item) {
         if (hasChildNodes(item)) {
             MENUNode node = new MENUNode();
             parentNode.addSubNode(node);
             node.setText(item.getText());
             for (FIXGRIDTreeItem childItem : item.getChildNodes()) {
                 addMenuNode(node, (FunctionNode) childItem);
             }
         } else {
             MENUITEMNode node = new MENUITEMNode();
             parentNode.addSubNode(node);
             node.setText(item.getText());
             node.setImage(item.getImage());
             node.setReference(item.getJspPage());
             node.setActionListener("#{d.WorkplaceMBean.onShowPage}");
         }
     }
 
     private boolean hasChildNodes(FunctionNode item) {
         return (item.getChildNodes() != null) && (item.getChildNodes().size() > 0);
     }


But there is still one problem: the rootentries in the menubar have the text 'default' instead of the text defined in the configurationfile.

Regards
Horst
hartmann

Power User

Joined: 20/08/2008 16:27:48
Messages: 73
Offline

Hello Captain (I know i should normally ask the Community, but I think noone else but you can give me an answer ),

is there any reason, why the rootNodes of the FIXGRIDTreeBinding return 'default' when calling 'getText()' while for subnodes it works fine? Or is it just a mistake?

Regards

Horst
 
Forum Index -> Development
Go to:   
Powered by JForum 2.1.6 © JForum Team