Skip to Content

attachPatternMatched not triggering First Time


We are using Object Page and for blocks we have defined separate controllers. Object controller does trigger method attached using attachPatternMatched but block controllers don't trigger first time. But from next object navigation it starts working.

I was using 1.60 UI5 version and today got upgraded to 1.71.11 and the apps stopped working for first time user hits Customer Navigation.

It was working just fine in 1.60....

Any thoughts?

Object Controller

this.getRouter().getRoute("object").attachPatternMatched(this._onObjectMatched, this); - All good...

Block Controller

this.getRouter().getRoute("object").attachPatternMatched(this._onBlockGeneralC, this); - this one starts triggering from next time. But first load not triggering

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Posted on Jul 07 at 02:32 PM

    Hi Hari,
    could check following:

    1. Set a break point when you perform the attach in the block controller

    2. Set a break point when in _onObjectMatched in the object controller

    I guess the navigation is triggered before the attaching happened.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 08 at 06:23 AM

    Hi Hari,
    what do you mean with "its not triggering". Is Step 2 (_onObjectMatched) called before Step 1 (attach in the block controller)?

    Would be nice if you could share a code snippet which reproduces the issue.

    Add a comment
    10|10000 characters needed characters exceeded

    • Sure Florian...Here's code snippet.

      onInit method of Block Controller

      onInit: function(){
      console.log("BlockGeneral ==> onInit");
      this.getRouter().getRoute("object").attachPatternMatched(this._onBlockGeneralC, this);
      _onBlockGeneralC: function(oEvent){ 
      console.log("BlockGeneral ==> _onBlockGeneralC");

      Here....Debugger stops @init method for first time and but skips _onBlockGeneralC execution.

      From second time it starts call _onBlockGeneralC.

      Interesting part again is i have same code used in 1.60 version and it works....

      Please see if i miss anything. If you want any additional code snippet reply back. Thanks

  • Posted on Jul 08 at 08:03 AM

    Thanks for clarification. Yes, it looks like the execution order changed between these two versions. The onInit of the blockcontroller happens later than the first navigation.

    Another developer had a simuluar issue and solved it:

    I would recommend to open a support ticket asking for why the object page changed the execution order.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 08 at 08:08 AM

    Another workaround would be to execute the this._onBlockGeneralC in the onInit after attaching to the route. So, the code is executed at the first time also.

    Add a comment
    10|10000 characters needed characters exceeded

    • Yes...I might need help there....How can i access the Object Parameters in inInit of Block Controller? I just started with UI5 6 months back.

      Is it good idea to define a method in base controller and dump those parameters in Globals and read in inInit. Any better idea?

      I have raised yesterday support ticket....

      customer = oEvent.getParameter("arguments").Customer,

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.