Universal Robots Forum

After deleting and re-deploying the same URCap, the components are having the same values


I have a URCap which has multiple ComboBoxes. The ComboBoxes are defined as private.

I add a few objects to the ComboBoxes when pushed a button.

But after removing the URCap from TreeNode and re-deploying them, the ComboBoxes have the objects I have added before deleting.

The values of the components I altered stayed with the URCap after removing them. Or when I add another one of the same URCap, the values stay the same.

I don’t know if I was able to explain the issue but the values of the components stay the same for different instances of the same URCap.

How can I reset them?

Thank you,


Where are the combo boxes you are referring to? Are they in program nodes or in the installation node? If you are loading the same saved program before and aftrer reinstallation of the URCap, then you should expect the program to remember the values in the combo box, assuming you use a program nodes DataModel to repopulate the combo boxes… Likewise if you have saved an installation file, if you remove the URCap and reinstall, the installation file will keep the data from the uninstalled URCap saved so that it can be re applied upon reinstallation, and again if these combo boxes are populated using data you save to the installation’s DataModel, this is the expected behaviour.

The other possibility assumes that your problem is with the UI not changing when clicking between different instances of different program noes of the same type. This is because whilst each program node has its own DataModel that is unique to a given program node instance, there is only a single instance of the view class that is used by each instance of that program node. This means that in order to update the UI for each program node, you should save information to a program nodes DataModel and then in `openView(), use the information saved in the data model to change any required UI components,

We would need more inforamtion about the circumstances under which this is happening in order to help confirm the cause of the problem you are seeing, hopefully 1 of the 2 above solutions above helps.

I have declared the combo boxes in the ProgramNodeView. I didn’t use DataModel to populate the ComboBoxes.

private String[] forCombo = {"1", "2", "3"};

private JComboBox<String> comboBox = new JComboBox<String>(forCombo);

private String[] forCombo1 = {"first", "1", "2", "last"};

private JComboBox<String> comboBox1 = new JComboBox<String>(forCombo1);

As far as I know, DataModel can’t be used in ProgramNodeView. When I tried to add it like this in the ProgramNodeService:

public dWellView createView(ViewAPIProvider apiProvider, DataModel model) {
// TODO Auto-generated method stub
return new dWellView(apiProvider, model);

An error occured.

I believe what you stated above is the only solution but how to do that?

I don’t have any installation nodes in my program.

The error occurs since as I stated, there is only ever 1 instance of the programNodeView, and so the view can be given a specific instance of a DataModel. Think of the view class as “static”, for want of a better word.

You will need to fetch the specific contribution instance in the view class in order to save to the currently active DataModel. This will be performed in a listener of some sort which I assume you already have implemented (if not have a look at this post) to perform actions when changes to the comboBox occur. You need to use the ContributionProvider that is passed to the view class in buildUI(). The contribution provider has a pethod called get() which returns the current contribution instance. From there, make a public method in your contribution class that passed and can save any necessayry data to the data model.


I have created 2 arrays of String in ProgramNodeView.

Then I have created a function in ProgramNodeContribution:

private static final String COMBO = "comboBox";

private static final String COMBO1 = "comboBox1";

private static final String[] DEF_COMBO = {"default_value"}; 

public void setComboBoxesC(final String[] combo1, final String[] combo) {

    undoRedoManager.recordChanges(new UndoableChanges() {
        public void executeChanges() {

            model.set(COMBO1, combo1);
            model.set(COMBO, combo);
    view.setComboBoxes(model.get(COMBO1, DEF_COMBO), model.get(COMBO, DEF_COMBO));

There is another function called setComboBoxes in ProgramNodeView that sets the String arrays to the comboBoxes:

I believe I used the DataModel as you have instructed but the same issue still persists. When I add another instance of this same Node the comboBoxes have values which were set in the instance before this.

Am I doing something wrong?

You will need to call view.setComboBoxes() in openView() of your contribution class to update them when adding/flicking between nodes. The UI objects stored in the view class will only ever change when they are told to do so (usually by the contribution) so you have to make sure to change them in openView() as well as in your listeners.

1 Like

I called the view.setComboBoxes() in openView() from ProgramNodeContribution as was told.

public String[] getModel1() {
    return model.get(COMBO1, DEF_COMBO1);

public String[] getModel() {
    return model.get(COMBO, DEF_COMBO);

public void openView() {
    view.setComboBoxes(getModel1(), getModel());

The function in ProgramNodeView which was called from ProgramNodeContribution is below.

public void setComboBoxes(String[] Combo1, String[] Combo) {
    comboBox1.setModel(new DefaultComboBoxModel<String>(Combo1));
    comboBox.setModel(new DefaultComboBoxModel<String>(Combo));

The same issue still persists. The items of Combo Boxes in a Node exist in another instance as well.

Also, the items in ComboBoxes are not updated automatically. They are updated after clicking another Node and clicking back to our Node which has ComboBoxes.


I found the problem. It was told that global variables should not be stored to the DataModels.

That was exactly what I was trying to do.

Instead of using global variable, I have used it an instance variable. There is no problem right now except for not auto-updating the items in comboBoxes.

Thank you for your time Sam

1 Like

Happy to help :slight_smile: