URCap DropDownList not Updating Issue


I am creating a URCap and had some questions. If anyone can help that would be great!

I am using the DropDownList interface and I have things working, however I have an issue with the program node not updating its selected item with what is on the title.

In the image below when I first select the program node, they all start at OFF, which is correct. I change the S1 value from OFF to Yellow which produces line 3. However, when I create a new program node on line 4, the DropDownList doesnt update to all to Off, however it still keeps the Yellow in there.

How would I create it so it remembers that specific instance values and not change all of them?


Another question I have is im also trying to adjust the positioning of the dropdownlist to be on the right side of the stack light, however am having alot of issues with formatting the screen since many of the common HTML and CSS commands are not valid. Is there an easy way to move it like the picture below?


And my final question I wanted to have it so the when the operator changes the segment to a specific color that the section selected will change the stack light color. Since the HTML and CSS options are limited was there any way to do that? If I was to import color blocks, is it possible to make it visible and invisible when selected?

I have my contribution program and my html attached…

helloworld-1.0-SNAPSHOT (2).urcap (58.0 KB)
DOCTYPE html.pdf (31.3 KB)

Thanks alot!

1.) You need to store the selected option to the DataModel using model.set(), and you need to update the selected item of each dropdown in the openView() method with an appropriate model.get() function. So it should look something like:

myDropDown.setSelectedItem(model.get("DROP_DOWN_1_ITEM", "Off"));

This would ensure that newly created nodes return “Off” to the dropdown, since the model.get() lookup would not be able to find any matching keys.

2.) I have always used Java Swing for developing the CAPs. For that I tend to use a BoxLayout Manager. So I would create a horizontal box to hold the graphic, and the box that contains all your dropdowns. This can be very confusing to understand when you start out, but makes sense as you get used to it. There are other layout managers that may work better for your application. You can look these up online.

3.) You can react to the selectedItemChanged event of the dropdown box and color the boxes according to their selection. How you do this will depend on how you’ve made that graphic. I would probably have made it 5 individual boxes and then just tie each box to the corresponding dropdown and do a “box.setBackgroundColor(getSelectedColor)).” Not a real function, you’d have to define these, but should be possible, albeit a little clunky.

Thank you! I will try these