cancel
Showing results for 
Search instead for 
Did you mean: 

How display Uploaded Image in Current Page

Former Member
0 Kudos

Hi All,

What excatly my requeriment is, I need to Upload Image and display in View.

I wrote Code like this

byte []by=new byte[wdContext.currentContextElement().getResource().read(true).available()];

wdContext.currentContextElement().getResource().read(true).read(by);

wdContext.currentContextElement().setData(by);

Here getResource-- it is value Attibute. it is assined to FileUpload UI Element.

I am getting total Image data to <b>by</b> variable.

My Problem is how to display image with that byte variable(<b>by</b>).

Please give solution to this problem or give any other solutions........

Thanks

SatyaSunil

Accepted Solutions (0)

Answers (3)

Answers (3)

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo Satya,

the following solution is only applicable in NW 04s:

<b>Context Definition</b>

Node:Resource

|_ Attribute: <i>UploadImgResource </i>: Resource

|_ Attribute: <i>UploadImgURL</i> : String

<b>View Layout</b>

FileUpload-resource -> bound to context attribute <i>UploadImgResource</i>

Image-source -> bound to context attribute <i>UploadImgURL</i>

<b>View Controller Coding</b>


//@@begin javadoc:onActionUploadImg(ServerEvent)
/** Declared validating event handler. */
//@@end
public void onActionUploadImg(
  com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, 
  com.sap.tc.wd.tut.fileupdownload.comp.wdp
    .IPrivateTableView.IResourcesElement resourceElement )
{
  //@@begin onActionUploadImg(ServerEvent)
  //  if a file in the FileUpload field exists
  if (resourceElement.getUploadImgResource() != null) {
    // copy URL string from IWDResource object to 
    // context attribute 'UploadImgURL'. Image gets 
    // visible on the UI based on data binding definition.  
    resourceElement.setUploadImgURL(
      resourceElement.getUploadImgResource().getUrl(
        WDFileDownloadBehaviour.OPEN_INPLACE.ordinal()));
  }
  //@@end
}

Best regards, Bertram

Former Member
0 Kudos
abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi,

The Image control requires a file name of the image in source property,

the file should be in your mimes of your project.

You can create a file and place it in the mimes folder and give the name of the

file in the source property

This is not the preferred solution, but you can try it.

Regards

Abhimanyu L