# Looking for help with TagBrowseTree component

**URL:** <https://forum.inductiveautomation.com/t/looking-for-help-with-tagbrowsetree-component/19288>\
**Category:** Module Development\
**Created:** [August 16, 2018, 6:25pm UTC](https://forum.inductiveautomation.com/t/looking-for-help-with-tagbrowsetree-component/19288 "2018-08-16T18:25:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike.viens](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mike.viens/32/5182_2.png) [@mike.viens](https://forum.inductiveautomation.com/u/mike.viens)\
**Post date:** [August 16, 2018, 6:25pm UTC](https://forum.inductiveautomation.com/t/looking-for-help-with-tagbrowsetree-component/19288/1 "2018-08-16T18:25:47Z")

</div>

I am trying to use the TagBrowseTree component from **within Java**. I can get the component to display but it contains the wrong data, which is the default items from Java’s TreeModel (colors, sports, food, etc.).

When I drop a TagBrowseTree component onto a new designer window, these same items are BRIEFLY displayed, but then very quickly replaced with the actual tag values. What needs to be done to use proper TreeModel for TagBrowseTree?

I tried searching the forums, looking at the SDK documention, and even looking at the SDK examples on GitHub. I found nothing to help.

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [August 16, 2018, 7:22pm UTC](https://forum.inductiveautomation.com/t/looking-for-help-with-tagbrowsetree-component/19288/2 "2018-08-16T19:22:48Z")

</div>

It sounds like you want the standard tree view control and not the TagBrowseTree  
They are different controls in the Designer control tree.

---

<div class="post-metadata">

**Author:** ![mike.viens](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mike.viens/32/5182_2.png) [@mike.viens](https://forum.inductiveautomation.com/u/mike.viens)\
**Post date:** [August 17, 2018, 6:05pm UTC](https://forum.inductiveautomation.com/t/looking-for-help-with-tagbrowsetree-component/19288/3 "2018-08-17T18:05:07Z")

</div>

I appreciate the reply, however I don’t see how using a simple Tree component will get me all of the tags to be populated in it. Could you please provide an example?

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [August 18, 2018, 11:27am UTC](https://forum.inductiveautomation.com/t/looking-for-help-with-tagbrowsetree-component/19288/4 "2018-08-18T11:27:43Z")

</div>

Sorry, from your post it sounded like you wanted to use a treeview for something other than tags,  
I will defer to developers.

---

<div class="post-metadata">

**Author:** ![mike.viens](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mike.viens/32/5182_2.png) [@mike.viens](https://forum.inductiveautomation.com/u/mike.viens)\
**Post date:** [August 20, 2018, 3:37pm UTC](https://forum.inductiveautomation.com/t/looking-for-help-with-tagbrowsetree-component/19288/5 "2018-08-20T15:37:21Z")

</div>

I work for Sepasoft and we are creating some modules. In Java code, I need to be able to replicate the Tag Selector Tree component. That is what I am trying to do.

---

<div class="post-metadata">

**Author:** ![salbrechtsen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/salbrechtsen/32/18660_2.png) [@salbrechtsen](https://forum.inductiveautomation.com/u/salbrechtsen)\
**Post date:** [August 29, 2018, 11:13pm UTC](https://forum.inductiveautomation.com/t/looking-for-help-with-tagbrowsetree-component/19288/6 "2018-08-29T23:13:11Z")

</div>

Through some trial and error, this worked for me, although I don’t know if this is the best way because it requires passing in the ClientContext every time.

```auto
import com.inductiveautomation.factorypmi.application.binding.VisionClientContext;
import com.inductiveautomation.factorypmi.application.components.TagBrowseTree;

public class MyTagBrowseTree extends TagBrowseTree{
    
    public MyTagBrowseTree() {
        super();
    }
        
    public MyTagBrowseTree(VisionClientContext context) {
        super();     
        
        setContext(context);
        setRootNodePath("");
        setShowRootNode(false);
        
        startupModel();
    }   
    
}

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 30, 2018, 12:36am UTC](https://forum.inductiveautomation.com/t/looking-for-help-with-tagbrowsetree-component/19288/7 "2018-08-30T00:36:10Z")

</div>

You don’t need to initialize with the context. It will be delivered to you when [startupComponent()](http://files.inductiveautomation.com/sdk/javadoc/ignition79/795/com/inductiveautomation/vision/api/client/components/model/AbstractVisionScrollPane.html#startupComponent-com.inductiveautomation.factorypmi.application.binding.VisionClientContext-) is called, and saved for you. Which is then retrievable with getAppContext(). Per that documentation, you should be overriding onStartup().

---

<div class="post-metadata">

**Author:** ![mike.viens](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mike.viens/32/5182_2.png) [@mike.viens](https://forum.inductiveautomation.com/u/mike.viens)\
**Post date:** [August 30, 2018, 4:00pm UTC](https://forum.inductiveautomation.com/t/looking-for-help-with-tagbrowsetree-component/19288/8 "2018-08-30T16:00:31Z")

</div>

Hi Phil,

Thank you for replying. I am not understanding your comment though. The `startupComponent()` method signature requires a `VisionClientContext` parameter. Are you able to execute this method without passing in the context?

So, instead of what Steve was suggesting with `setContext(context)`, how I got it working was to pass in the context like this:

```auto
TagBrowseTree tree = new TagBrowseTree();
tree.startupComponent(context);
```

The `context` was available through an existing module, so I just reused it.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 30, 2018, 4:03pm UTC](https://forum.inductiveautomation.com/t/looking-for-help-with-tagbrowsetree-component/19288/9 "2018-08-30T16:03:53Z")

</div>

Don’t call startupComponent() yourself. The container will call it for you when it starts up. startupComponent() will then call onStartup(). Override onStartup() to perform your actual tree configuration – don’t do it in the constructor.
