Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to implement FileDownload UI element in Table cell editor??

Dear All,

I want to use UI element FileDownload as the cell editor for a table column. I have declared a table with two value attribute. One is file name and the other is fileResource as binary type. I have read an article saying that "<b>If you are using UI element FileDownload as the cell editor for a table column, all MIME files displayed in the table using download links have to be saved at runtime." What does this mean?</b>

I have added the following code in wdDoInit, but it does not work when the Download link is clicked. Please help me slove this. Thanks alot.

wdDoInit()
=================================================

if(wdContext.nodeTableTest().getLeadSelection() >= 0)
{
   int i = wdContext.nodeTableTest().getLeadSelection();
   IWDAttributeInfo attInfo =
     wdContext.getNodeInfo().getAttribute(
     IPrivateFileDownloadView.ITableTestElement.DOWNLOAD_RESOURCE);
		
   // create a modifiable binary type for the context    
   //which stores the MIME-object.  IWDModifiableBinaryType binaryType =
(IWDModifiableBinaryType) attInfo.getModifiableSimpleType();
	
// set binary type metadata. Without setting the mime type the client does not know how to open the downloaded file.        
	    binaryType.setFileName(FileDownloadView.FILE_NAME);
	    binaryType.setMimeType(WDWebResourceType.JPG_IMAGE);
	    
	    try {
	      // The image file 'sap.jpg' is deployed with the Web Dynpro project 
	      // (under src/mimes/Components...). The resource path (URL) for this mime 
	      // objects can be accessed using the WDURLGenerator service.
	      String resourcePath =
	        WDURLGenerator.getResourcePath(
	          wdComponentAPI.getDeployableObjectPart(),
	          FileDownloadView.FILE_NAME);
	
	      // retrieve byte array for given resource path and store it 
	      // in context value attribute 'FileDownload'
		  wdContext.nodeTableTest().getTableTestElementAt(i).setDownloadResource(this.getByteArrayFromResourcePath(resourcePath));
	      	
	    } catch (WDAliasResolvingException e) {
	      wdComponentAPI.getMessageManager().reportException(
	        e.getLocalizedMessage(),
	        true);
	    } catch (Exception e) {
	      throw new WDRuntimeException(e);
	    }
	}

If I do not use FileDownload UI Element in a table cell editor and use it as a regular element, everything works fine. After I use cell editor, I do not get any response window ( download or open file window) when the download link is clicked.

Zita

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question