cancel
Showing results for 
Search instead for 
Did you mean: 

How to dynamically create file and put it into MIMES of the WDJ project?

Former Member
0 Kudos

Hi, experts,

I have create a jsp file stream in the wdDoModifyView method of the view.

I don't want to use the KM repository for storage the jsp file because the jsp file would be changed often.

But I don't know how to put the jsp file stream to MIMES of the WDJ project as a jsp file.

Do you give me some hint?

Thanks a lot

Best regards,

tao

Edited by: wang tao on Mar 4, 2010 8:24 AM

Accepted Solutions (1)

Accepted Solutions (1)

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi tao

How are you going to consume the JSP file? Should it be a public resource available for HTTP request?

BR, Siarhei

Former Member
0 Kudos

Hi,Siarhei,

First, thanks a lot for your help .

I have create a IFrame in the view, and bind the IFrame attribute "source" on the jsp name so that I can consume the JSP file.

The jsp get data from the WDJ for creating a flash, so I have to put the jsp into the MIMES of the WDJ project.

I can get the MIMES URL and the jsp file stream, but I don't know how to put the jsp file stream to MIMES of the WDJ project as a jsp file.

Do you give me some hint?

Best regards,

tao

Edited by: wang tao on Mar 4, 2010 10:27 AM

siarhei_pisarenka3
Active Contributor
0 Kudos

Use the following API in order to create temporary web-resource. The life-time of the resource is specified by argument scopeType.

public static IWDCachedWebResource WDWebResource.getPublicCachedWebResource(
   java.io.InputStream webResource,
   WDWebResourceType resourceType,
   WDScopeType scopeType,
   WDDeployableObjectPart deployableObjectpart,
   java.lang.String key)

Parameters:

webResource - - the stream/bytearray

resourceType - - the content type of the bytearray

scopeType - - the lifetime scopetype

deployableObjectPart - - the deployableobject, in which directory the cached source is saved

key - - the name/key of the resource

BR, Siarhei

Former Member
0 Kudos

Hi, Siarhei,

Thanks a lot for your help!

According your suggestion, I code the following:

" ....

String strdata = getJSPData(wdContext);

byte[] webResource = strdata.getBytes();

IWDCachedWebResource res = WDWebResource.getPublicCachedWebResource( webResource, WDWebResourceType.JAVA, WDScopeType.CLIENTSESSION_SCOPE, wdThis.wdGetAPI().getComponent().getDeployableObjectPart(),"Column3d.jsp");

if(res!= null){

wdThis.wdGetAPI().getComponent().getMessageManager().reportWarning( res.getURL() );

}else{

wdThis.wdGetAPI().getComponent().getMessageManager().reportWarning("res is null");

}

....

"

After I run the WDJ, I found the url is :

../../../resources/sap.com/WangTaoDC/Components/com.cts.comp.widgetscharts.WidgetsCharts/Column3d.jsp1094794859972986112.java.

So I don't it is right.

I think the following URL is right:

../../../resources/sap.com/WangTaoDC/Components/com.cts.comp.widgetscharts.WidgetsCharts/Column3d.jsp

I don't know how to change my code.

Do you give me some hint?

Best regards,

tao

Edited by: wang tao on Mar 4, 2010 11:35 AM

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi tao

Try also the following method below. Maybe it works differently from the one I posted previously.

WDResourceFactory.createCachedResource(byte[] data, java.lang.String resourceName, WDWebResourceType type)

or

WDResourceFactory.createCachedResource(java.io.InputStream stream, java.lang.String resourceName, WDWebResourceType type, boolean doCopyNow)

BR, Siarhei

Former Member
0 Kudos

Hi, Siarhei,

Thanks a lot for your help!

I have solved the problem with your help.

Thanks again!

Best regards,

tao

Answers (0)