Changing view of a widget in Dashboard from the widget view

I have a view which is a Dashboard component. Let's call it Xview.

Each widget has a viewPath to another view and let's call that Yview.

I have a configuration table and a button in that Yview where i need to ultimately change the view of that specific widget in Xview from Yview.

Since i cannot set widget props of Xview from inside Yview, what is the proper way to do this using scripting?

Use message handlers.