cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying an image created at runtime.

Former Member
0 Kudos

I am creating an image at run time (a bar code). How do I display this?

To test a static image I placed the bar code image in the src/mimes/components/packages directory, then compiled that application and it worked perfectly.

I then created the bar code image at run time and wrote it to the same src/mimes/components/packages directory as above. The file was succesfully placed there, but the application does not display the image. If the application is then recompiled with a a hard coded value of the previous bar code in the getImageImageSource method it works.

I'm guessing that the run time repository for images is different to the design time one; is this is the case where should I be writing the image file and what should I return from the getImageImageSource method?

Nigel

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello

How we can increase the cache time of the image.

The images are getting disapper after 2 min of time.

regards

John

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo Nigel,

you can apply the Web Dynpro Binary Cache. Just store URL of the cached resource within a context attribute and bind the image url to this attribute.

Implement the following coding:

//@@begin javadoc:wdDoInit() 
  /** Hook method called to initialize controller. */ 
  //@@end 
  public void wdDoInit() 
  { 
    //@@begin wdDoInit() 
    wdContext.currentContextElement().setImgVisibility(WDVisibility.NONE); 

    // Modify datatype, propare datatype for modifications done by the runtime 
    wdContext.getNodeInfo().getAttribute("File").getModifiableSimpleType(); 
    //@@end 
  } 

  //@@begin javadoc:onActionUpload(ServerEvent) 
  /** Declared validating event handler. */ 
  //@@end 
  public void onActionUpload(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent ) 
  { 
    //@@begin onActionUpload(ServerEvent) 
    IWDCachedWebResource cachedResource = null; 
    String imgUrl = null; 

    WDWebResourceType type = 
      ((IWDModifiableBinaryType) wdContext.getNodeInfo().getAttribute("File").getModifiableSimpleType()) 
        .getMimeType(); 
    byte[] file = wdContext.currentContextElement().getFile(); 

    if (file != null) { 
      cachedResource = WDWebResource.getWebResource(file, type); 

      try { 
        imgUrl = cachedResource.getURL(); 
        wdContext.currentContextElement().setUrl(imgUrl); 
        wdContext.currentContextElement().setImgVisibility(WDVisibility.VISIBLE); 
      } catch (WDURLException e) { 
        wdComponentAPI.getMessageManager().reportException(e.getLocalizedMessage(), true); 
      } 
    } 

    //@@end 
  } 

Regards, Bertram