If you want to do runtime injection, it isn't that hard. You just need to remember that you're going to inject a TREE, not just one block. (well, in 99% of cases, anyway.)
However, this is all going to work vastly better if you do it in Java. The best approach there is to go to OpenNTF.org, and get the XPages Extension Library source code. Then look for components like Tooltips or Dialogs.
It's a more complex issue than can be addressed in a single forum post.