cancel
Showing results for 
Search instead for 
Did you mean: 

Button with an image...

david_fryda2
Participant
0 Kudos

Hi everyone,

I am trying to put on a Button a jpeg.

This is the code :

Button bt1 = new Button("bt1");

bt1.setEncode(false);

bt1.setText("<img src=\"Winter.jpg\">");

The Winter.jpeg is located in the \dist\images folder.

When I run the iView, the image is not found.

Does anyone know how to deal with this.

Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi David,

try this:

bt1.setText("<img src=""+componentRequest.getWebResourcePath() + "/images/Winter.jpg">");

Kind regards

Francisco

Message was edited by: Francisco Villar

Answers (1)

Answers (1)

Former Member
0 Kudos

Just a quick guess, but would


bt1.setText("<img src="images/Winter.jpg">");

work ?

david_fryda2
Participant
0 Kudos

Great, it works.

I have to use the getWebResourcePath.

Thank you!

Former Member
0 Kudos

Ok, glad I could help.

Please consider rewarding some points for the answer

Kind regards

Francisco

Former Member
0 Kudos

Hi,

I have an image placed under my images folder of the portal component. In the code I access the image by setting the SRC attribute of the Image UI to componentRequest.getWebResourcePath()+ "/images/image.jpg". But the image doesn't seem to come up.

When I see the URL of the image that gets generated, it's actually file:///C:/usr/sap/EP62/j2ee/j2ee_10/cluster/server/services/servlet_jsp/work/jspTemp/irj/root/portalapps/<Portal app name>/images/image.jpg.

When it shud have been a HTTP web URL. Any idea how this can be corrected?

Thanks

Shakeel

Former Member
0 Kudos

Hi Shakeel,

do you have a

setEncode(false)

setting in your Button?

Kind regards,

Francisco

Former Member
0 Kudos

Francisco,

I don not have a Button. I was trying the HTMLB Image UI.

There is no Encode attribute for the Image UI.

Anyways, I replaced the HTMLB Image UI with <img src=\irj/portalapps/<PAR Component Name>/images/image.jpg>

This works!

Thanks

Shakeel