cancel
Showing results for 
Search instead for 
Did you mean: 

How to format sap.m.MessagePopoverItem as HTML?

Former Member

Dear colleagues,

while writing a message plugin for FLP on SAP EP 7.5 SP7 I faced following problem. Im reading some messages as JSON from a custom component to render those within FLP. Since the messages are originally created in a HTML editor, those are formatted, means containing HTML tags. This looks approx like this:

var _showMessages = function(oEvent) {
	
	var oMessageTemplate = new sap.m.MessagePopoverItem({
		type: '{type}',
		title: '{title}',
		description: '{description}',
		counter: '{counter}'
	});


	var oMessagePopover = new sap.m.MessagePopover({
		items: {
			path: '/',
			template: oMessageTemplate
		}
	});
	
	//if messages are avaiable append notification bubble and fill those in corresponding categories
	var sUrl = "/irj/servlet/prt/prtrw/prtroot/xxx.MessagesComponent";
	$.ajax({
		url: sUrl,
		async: false,
		timeout: 10000,
		error: function(){
			$.sap.log.error("Could not load system messages...");
		}.bind(this),
		success: function(data, status, jqXHR){
			if (typeof data !== 'undefined' && data.messages.length > 0) {
				var messages = data;
				$("#messageBtn").prepend("<span id='bubble_MessageBtn' class='notify-bubble' />");
				var jsonMessages = [];
				var counter = 0;
				for (var i=0; i < data.messages.length; i++)
				{
					counter++;
					jsonMessages[i] = {
						type: 'Information',
						title: data.messages[i].title,
						description: data.messages[i].text,
						counter: counter
					};
				}
											
				var oModel = new sap.ui.model.json.JSONModel();
				oModel.setData(jsonMessages);


				var viewModel = new sap.ui.model.json.JSONModel();
				viewModel.setData({messagesLength: jsonMessages.length + ''});


				oMessagePopover.setModel(oModel);
				oMessagePopover.openBy(oEvent);
							}
			else {
				$("#bubble_MessageBtn").remove();						


			}
		}.bind(this)
	});


};


So at the end it works well, but I can see the html tags within description: data.messages[i].text, self evident is: I dont want them, I need clean formatting.

So I checked https://sapui5.hana.ondemand.com/docs/api//symbols/sap.m.MessagePopoverItem.html but didnt found anything for my purposes. Does anybody knows how to overcome this? Thank you very much,

cheers

Accepted Solutions (0)

Answers (0)