DataModel is not shared between nodes

Note that the ItemListener will fire for a number of different reasons:
See ItemEvent docs: ItemEvent (Java Platform SE 7 )

Perhaps you should add the following to ensure the event only actually fires, when the user selected an item.

if(e.getStateChange == ItemEvent.SELECTED){
   // Do the magic
}
1 Like

After the robot program starts, will the URCap node’s DataModel be unified to one value?
We added several same URCap nodes as above gif and set different values ​​of each DataModel.
However, when the robot program is executed, the DataModel values ​​are unified into one.

I would like to know the solution to the above question.
please answer about my question.

@aofk159 i understand you adress a problem that has nothing to with sharing data between the nodes (which is explained above) so,
how do you trigger your data model inside the urcap entities? basically, for any UI Input all you need to do is to call model.set with every change (UI Input Button etc.) and (most importantly) call model.get with the specific key on openView(). The model Data will also be saved when you save your program. This way, it should be working with multiple urcaps of the same type

The current situation is like this.
After adding the same two URCaps, we set the model’s Job ID(model key) value (1000,2000 …).
However, when the robot program is started, the model values ​​of the two URCaps are set to the model values ​​of the first URCap in the program.
Can not set specific variable values ​​in the data model?

can you show me every code snippet where you call: model.set() and model.get() ?

public void onOutputSelection(final String output) {
	undoRedoManager.recordChanges(new UndoableChanges() {
	
		@Override
		public void executeChanges() {
			model.set(JOB_ID, output);
		}
	});
} 

    jobList.addItemListener(new ItemListener() {

		@Override
		public void itemStateChanged(ItemEvent e) {
			if(e.getStateChange() == ItemEvent.SELECTED) {
				provider.get().onOutputSelection((String) e.getItem());
			}
		}
	});

int job_id = model.get(JOB_ID, DEFAULT_JOB_ID);

This is the model set, get part of my code.

Can you give me answers to my code?

If it is the same node, does it have the same value for one model value?
If the same URCap is contained in each of the parent node’s child nodes, is it a different class?

it should be working fine. Even if it’s a copied URCap Node it has its own Datamodel. I would check if your model.set and model.get functions are called well e.g. on openView()/ closeView() and save the right information or won’t reset to defaults.
Putting any URCap in a Subtree should also not lead to any problems with its datamodel.

2 Likes

Thank you. I noticed that it worked well before I started the robot program. However, when a robot program starts, it does not have its own data model but has the same value as one data model.

Hello,

Although the value of the URCap node model is set to something else, the specific value of the model is fixed to one value in the robot program script. How can I make scripts have different values for each URCap node?