on 02-04-2019 2:48 PM
Hi All,
I am working on a project and I have a requirement to capture events user performs on SAP UI5 app and playback same events when required.
I have developed a small UI5 app with few text fields, buttons and links. I am using java script DOM events to capture the events. I save element id and type of command(click, input) in my local Json model. When playback is required I use saved data to perform same events again.
I am successfully able to capture and playback text input fields but when i click button or link in playback it clicks the button but do not call function defined in controller on press event of button.
Can someone help me on this.In below my example during playback, button click works but it does not call controller function back.
Example code -
View file has button defined -
var Submit = new sap.m.Button("Submit",{
text: 'Submit', enabled: true,
press: function(oEvt) { oController.OnPressSubmit(oEvt)
} });
Controller has function defined -
OnPressSubmit: function(oEvt){ //Perform action }
Another .js file injected in index file, capture events like below
document.addEventListener("input", myInputFunction);
function myInputFunction(evt) {
if (event.target.localName.length > 0) {
recordingData.push({
"type": event.target.localName,
"command": event.type,
"name": event.target.id, "value": event.target.value }); }
sendData(recordingData); };
In Playback -
function playDataBack(Data) {
for (var i = 0; i < playbackData.length; i++) {
if (playbackData[i].command == 'input')
document.getElementById(playbackData[i].name).value = playbackData[[i]].value;
if (playbackData[i].command == 'click') {
var targBtn = document.querySelector ("#" + playbackData[i].name);
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent ('click', true, true);
targBtn.dispatchEvent (clickEvent);
} }; }
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.