cancel
Showing results for 
Search instead for 
Did you mean: 

How to dynamically bind immage?

Former Member
0 Kudos

Hi

I have an image UI Element in my main view and i want to dynamically bind a MIME object (type LPEG) to it, is there a way to do that ?

Thanks

Ami

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

there is property in image UI element  SOURCE  bind it with attribute and change this attribute value dynamically.

how to know path of image :-

just simply drag the image from MIME repository onto the source parameter and it will enter the path for you.

if helpful reward points

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Ami,

Add Context Attribute "SOURCE_IMG" with type String.
Add Image UI "img_id" in layout and bind its source with this context attribute.

on any method where you want to change image dynamically, put this code :

here url can be path to image on local or any url-path for web image.

call method wd_context->set_attribute
       EXPORTING
         name = 'SOURCE_IMG'
         value          = url .

I hope this is what you are looking for.

Thank you

Meet Vajaria

amy_king
Active Contributor
0 Kudos

Hi Ami,

Once you know the path to your mime repository objects, you can dynamically assign the image's source property by doing the following...

method onactionchangeimagesource .

   data lo_view      type ref to if_wd_view.

   data lo_image   type ref to cl_wd_image.

* Get a reference to the view, casting to the appropriate interface

   lo_view ?= wd_this->wd_get_api( ).

* Get a reference to the image whose source you want to change

   lo_image ?= lo_view->get_element( 'IMAGE_ID' ).

* Set the image source property

   lo_image->bind_source( path = '/path/to/mime' ).

endmethod.

Check out the information in Handling Web Icons about using a relative path to a MIME object (section Supported URL Formats). An alternate approach would be to bind the image source property to a context attribute and simply change the value of the context attribute to the appropriate MIME path.

Cheers,

Amy

0 Kudos

Hi Amy,

I am using the URL path as below, I am notable to display the MIME Image

Please guide me in doing this.

I Tried both the options, but still not displayed

* ls_logo_url-logo = 'http://servername.domainname/sap/public/logo.bmp'.



ls_logo_url-logo = '/sap/public/logo_320.jpg'.


Kindly help in getting the exact path of the MIME Object.