Skip to Content
avatar image
Former Member

Display Fragment on View

I want to display a fragment on top of a View. Which will allow user to enter his credentials. For this, I created a home page, where I'm displaying the data and I created a login page (as a fragment). I'm following this approach because, I have implemented side menu on root view level and if I create a login page as normal page, then root view side menu will be displayed on login page as well and I dont want this.

So, I've created home view where I'm displaying business data and opening login page as a popup on home page. I'm having 2 challenges here.

The first challenge was to display the popup without any interaction of the user. I called "attachDisplay" method in "onInit" life cycle method and this is opening and closing the fragment immediately. To over come this, I simulated button "press" event (created button at runtime), in "onAfterRendering" life cyle method. Now, I can see the popup, problem solved and here comes the second challenge.

After entering uid/pwd, when i click on login, the event handler method of the fragment is not triggering.

Code to simulate button event trigger

   this.oButton = new Button({
     	id: this.getView().createId("logonButton"),
     this.oButton.firePress();  //("press"); 

code to open fragment.

    		this.getDialog = sap.ui.xmlfragment("logonPage", "mabothulaMaruthi.view.login", this);
login.jpg (50.3 kB)
Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    May 23, 2018 at 06:24 PM

    set a variable on the controller to identify if the view 'onAfterRendering' is called first time or not.

    Check the below plunker sample code

    Add comment
    10|10000 characters needed characters exceeded