I posted a question a few days ago on how to best deal with frames, in
particular how to pass arguments between a tree view in one frame and
a list view in another.  I didn't get any takers.

I finally determined that there was no good way other than to use
plain-old javascript to push values from the tree up to the parent
frame, where they are dispersed to the other frames.

I wanted to use LinkTree, but really didn't need most of the features
other than the look and feel.  I just needed to be able to insert an
onclick link that would pass a value to my parent frame.

After a lot of digging I came up with a solution that worked, but
seems verbose for the job I'm attempting.  My question for dear reader
is this:  Can you propose an more concise solution?


public class CategoryTree extends LinkTree
{
        @Override
        protected Component newNodeComponent(String id, IModel model)
        {
                return new LinkIconPanel(id, model, CategoryTree.this)
                {
                        private static final long serialVersionUID = 1L;

                        protected void onNodeLinkClicked(TreeNode node, 
BaseTree tree,
AjaxRequestTarget target)
                        {
                                super.onNodeLinkClicked(node, tree, target);
                                CategoryTree.this.onNodeLinkClicked(node, tree, 
target);
                        }
                        
                        protected Component newContentComponent(String 
componentId,
BaseTree tree, IModel model)
                        {
                                Label l = new Label(componentId, model)
                        {
                                private static final long serialVersionUID = 1L;
                                
                        @Override
                        protected void onComponentTag(ComponentTag tag)
                        {
                                super.onComponentTag(tag);
                                tag.put("onclick",
"parent.notifyViews(this.getAttribute('catalogid'))");
                                
                        }
                        };
                
                        DefaultMutableTreeNode n = 
(DefaultMutableTreeNode)model.getObject();
                        
                        if (n.getUserObject() instanceof EcCategoryTreeNode)
                        {
                        EcCategoryTreeNode ec = 
(EcCategoryTreeNode)n.getUserObject();
                        l.add(new SimpleAttributeModifier("catalogid", "" + 
ec.getId()));
                        }
                        
                        return l;
                        };
                };
        }

        public CategoryTree(String s, TreeModel tm)
        {
                super(s,tm);
                this.setLinkType(LinkType.REGULAR);
        }

}

Devin

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to