Skip to Content
0

Can we add fragments in place of blocks in Object page layout?

Jan 26, 2017 at 05:47 AM

150

avatar image

Hi all,

I am using blocks in object page layout in one of my ui5 application. Now I want to add fragments dynamically instead of blocks in Object page layout.

I do not find any events for ObjectPageSubSection?

Is it possible to do this?Any help will be appreciated.

objpage.png (18.8 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

VIPLOVE KHUSHALANI Jan 30, 2017 at 12:11 PM
0

Hi Venkatesh ,

Yeah you need to extend ObjectPageSubsection class to add the event , but just think if you can any other control , if not than go ahead and extend

thanks

Viplove

Show 12 Share
10 |10000 characters needed characters left characters exceeded

Hi Viplove,

I have extended the container Object Page Sub Section as below,

Home.view.xml

……………………

…………………….

<ObjectPageSection id="educationSection" title="Education" importance="Low">

<subSections>

<osswe:ObjectPageSubSectionWithEvent title="Sub 1" press="onSub1">

<blocks>

<formblock:PersonalBlock id="idRegBlock1" columnLayout="1"/>

</blocks>

</osswe:ObjectPageSubSectionWithEvent>

<ObjectPageSubSection id="personalSectionSS2" title="Sub 2">

<moreBlocks>

<formblock:PersonalBlock id="idRegBlock2"/>

<formblock:PersonalBlock id="idRegBlock3"/>

</moreBlocks>

</ObjectPageSubSection>

</subSections>

</ObjectPageSection>

…………………..

……………………….

ObjectPageSubSecitonWithEvent.js(extended control)

sap.ui.define(["sap/ui/core/Control"], function(Control) {

"use strict";

return Control.extend("com.testObjectPage.control.ObjectPageSubSecitonWithEvent", {

metadata: {

properties: {},

aggregations: {},

events: {

"press": {}

}

},

init: function() {},

onclick: function(evt) {

this.firePress();

},

renderer: function(oRm, oControl) {

oRm.write('<li');

oRm.writeControlData(oControl);

oRm.write(">");

oRm.write('</li>');

}

});

});

Home.controller.js

jQuery.sap.declare("control.ObjectPageSubSecitonWithEvent");

sap.ui.define([

"sap/ui/core/mvc/Controller"

], function(Controller) {

"use strict";

return Controller.extend("com.testObjectPage.controller.Home", {

onPress:function(){

sap.m.MessageToast.show("sMessage");

}

});

});

Project Structure:

Output:

Error:

Can't find object class 'com.testObjectPage.control.ObjectPageSubSectionWithEvent' for XML-view - XMLTemplateProcessor.js

Please help me where I am getting error.

0

Hi ,

Actually there is mistake in the name of the extended control it should Section:

return Control.extend("com.testObjectPage.control.ObjectPageSubSecitonWithEvent", {

thanks

Viplove

0

Thank you very much Viplove.

It got resolved.

I got another error:

Uncaught error: Cannot add direct child without default aggregation defined for control .... ObjectPageSubSectionWithEvent .

0

Actually there is nothing in aggregation in the extended control , as you are extending the Control Class not the ObjectPageSubSection Class which means you are creating the custom control but you need to extend an existing control with a press event .

check this link for that .

thanks

Viplove

0

Now I have changed from Control class to ObjectPageSubSection class.

But another error related to blocks aggregation.

Failed to load "sap/uxap/block.js" from resources/.....

0

Above error got resolved but event is not getting fired.

0
Show more comments

Hi Viplove,

Below is the final code..

Event is firing but in wrong place.

Actually event has to fired when user selects the drop down like item .i.e. ObjectPageSubSection title as shown below,

But it is being fired when user clicks on the subsection part as shown below.

Complete code:

ObjectPageSubSectionWithEvent.js

sap.ui.define(["sap/ui/core/Control", "sap/uxap/ObjectPageSubSection"], function(Control, ObjectPageSubSection) {

"use strict";

return ObjectPageSubSection.extend("com.testObjectPage.control.ObjectPageSubSectionWithEvent", {

metadata: {

events: {

"press": {}

}

},

onclick: function(evt) {

this.firePress();

},

renderer:{}

});

});

Home.view.xml

<ObjectPageSection id="educationSection" title="Education" importance="Low">

<subSections>

<osswe:ObjectPageSubSectionWithEvent title="Extended Sub 1" press="onSub1">

<osswe:blocks>

<formblock:PersonalBlock id="idRegBlock1" columnLayout="1"/>

</osswe:blocks>

</osswe:ObjectPageSubSectionWithEvent>

<ObjectPageSubSection id="personalSectionSS2" title="Sub 2">

<moreBlocks>

<formblock:PersonalBlock id="idRegBlock2"/>

<formblock:PersonalBlock id="idRegBlock3"/>

</moreBlocks>

</ObjectPageSubSection>

</subSections>

</ObjectPageSection>

Home.controller.js

jQuery.sap.declare("control.ObjectPageSubSectionWithEvent");

sap.ui.define([

"sap/ui/core/mvc/Controller"

], function(Controller) {

"use strict";

return Controller.extend("com.testObjectPage.controller.Home", {

onSub1:function(){

//debugger;

sap.m.MessageToast.show("sMessage");

}

});

});

thanks.

0

Can you try extending objectPageSection and in that it will be select event with a key similar to sap.m.select.

Its better you should try any standard control ..

thanks

Viplove

0
Show more comments

Hi Viplove,

No error is seen in console except 404 as below,

thanks,

error.png (78.1 kB)
0