cancel
Showing results for 
Search instead for 
Did you mean: 

How to set the Image from one controller into a view

Former Member
0 Kudos

Hi,

         I am currently working on the proof of concept, I have used the concept of the navContainer, ie, (sap.ui.commons.Panel) like removing the content and adding the new content to the container. i am currently facing some issues while setting the image into the view through the controller.

inside controller...........

var string=sessionStorage.getItem("GloblalOfflineSign");

      document.getElementById("saveSignature").src = string;

      sap.ui.getCore().byId("signature1").setContent(document.getElementById("saveSignature"));

inside view......

var htmlOutput1 = ' <img id="saveSignature"   style="background-color:white; width:100px; height:50px; border: 1px solid #c4caac;"/>';

  var signature1 = new sap.ui.core.HTML("signature1",{

             content : htmlOutput1,

});

Is there any other method to set the data from controller to the view...? similar to ".setText" or ".setValue". please advice.

regards

Nagarjun

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Maksim,

     Yes i have couple of views and controllers in my Project, I have strucked up with this.  If you can just give me the necessary syntax for setting the image from one controller to another view it would be helpful. and oblige.

regards,

Nagarjun

former_member182372
Active Contributor
0 Kudos

use events to communicate between views

Former Member
0 Kudos

Hi Maksim,

     actually the business logic is in seperate controller(EAM_order_console.controller.js), and the view is in another seperate view that is (EAM_order_view.view.js). the above said way is only valid for the same view and controller. Is there any method to call from another controller to another view, please advice.

regards,

Nagarjun

former_member182372
Active Contributor
0 Kudos

i am confused with your project structure

you have 2 views (EAM_order_console and EAM_order_view) and need to set something from first viws' controller in second view? use event for that, it is probably the easiest way

Former Member
0 Kudos

Hi Maksim,

     Thanks for your reply, well i am using html5 canvas elements,

inside view.............

var htmlOutput1 = ' <img id="saveSignature"   style="background-color:white; width:100px;/>';

  var signature1 = new sap.ui.core.HTML("signature1",{

             content : htmlOutput1,

        preferDOM : false}

});

how to set the image in the controller, so that ill be in a position to get the image in this view. please adivce.

regards,

Nagarjun

former_member182372
Active Contributor
0 Kudos

this.getView().byId("signature1").setContent (htmlOutput1 )

former_member182372
Active Contributor
0 Kudos

you can reference a view from controller by calling getView

https://sapui5.netweaver.ondemand.com/sdk/#docs/api/symbols/sap.ui.core.mvc.Controller.html#getView

//assume saveSignature is id of sap.ui.commons.Image or sap.m.Image

var string=sessionStorage.getItem("GloblalOfflineSign");

this.getView().byId("saveSignature").setSrc(string);