$(function () { pageContext.i18n.modTalk = 'moderation talk'; pageContext.i18n.replyToComment = 'Reply'; pageContext.i18n.modTalkEmpty = 'moderation talk is empty'; pageContext.url.getModTalk = "/comments/%25ID%25/listModTalk.json"; pageContext.url.possibleCommentRecipients = "/comments/%ID%/possibleRecipients.json"; pageContext.url.commentEdit = '/comments/%25ID%25/edit.html'; pageContext.url.commentView = '/comments/%ID%/view.html'; pageContext.i18n.commentVisibility = { 'full': 'Viewable by all users', 'op': 'Viewable by the original poster', 'mod': 'Viewable by moderators', 'opAndMod': 'Viewable by moderators and the original poster', 'other': 'Advanced visibility', 'dialogTitle': 'Comment visibility', 'selectGroups': 'Visible to groups', 'selectOther': 'Other recipients', 'selectOriginalPoster': 'Original poster', 'selectModerators': 'Moderators', 'selectAssignees': 'Asked to answer users' }; pageContext.i18n.commentMenuLabels = { 'comment-edit': 'comments.menu.edit', 'comment-delete': 'comments.menu.delete', 'comment-convert': 'comments.menu.convert' };pageContext.i18n.answer= { bestAnswer: 'Best Answer', controlBar : { accept: 'Accept', unaccept: 'Unaccept', acceptCommand: 'Accept this answer as correct', cancelAcceptedCommand: 'Remove this answers accepted status' } }; window.croles = { u: false, op: false, m: false, og: false, as: false, ag: false, dc: false, doc: false, eo: false, ea: false }; tools.init({ q: { e: false, ew: false, eo: false, r: false, ro: false, d: false, dow: false, fv: false, c: false, co: false, p: false, tm: false , ms: false, mos: false }, n: { f: false, vf: false, vfo: false, vr: false, vro: false, c: false, co: false, vu: false, vd: false, w: false, wo: false, l: false }, c: { e: false, eo: false, d: false, dow: false, ta: false, tao: false, l: false }, a: { e: false, ew: false, eo: false, d: false, dow: false, a: false, aoq: false, ao: false, tc: false, tco: false, p: false, tm: false }, pc: croles }, { tc: true, nsc: true }); commandUtils.initializeLabels(); }); Skip to Content

Running a custom method on a controls rendering from a XML view level in SAPUI5

Mar 03, 2017 at 02:28 PM


avatar image

I would like to implement some kind of ACL in a SAPUI5 XML view.

onBeforeRendering="customFunc"     />

Is there a way to launch the "customFunc" on some kind of "render"/"before render" event of the control? The "customFunc" is defined in a base controller (currently parent to the one that initializes the view and therefore - the control (in this case, a Button, but not always)).

The "customFunc" as mentioned above, is gonna have to be called in various controls. So is there a global method/event like the mentioned above "onBeforeRendering"?

Is this the best way of handling some globally available, custom methods (via the base controller)?

10 |10000 characters needed characters left characters exceeded

I'm not sure what you want to do with calling a function on onBeforeRendering method of the control. But if you want to disable or hide this button, this is not right way to do it. You should bind its visible or enable property to an attribute in the model and set the attribute accordingly.

But to answer your question, yes you can manipulate the control properties before it gets loaded/rendered in the view.

Have an id to the control in view(xml), and in the corresponding controller implement onAfterRendering method.

In that method you get get the control by calling this.byId("BUTTON_ID"). Once you have button control, you can do what you want to do on the control, as it's reference to the button object.




Hi Dheeram,

The main problem is that I do not wan't to involve controllers into this, but simply call custom model methods (with attributes) from the XML view. The model has some globally available methods. Let's call the model simply MyModel. Then you call a method simply by going MyModel.MyCustomMethod(id-of-element-to-hide).

Assuming that the method returns a certain value, could I go with something like this?

enabled="MyModel.MyCustomMethod(some-id)"     />

Then use a formatter. In the formatter method you can write your own logic.


what are you talking?

* Please Login or Register to Answer, Follow or Comment.

0 Answers