cancel
Showing results for 
Search instead for 
Did you mean: 

Launch mime type - like excel, pdf using LinkToUrl / LinkToAction

Former Member
0 Kudos

Hi,

I have uploaded excel (demo.xlsx) and pdf (dmo.pdf) files in mime and I wish to launch it (show standard popup with buttons open, save and cancel). How do I achieve using

LinkToUrl (what should I put in reference field)

LinkToAction (Needed code to read from mime and launch it)

Thanks

Amit kumar Jain

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You can use a file downlad UI for this purpose.

http://help.sap.com/saphelp_nw04/helpdata/en/c8/32cc6922fb6040a768652aaa0b6879/content.htm

Regards,

Mahesh

Former Member
0 Kudos

Hi Mahesh,

Can we achieve this using link (either using action / url)?

Thanks

Amit

Former Member
0 Kudos

Yes you can ...

Please use the below code in the onAction of link to action/url

	  IWDResource res = WDResourceFactory.createResource(<provide byte array of the file>, "", WDWebResourceType.PDF);
	  res.download(WDFileDownloadBehaviour.AUTO.ordinal());

Edited by: Mahesh K on Dec 14, 2011 8:21 AM

Former Member
0 Kudos

Hi,

I think I am almost there. I have uploaded excel to mime. How do I get reference to mime file and link it to resource.

For example: a file users_excel.xls is uploaded to following folder path.

src->mimes->Applications->com.sap.test.app_name

Thanks

Amit kumar Jain

Former Member
0 Kudos

Provided that you have stored the object under the folder: src/mimes/Components/<component name>.

You can use the below code to get the file path:

WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(), "<name.extension>");

Former Member
0 Kudos

Issue resolved.

Thanks to all and points are awarded.

This is the final code just incase anyneeds.

WDWebResourceType FILE_EXT = WDWebResourceType.XLS;

try

{

String resourcePath = WDURLGenerator.getResourcePath(

wdComponentAPI.getDeployableObjectPart(),"portal_users_upload.xls");

IWDResource resource = WDResourceFactory.createResource(

new FileInputStream(new File(resourcePath)),

"portal_users_upload.xls",

FILE_EXT,

true );

if (resource != null)

{

wdContext.currentFiledownloadElement().setDnl_res(resource);

}

}

catch (WDAliasResolvingException e)

{

wdComponentAPI.getMessageManager().reportException(

e.getLocalizedMessage(), true);

}

catch (FileNotFoundException e)

{

wdComponentAPI.getMessageManager().reportException(

e.getLocalizedMessage(), true);

}

Answers (1)

Answers (1)

Former Member
0 Kudos

if you have the file in resoucre attribute then write the below code in link to action method:

resource.download

Regards,

Ashwin