Skip to main content
Declined

Automatic Widget Renaming in JSON file

Related products:WebUI
  • March 3, 2023
  • 5 replies
  • 44 views

Diego Perez-Urruti
AIMMS Partner
Forum|alt.badge.img+4

It appears that renaming a widget changes its name attribute, but not the original name of the widget in the underlying JSON file. And it appears the CSS refers to the latter, whcih might lead to und

If you dig into the webui.json file, you'll see the widget object for the “Diego” Table as:

"widgets/Diego_Table"

with attribute:

    "name": {      "literal": "TA_Diego"    },

Would it be possible to make it so that the “rename widget” functionality also updates the original widget name in the JSON file?
Maybe there is a good reason why it doesn’t so just submitting it here as an idea 😀

5 replies

Edo Nijmeijer
AIMMSian
Forum|alt.badge.img+4

Hi Diego, thanks for posting and sorry for not having bumped into it earlier, myself.

I think your explanation clearly shows where the current way of renaming Widgets is inconvenient for the App Developer perspective: if you have any references to that Widget elsewhere already, those references will be harder to understand.

I typed ‘understand’ there on purpose, because the more important things is: they will also keep in working!

Because despite the ‘name’ key in the JSON file, this is of course a unique identifier for the Widget. It is created when you first create the widget, making sure it is unique at that time (which is kind of easy to do then) by adding a suffix if needed.

This identifier is then used where ever it needs to be referenced. So for example when connecting the Widget to a page (in the same JSON file), when specifying custom styling for it (in your external css files, using the widget uri data attribute) or maybe even when writing procedures (where pages use the same kind of naming/id scheme and pages are a widget, technically).

So if the (displayed) name of the widget would have to be equal to the id, then when renaming it we would need to:

  • check if any other widget already has that name in use
  • edit all references

But even while checking the existence of the desired new name might be easy, we don’t really have access (in a straightforward or existing way) to all those other references I mentioned. For example: model code or CSS is not under control of the WebUI. This code is provided in a separate file by the developer, or of course maintained in the AIMMS desktop application.

And therefore a renamed ‘id’ could accidentally break your work done in the model. or break the styling of your application in WebUI. Even if we did have access to all of those references, the extent of the needed changes might also surprise you as a developer, finding many files changed upon a simple ‘rename’.

So when first choosing the ‘name’ of your widget, make sure you use something logical, because it will be the ‘id’ in the long term. This is a the first step in preventing confusion later on, when trying to reference that widget.

And with that, I’m afraid I’m basically saying that a change to WebUI, for this purpose, is kind of unlikely to happen. I hope you now see as to why I am saying that, and that it helps in making the right decisions early on in building your WebUI applications.

P.S. if you really want your ‘id’ to change, you of course still have the option to do so by manually replacing all occurrences in the webui.json file, but it then is your responsibility to make sure it is unique and that you take care of other ‘references’ too. Or stuff will break ;-)


Jess Es
Forum|alt.badge.img+6
  • Grand Master
  • September 26, 2023
NewDiscussion ongoing

Diego Perez-Urruti
AIMMS Partner
Forum|alt.badge.img+4

Thanks for the great expalanation Edo! Totally makes sense!


Madhu Krishnappa
AIMMSian
Forum|alt.badge.img+5

Thanks @Edo Nijmeijer for your input and for sharing the workaround to address this issue.

@Diego Perez-Urruti, considering the current priorities outlined in the WebUI Roadmap and other valuable items on our backlog, along with the existence of a workaround for this feature, I believe pursuing this idea is of very low priority. Therefore, I will be declining this feature request.

 


Madhu Krishnappa
AIMMSian
Forum|alt.badge.img+5
Discussion ongoingDeclined

Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator