One more note.  The updateTree() call did work in Firefox, but not in IE6 or
IE7.


Matej Knopp-2 wrote:
> 
> Hi,
> 
> you shouldn't do target.addComponent(tree). You shouldo only call
> tree.upateTree() (or tree.updateTree(target), should do the same
> thing). Also you could consider using DefaultTreeModel.insertNodeInto
> instead of parent.addNode, as it automatically fires the listener for
> you.
> 
> Btw. I was thinking of some code I could actually run (so also the
> page with tree and the prebuit tree). Thus if this answer doesn't help
> your problem you can consider providing a quickstart project I can use
> to reproduce it.
> 
> -Matej
> 
> On Sat, Mar 15, 2008 at 12:57 AM, jeredm <[EMAIL PROTECTED]>
> wrote:
>>
>>  Here is the code that pops up a modal for the user to enter a new option
>> for
>>  a
>>  multiple choice question.  When the modal returns I add the object it
>> sends
>>  back to
>>  a node and then add the the node to the tree.  Finally, I refresh the
>> tree.
>>
>>  The BaseTreeNode is an extended DefaultMutableTreeNode. The
>>  model on my link tree is a set of BaseTreeNodes...so
>>  tree = new MWLinkTree("tree", new
>> DefaultTreeModel(rootBaseTreeNode)){...};
>>
>>  I don't know if this will be much more help.  Keep in mind that I had
>> 875
>>  nodes that were
>>  in an expanded state during the tests.  Thanks again for your help.
>>
>>
>>  MWAjaxSubmitLink newButton = new MWAjaxSubmitLink("newButton",
>> indicatorImg,
>>  feedback){
>>   private static final long serialVersionUID = 1L;
>>
>>   @Override
>>   protected void onSubmit(AjaxRequestTarget target, Form form) {
>>     ARGS.addParam("QuestionPk", option.getQuestionPk());
>>     modal.setContent(new
>> Exam_QuestionsNewOptionPanel(modal.getContentId(),
>>  ARGS));
>>
>>     modal.setWindowClosedCallback(new
>> MWModalWindow.WindowClosedCallback(){
>>       private static final long serialVersionUID = 1L;
>>
>>       public void onClose(AjaxRequestTarget target){
>>         QuestionOption newOption =
>>  (QuestionOption)ARGS.getParam("NewQuestionOption");
>>
>>         // Check to see if the action was canceled
>>         if(newOption != null){
>>           PageData passArgs = new PageData();
>>           passArgs.addParam("QuestionOption", newOption);
>>
>>           TreeNodeFactory factory = TreeNodeFactory.getObject();
>>           BaseTreeNode newNode = factory.buildReplaceNode(treePanel,
>>  StringUtil.truncateForList(newOption.getShortDesc(), 18),
>> "QuestionOption",
>>  newOption, passArgs, "Exam_QuestionsOptionPanel", "swapPanel",
>>  TreeNodeState.NONE);
>>
>>           // ADD NEW NODE HERE --------------------------------
>>           // the node is the selected node
>>           ((BaseTreeNode)node.getParent()).add(newNode);
>>
>>           // REFRESH THE TREE HERE -----------------------------
>>
>>           DefaultTreeModel model =
>> (DefaultTreeModel)tree.getModelObject();
>>           int[] changes = new
>>  int[]{model.getIndexOfChild(newNode.getParent(), newNode)};
>>           model.nodesWereInserted((TreeNode)newNode.getParent(),
>> changes);
>>
>>           target.addComponent(tree);
>>         }
>>       }
>>     });
>>
>>     modal.show(target);
>>
>> 
>> target.appendJavascript("document.getElementById('answerDesc').select()");
>>     target.addComponent(this.feedback);
>>   }
>>  };
>>  form.add(newButton);
>>
>>
>>
>>  Matej Knopp-2 wrote:
>>  >
>>  > Sorry, I meant the updateTree method. Anyway, 23 seconds seems quite a
>>  > lot to me. Any chance you could submit a stripped down example I can
>>  > take a look at?
>>  >
>>  > -Matej
>>  >
>>  > On Fri, Mar 14, 2008 at 6:01 PM, jeredm <[EMAIL PROTECTED]>
>>  > wrote:
>>  >>
>>  >>  I added the following code and it correctly refreshed the node:
>>  >>
>>  >>  DefaultTreeModel model = (DefaultTreeModel)tree.getModelObject();
>>  >>  int[] changes = new int[]{model.getIndexOfChild(parentNode,
>> newNode)};
>>  >>  model.nodesWereInserted((TreeNode)parentNode, changes);
>>  >>
>>  >>  The time difference seemed close to invalidateAll(). 
>> invalidateAll()
>>  >> took
>>  >>  about 24 seconds while the new method took 23 seconds.  It is likely
>>  >> that
>>  >>  they are the same speed as I was counting in my head and only ran
>> the
>>  >> test
>>  >>  once.  The test was with 875 nodes open in the tree...so that is
>> about 1
>>  >>  second for every 35 nodes.  I think a typical user will have about
>> 90
>>  >> nodes
>>  >>  in the tree at the most and 30 on average, so between 2.5 and 1
>>  >> second(s) to
>>  >>  wait for the node to display after clicking save.  The speed I am
>> seeing
>>  >> may
>>  >>  just be the time it takes to render in the browser.  If that is the
>>  >> case,
>>  >>  then I am fine with it.  I just want to make sure I am correctly
>>  >> updating
>>  >>  the tree and not making it work harder than it needs to.
>>  >>
>>  >>  I also tried tree.updateTree() after I added the node and found that
>> it
>>  >> did
>>  >>  not solve the refresh problem.  When you said call update() on the
>> model
>>  >>  what function should I be calling (I don't see update in the API)?
>>  >>
>>  >>  Thanks for your help!
>>  >>
>>  >>
>>  >>
>>  >>
>>  >>  Matej Knopp-2 wrote:
>>  >>  >
>>  >>  > Make sure your tree model fires the appropriate events when your
>> tree
>>  >>  > is modified. The Tree implementation should properly update the
>>  >>  > changed portions of tree (assuming you call the update() method).
>>  >>  >
>>  >>  > -Matej
>>  >>  >
>>  >>  > On Fri, Mar 14, 2008 at 1:27 AM, jeredm
>> <[EMAIL PROTECTED]>
>>  >>  > wrote:
>>  >>  >>
>>  >>  >>  I have a LinkTree where am adding new nodes via AJAX where the
>> node
>>  >> is
>>  >>  >> not
>>  >>  >>  visually refreshing until I call myLinkTree.invalidateAll();. 
>> The
>>  >>  >> problem
>>  >>  >>  is that the tree refresh takes too long when I have a bunch of
>> nodes
>>  >>  >>  displayed.  AbstractTree.invalidateAll() appears to "redraw" the
>>  >> whole
>>  >>  >> tree,
>>  >>  >>  but I only need to "redraw" the single node (I may be wrong on
>> this
>>  >> and
>>  >>  >> it
>>  >>  >>  may be working exactly as I need it to, but it is slow).
>>  >>  >>
>>  >>  >>  My basic setup is a tree on the left that dynamically swaps out
>>  >> panels
>>  >>  >> via
>>  >>  >>  AJAX on the right based on the node selected.  The tree itself
>> only
>>  >>  >> starts
>>  >>  >>  with the root and first children.  All first children load their
>>  >> child
>>  >>  >> nodes
>>  >>  >>  via an AJAX call on expand.  These nodes will correctly refresh
>> as
>>  >> the
>>  >>  >> nodes
>>  >>  >>  are added and then the parent is expanded.  I cannot collapse
>> and
>>  >>  >> re-expand
>>  >>  >>  the parent node in this case as expanding a node would cause the
>>  >> tree to
>>  >>  >>  close nodes the user has already opened.  What I need is to be
>> able
>>  >> to
>>  >>  >>  insert a node like so...
>>  >>  >>
>>  >>  >>  - My Root
>>  >>  >>   |--First Child
>>  >>  >>       |-- First Grandchild
>>  >>  >>       |-- NEW NODE
>>  >>  >>       |-- Last Grandchild
>>  >>  >>
>>  >>  >>  I need the First Grandchild and Last Grandchild to already be
>>  >> expanded
>>  >>  >> and
>>  >>  >>  displaying before I add NEW NODE.
>>  >>  >>
>>  >>  >>  --
>>  >>  >>  View this message in context:
>>  >>  >>
>> http://www.nabble.com/LinkTree-Node-Refresh-tp16041813p16041813.html
>>  >>  >>  Sent from the Wicket - User mailing list archive at Nabble.com.
>>  >>  >>
>>  >>  >>
>>  >>  >>
>>  >> ---------------------------------------------------------------------
>>  >>  >>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>>  >>  >>  For additional commands, e-mail: [EMAIL PROTECTED]
>>  >>  >>
>>  >>  >>
>>  >>  >
>>  >>  >
>>  >>  >
>>  >>  > --
>>  >>  > Resizable and reorderable grid components.
>>  >>  > http://www.inmethod.com
>>  >>  >
>>  >>  >
>> ---------------------------------------------------------------------
>>  >>  > To unsubscribe, e-mail: [EMAIL PROTECTED]
>>  >>  > For additional commands, e-mail: [EMAIL PROTECTED]
>>  >>  >
>>  >>  >
>>  >>  >
>>  >>
>>  >>  --
>>  >>  View this message in context:
>>  >> http://www.nabble.com/LinkTree-Node-Refresh-tp16041813p16048613.html
>>  >>
>>  >>
>>  >> Sent from the Wicket - User mailing list archive at Nabble.com.
>>  >>
>>  >>
>>  >> 
>> ---------------------------------------------------------------------
>>  >>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>>  >>  For additional commands, e-mail: [EMAIL PROTECTED]
>>  >>
>>  >>
>>  >
>>  >
>>  >
>>  > --
>>  > Resizable and reorderable grid components.
>>  > http://www.inmethod.com
>>  >
>>  > ---------------------------------------------------------------------
>>  > To unsubscribe, e-mail: [EMAIL PROTECTED]
>>  > For additional commands, e-mail: [EMAIL PROTECTED]
>>  >
>>  >
>>  >
>>
>>  --
>>  View this message in context:
>> http://www.nabble.com/LinkTree-Node-Refresh-tp16041813p16062572.html
>>
>>
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>>  ---------------------------------------------------------------------
>>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>>  For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> 
> 
> -- 
> Resizable and reorderable grid components.
> http://www.inmethod.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/LinkTree-Node-Refresh-tp16041813p16097052.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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

Reply via email to