Skip to main content

Is there a way to force a browser refresh from a procedures? 

 

My use case is to make it more apparent to application users that they are in a “training” mode.  Our thought, which we had done in WinUI, was to change the background color of the webui.    So when users load a training data set, I have a procedure that programmatically creates a CSS stylesheet that sets the app background to light-pink.  When they exit training mode, the procedure re-writes that file to be back to our default app background color.

If a user manually refreshes the browser, the new CSS file gets used and the color changes.  Yet the user has to manually refresh themselves. I haven’t found a way to refresh it via code. 

I tried “webui::RefreshAllWidgets” to see if that might force it, but I just get an AIMMS warning “awf.data.aimms.session:WinUI pages are not available when project is setup for WebUI.” when I call it. 

 

 

Hello Marcel,

I can’t really tell you why calling webui::RefreshAllWidgets would cause that particular warning message. Because it just shouldn’t, and I hope some other part of your model contains remainders of your original setup/idea/refreshes when applied to the WinUI app this WebUI app was maybe built ‘from’.

But this is not your real problem or solution for it anyway. Since refreshing the widgets does not work by reloading the page like in a ‘full browser page refresh’. Which is indeed needed if you know that you’ve changed one of your stylesheets.

But in order to do that, some trigger would need to be in place, in the browser, like a piece of script that:

  • acts like a custom widget that responds to one of its options changing (by reloading or by doing what the 3rd option suggests)
  • monitors page contents for a certain widget-uri to be added to the page and then adding a click handler to it which does the browser refresh. Or,
  • does something like the previous, but instead does not reload, but sets the new value of the css custom property (‘theming variable’) that dictates the background color. That would work instantly.

The first is the most ‘AIMMS-like’. But part of our kind of deprecated Custom Widgets setup…

 

The page monitoring needed for option 2 or 3 is potentially a little bit harmful for overall page performance, but you might not notice it at all either.

 

Do you have a certain Widget that is the actual trigger for leaving or entering the training mode? Like a button on a specific page? Do you need some pointers or a skeleton script to get you going in that direction?


@MarcelMueller can you check if you have any XML pages in your application? Being old WinUI pages or just data pages saved under Main Project > Pages?


Reply


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

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