on 01-16-2006 8:04 PM
I'm tryign to use FileDownload UI Element in a table, but it seems not to work.
I have defined a binary, an IWDAttributeInfo and a IWDModifiableBinaryType attributes in the same context node of the table.
In wdDoInit() I wrote the following code:
for (int i=0;i<wdContext.nodeFileTab().size();i++)
{
try {
wdContext.nodeFileTab().getFileTabElementAt(i).setAttInfo(wdContext.nodeFileTab().getNodeInfo().getAttribute(IPrivateView_pdfView.IFileTabElement.T_FILE_DOWNLOAD));
wdContext.nodeFileTab().getFileTabElementAt(i).setBinaryType((IWDModifiableBinaryType)wdContext.nodeFileTab().getFileTabElementAt(i).getAttInfo().getModifiableSimpleType());
wdContext.nodeFileTab().getFileTabElementAt(i).getBinaryType().setFileName(wdContext.nodeFileTab().getFileTabElementAt(i).getFilename());
wdContext.nodeFileTab().getFileTabElementAt(i).getBinaryType().setMimeType(WDWebResourceType.PDF);
wdContext.nodeFileTab().getFileTabElementAt(i).setTFileDownload(this.getByteArrayFromResourcePath("/sapmnt/PCD/global/config/cm/etc/pdf/"+wdContext.nodeFileTab().getFileTabElementAt(i).getFilename()));
}
catch (Exception e)
{
wdComponentAPI.getMessageManager().reportException(e.toString(),true);
}
}
As result each row download the file in the last row. Is there any other way I can try?
Hi Anita,
you cannot set metadata at element level of a node. When you set the metadata ( example mime type or file name ) for a particular element in the node , it changes for all the element. So you are always getting the file for the last row. ( most recent set metadata ).
Try using the inteface IWDCachedWebResource for file download.
For each row add a button, and associate an action "DownloadFile" for it. Use the following "onAction" for the said action.
public void onActionDownloadFile(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionDownloadFile(ServerEvent)
//
int selectedIndex = wdContext.nodeFileTab().getLeadSelection();
IPrivateView_pdfView.IFileTabElement file = wdContext.nodeFileTab().getFileTabElementAt(selectedIndex);
try {
IWDCachedWebResource webResource = WDWebResource.getWebResource(
this.
getByteArrayFromResourcePath("/sapmnt/PCD/global/config/cm/etc/pdf/"+
wdContext.nodeFileTab().getFileTabElementAt().getFilename(selectedIndex),
WDWebResourceType.PDF);
wdComponentAPI.getWindowManager().createExternalWindow(webResource.getURL(),"Download File",true).open();
}
catch(Exception e) {
// take some action
wdComponentAPI.getMessageManager().reportException(e.toString(),true);
}
//@@end
}
Hope you get a solution.
Regards
KK.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.