Skip to Content

Couldnt accesss 2nd fragment values from controller.

Hi,

I'm creating custom F4 help screens same as Smart Field with Value Help.

UI screen flow is from view1.view.xml->fragment1->fragment2.

For both fragment1 & fragment2, im calling from view1.controller.js and i had used addDependent().

However i'm struck while accessing fragment2 UI element values in view1.controller.js and couldnt add a panel to fragement2 dyanamically.

Any advice is deeply appreciated.

PS: Please find attached screenshot for reference.

Regards,

Natarajan

f4help.png (23.7 kB)
f4help.png (23.7 kB)
Add comment
10|10000 characters needed characters exceeded

  • It looks like there is no issue with the approach you are are following, you should provide the code that you have written to analyze the error like the places where you are instatiating the fragment and where you are trying to read the data.

    BR, Mahesh

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Dec 24, 2018 at 11:48 AM

    Usually, the problem is no about the addDependent. That method allows you to add the control (in this case the fragment/dialog) to the current view lifecycle. It means that the control will react to the same event of the view. So when you destroy the view, the fragment/dialog will be automatically destroyed.

    I think that the issue is when you create the fragment. Here's a snippet of code that will help you:

    		onSalesOrderItemDialogOpen: function(bFromCreate, oItemBindingContextPath) {
    			this._fromCreate = bFromCreate;	
    			this.getView().getModel("data").setProperty("/salesOrderItemFormCreate", bFromCreate);
    			
    			if (!this._oEditDialog) {
    				this._oEditDialog = sap.ui.xmlfragment(this.getView().getId(), "com.techedge.training.SAPUI5Training.view.fragment.dialog.SaleOrderItemEditDialog", this);
    				this.getView().addDependent(this._oEditDialog);
    			}
    			
    			this._oEditDialog.bindElement( oItemBindingContextPath );
    			// toggle compact style
    			jQuery.sap.syncStyleClass("sapUiSizeCompact", this.getView(), this._oEditDialog);
    			this._oEditDialog.open();
    		},
    

    As you can see when I create the sap.ui.xmlfragment I'm passing to it three parametes. The first one is the one that you need to specify. It is the view ID. This is is foundamental when in your controller you want to retrieve a fragment element with an ID. If you don't specify the view ID the this.getView().byId() will not work.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 24, 2018 at 02:53 PM

    https://ui5.sap.com/#/topic/5da591c5a5a54740948acfe56b22fbc3

    study that chapter to understand what you are missing......

    Add comment
    10|10000 characters needed characters exceeded