cancel
Showing results for 
Search instead for 
Did you mean: 

Correct way to implement Object Page Sections if each section has individual services

yogesh_beria
Explorer
0 Kudos

Hello,

I have an object page with multiple sections with lazy loading as true and using blocks implementation.

My scenario does not have a single oData from which all sections are created. Instead, all sections have their own services.

The problem is when to make the service call and refresh the data for the section.

1. The section is refreshed whenever the route changes by attaching the RoutePatternMatched change event handler.

2. I also make a call when the section is initialized on clicking it for the first time because the sections which were not initially loaded due to lazy loading will not have any data otherwise. (Because when the route changed, the section wasn't even present).

The problem here is that to make the call in the init method, I need the parameter from the URL (which is available in the event object in RoutePattern Matched event handler). This was also present in the main object page controller from where I access it.

But when the controller is initialized, it does not know that it is a section within the object page. So onInit does not know the view's parent and the object page cannot be accessed.
In onAfterRendering, I find the object page, get the url parameter saved there, and make the call.

Also, because with the data, the section would be rerendered (and onAfterRendering triggered again), I need to ensure that this part of onAfterRendering is executed only once so that it does not end up in an infinite loop.

Can it be implemented in a better way?

It does not also have direct access to the application's component because each section does not have a unique root for itself.

Regards,

Yogesh

Accepted Solutions (0)

Answers (0)