cancel
Showing results for 
Search instead for 
Did you mean: 

Display Fragment on View

Former Member
0 Kudos

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

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

code to open fragment.

_ShowLogonPopup:function(oEvent){    	
if(!this.getDialog){
    		this.getDialog = sap.ui.xmlfragment("logonPage", "mabothulaMaruthi.view.login", this);
    	}
    	this.getDialog.open(); 
} 

Accepted Solutions (1)

Accepted Solutions (1)

former_member365727
Active Contributor
0 Kudos

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

Check the below plunker sample code

https://embed.plnkr.co/vyVkwsvfaO24C8kVppeG/

Answers (0)