cancel
Showing results for 
Search instead for 
Did you mean: 

Display Image with binary resource

Former Member
0 Kudos

Hello,

I created an image with the java awt libraries in my wd application. So, I got the image in the binary format (not as file!).

Next step would be to display this jpeg on the screen but this don`t works with the "Image"-layout object. This object uses a String-Context-Attribute to reference on an image file, but my Context attribute is binary (byte[]).

What can I do, except to write this image as an file on runtime on the server file system ?

best regards

and thanks in advance

Mathias

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member182372
Active Contributor
0 Kudos

Hi Mathias,

Are you familiar with ?

Nice Valery`s solution posted on Mar 3, 2005, so, it is definitely not 04s.

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Thanks Maksim,

Problem solved on NW 2004 Server!

Solution:

//IN MY wdDoInit()

//modifying the attribute type

ISimpleType pictureType=null;

pictureType = wdContext.nodeRoot().getNodeInfo().getAttribute("myPicture").getModifiableSimpleType();

((IWDModifiableBinaryType)pictureType).setMimeType( WDWebResourceType.JPG_IMAGE);

((IWDModifiableBinaryType)pictureType).setFileName( "picture.jpg" );

-


//IN MY EXECUTE-METHOD

//Modifying my Attribute

final byte[] pictureContent = captchaChallengeAsJpeg;

ISimpleType pictureType=null;

pictureType = wdContext.nodeRoot().getNodeInfo().getAttribute("myPicture").getModifiableSimpleType();

/* And now the trick itself */

final String pictureUrl = pictureType.format(pictureContent);

//Setting the rel. picture path in an other attribute

//...which my Image object references

wdContext.nodeRoot().currentRootElement().setMyPricturePath(pictureUrl);

best regards

Mathias

Former Member
0 Kudos

Hi Mathais,

I implemented this method but the image is still not getting displayd. The url that was generated is as follows.. is there anyway i could check if it contains the image or not,.. or there could be some other error?

context pictureUrl contains:

../../local/imagesapmple/SampleImageAppl/wd_key1B2M2Y8AsgTpgAmY7PhCfg==/image.jpg?sap.session.download=4&sap-wd-cltwndid=3b7237606a5f11db8f5d001279d06755&sap-wd-appwndid=Id3b7237606a5f11db8f5d001279d0675586&sap-wd-norefresh=true

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Debashri,

apply the Web Dynpro Binary Cache service to display a dynamically generated mime resource.

I described the coding in this thread:

Regards, Bertram

Former Member
0 Kudos

Hi Mathias,

after some discussions we found a solution (-;

   String test="Hello!";
    IWDResource
res=WDResourceFactory.createCachedResource(test.getBytes(),"hello",WDWebResourceType.UNKNOWN);
    wdContext.currentContextElement().setReso(res);
    wdContext.currentContextElement().setUrl(res.toString());

This is a simple example for a text, but it also works for images. The context attribute "reso" is of type com.sap.ide.webdynpro.uielementdefinitions.Resource and with res.toString you get the relative URL you can take as source of your image.

See also the JavaDocs:

https://media.sdn.sap.com/javadocs/NW04s/SPS7/wd/com/sap/tc/webdynpro/progmodel/api/WDResourceFactor...

Kind Regards

Stefanie

Former Member
0 Kudos

Hi Stefanie,

as I looked for the com.sap.ide.webdynpro.uielementdefinitions.Resource or IWDResource to set this type to my context attribute, I got no one.

The problem might be, that I use the former NetWeaver '04 Version and not NetWeaver 2004s.

But, what can I do under NW '04 ?

best regards

Former Member
0 Kudos

Yes, this is feature is only available from NW04s on.

Another possibility might be to provide a servlet that produces the image for a certain URL and use that URL in your Image UI element.

Armin