Page refresh when using Go To Page

I have a main nav menu for my app and I’m using Go To Page block in the navigation links. I use this block in logic because I need to pass parameters to pages. My issue is that when I am on a page, and I click the relevant link in the nav menu, the page doesn’t refresh, so Before Page Enter and/or Page Enter events doesn’t get triggered. Is there a way to force a page refresh when using Go To Page? Only solution I see is to use Open Web Page and encode URL parameters I need, but I prefer to ask. It seems to me that Go To Page should allow triggering of page-level events, but maybe it wasn’t thought of that way.

image

Hello @Marc_Chriqui

When you run GoToPage you are trying to go to another page or stay on the same page with changed query params (data input) only?

I need to support both. Going to another page seems to do a page load (which is good) however when Go To Page is called from the same page with different query params, I see the URL string change to reflect the new query params in the address bar, however the page does not reload.

In case when you need to stay on the same page, why force reload?

Here’s why, maybe you have a solution…

it is not clear to me what should happen when you click “Client 1” in the left sidebar. If the page you’re on has the structure and UI that you need, then it would be a matter of updating the data model of that page without reloading it.

It’s hard to update the page data model when Client 1 link is part of a reusable component that is on every page. Best I can do from what I see is to call Get Current Url to see which page I’m on (looking for “page=Organization”) and then decide how to interact with it - either call Go To Page or interact with the page data model. I’ll do that. Thanks.

if you do not change the current page, it doesn’t run the following handlers “OnPageEnter/OnPageLeave”.
It doesn’t happen because you actually do not leave/enter the page, you stay on the same page.

Instead, if you stay on the same page but you change query parameters you should change the “PageData” model and trigger loading new data according to the query. It would be the best way from the UX perspective when your customer won’t be waiting for a full reload when some data is changed.

However, I can propose you a workaround to do a full reload being on the same page:

Just add a CustomCode block right after the “GoToPage” block and in the CustomCode block add the following code:

location.reload()

Regards, Vlad

The workaround is exactly what I did. Thanks again.

1 Like

I’m back on this topic. The UX is not considered satisfactory when I call Go to Page then do page reload via custom code. The UI gets distorted as soon as I call Go to Page for some reason then the user has to wait for the entire page to reload.

Would it be possible for you to improve the core behavior of Go to Page when called from the page we’re trying to re-initialize? The URL + parameters seem to change, which is good, but the Page Enter handler does not run. It seems to me that a call to Go to Page should re-initialize the page and run the appropriate page handlers.

I can’t just update Page Data. I need to re-initialize the page with updated URL parameters because our users are using the browser Back button. If Go to Page is made to run properly when called from the same page to reload the page, everything would work perfectly.

Hi @Marc_Chriqui

I understand your issue but running “OnPageEnter” when the page name is not changed is not an option for several reasons:

  • it will be a breaking change and it might break already existing applications of our customers
  • it runs the “OnPageEnter” only when it renders the page and it doesn’t matter how it rich the page whether using the browser history (buttons back/forward) or using the “GoToPage” block, which just modifies the browser history
  • the “OnPageEnter” means it rendered a page with a specific name and if the page name was not changed the page is still alive and there is no sense to rerun the handler

However, I can see a reason to implement a new handler for a Page Component to notify a developer the page query was changed.
It could be “On Page Query” and it will be running between “onBeforePageEnter” and “onPageEntered” handlers and if the page name is the same then it will be running each time when the URL query is changed, there can be the following context blocks: “Previous Query” and “Next Query” to determine a diff

Does it make sense?

2 Likes

Yes, On Page Query with these two context blocks would be ideal! Hopefully you could add this soon. Please let me and/or the community when these will be available. Appreciated!

We have created an internal ticket(BKNDLSS-29286) and will inform you when it will be implemented.

1 Like

Hello @Marc_Chriqui

We added a new event handler “OnPageQuery”. We also added the following context blocks: “Previous Page Query” and “Page Query” to determine a diff.


Regards,
Inna

1 Like

Amazing! Thank you! It works great.