cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with fileupload

Former Member
0 Kudos

Hi Guys,

I am facing one porblem with file upload in my appliction. the porblem is exactly when i am clicking the Upload Button after selecting the file path ,The controle is not at all going to the OnActionUpload() method. Even the first line of the method . It is showing like page not found and some time the page is getting reloaded and controle goes to the WdInit() method.

can any body please help me regarding the same.

Thanks and Regards

Ratnakar reddy

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Reddy,

You have button and you bind the "OnAction" to OnActionUpload() ...Am i right ??

What are you trying to do in OnActionUpload() method ? Please post the code.

Do you have any code in wdDoModifyView() method ? Is so please check you have if(fsirstTime) check or not ?

Regards,Anilkumar

Former Member
0 Kudos

Hi Anil ,

Yes the button UploadFile is bound to onActionUploadFile(). method. There is no code in the wdDoModifyView() method.

public void wdDoInit()

{

IWDAttributeInfo attInfo =

wdContext.getNodeInfo().getAttribute(

IPrivateFileUploadView.IContextElement.FILE_RESOURCE);

attInfo.getModifiableSimpleType();

wdContext.currentContextElement().setDetailsVisibility(WDVisibility.NONE);

IWDMessageManager msgr=wdComponentAPI.getMessageManager();

msgr.reportSuccess("Entered into the init method()");

//@@end

}

....................................................................................

public void onActionUploadFile(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionUploadFile(ServerEvent)

// get attribute info for context attribute "FileUpload"

IWDMessageManager msgMgr1=wdComponentAPI.getMessageManager();

msgMgr1.reportSuccess("entered into the upload file method");

IWDAttributeInfo attInfo =

wdContext.getNodeInfo().getAttribute(

IPrivateFileUploadView.IContextElement.FILE_RESOURCE);

// get modifiable binary type from the attribute info

// requires type cast

IWDModifiableBinaryType binaryType =

(IWDModifiableBinaryType) attInfo.getModifiableSimpleType();

IPrivateFileUploadView.IContextElement element =

wdContext.currentContextElement();

// if a file in the FileUpload field exists

if (element.getFileResource() != null) {

try {

String mimeType = binaryType.getMimeType().toString();

byte[] file = element.getFileResource();

// get the size of the uploaded file

element.setFileSize(this.getFileSize(file));

// get the extension of the uploaded file

element.setFileExtension(binaryType.getMimeType().getFileExtension());

// NOTE: context attribute 'fileName' must not be set, because the

// FileUpload-UI-element property 'fileName' is bound to it. Consequently the

// fileName is automatically written to the context after file upload.

// set the details visibility attribute

element.setDetailsVisibility(WDVisibility.VISIBLE);

// report success message

wdComponentAPI.getMessageManager().reportMessage(

IMessageFileUpDownloadComp.SF_UPLOAD,

new Object[] { binaryType.getFileName()},

false);

} catch (Exception e) {

throw new WDRuntimeException(e);

}

}

// if no file in the FileUpload field exists

else {

// set the details visibility attribute, hide details

element.setDetailsVisibility(WDVisibility.NONE);

// report error message

IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();

msgMgr.reportContextAttributeMessage(

element,

attInfo,

IMessageFileUpDownloadComp.NO_FILE,

new Object[] { "" },

true);

}

// clear the FileUpload context value attribute

element.setFileResource(null);

//@@end

}

Thanks and Regards

Ratnakar