cancel
Showing results for 
Search instead for 
Did you mean: 

File Upload UI elemet:portal is not responding when entered wrong path

Former Member
0 Kudos

Hello experts,

We are using FileUpload UI elemet ,we are validating the selected file path , the problem is here that user can also enter manually the file path instead of selected through the Browse button.

if he enteres wrong path( enters some thing like "\Messenger\logo.gif" instead of "C:\Program Files\Messenger\logo.gif") and press validate butoon webdynpro is taking lot of time , portal is getting struck, we have to close the browser.

Is there any alternative to control this?Is it possible to stop the file searching process after certain time and show the error message?

any suggestions really appriciated and award by points.

Thanks & Regards,

Veera.

Accepted Solutions (0)

Answers (1)

Answers (1)

pravesh_verma
Active Contributor
0 Kudos

Hi Veera,

I am sure there is some logic problem where you checking for the validity of the entered path. Can you please check that part of code in which you are handling the condition when the path entered by the user is not correct.

I would also request you to kindly post the code which you are using for the validation. Probably then I can tell you the clear picture. However before doing that just check the condition which I have mentioned above.

I hope this solves your problem. Please revert back in case of any further information.

Thanks and Regards

Pravesh

Former Member
0 Kudos

Hi Parvesh,

Thank you for your quick response. I think when i press validate button after entering wrong path (not fully qulified path) , webdydnpro framework is trying to locate the file, as file path is not qualified path, it is not able to locate a file, is it possible to handle this situtation?

Please see the code below.

Context : V_FileUpload -> FileResource type Resource

FileExtension

FileName

IV_FileUploadElement fileUpload = wdContext.currentV_FileUploadElement();

// if a file in the fileUpload exists

if (fileUpload.getFileResource()!= null)

{

IWDResource resource = fileUpload.getFileResource();

fileUpload.setFileName(resource.getResourceName());

fileUpload.setFileExtension( resource.getResourceType().getFileExtension());

}

Validation logic:

IWDResource res = wdContext.currentV_FileUploadElement().getFileResource();

String fileName = wdContext.currentV_FileUploadElement().getFileName();

if (fileName == null) fileName = "";

if (res != null)

{

if (res.read(true).available() == 0){

wdComponentAPI.getMessageManager().reportException(wdComponentAPI.getTextAccessor().getText("InvalidFilePath") + " " + fileName, false);

validSucess = false;

}

}

Thanks & Regards,

Veera.

pravesh_verma
Active Contributor
0 Kudos

Hi Veera,

I think instead of directly checking for the path exist using the IWDResource API try using the File I/O API's. use the following code for checking whetherthe file exist and then do the processing accordinly. I guess this is an issue with the IWDResource for cheking the valid path.

Try this code:



File fileName = new File("D:\\Log\\Sample");
if (!fileName.exists())
{
wdComponentAPI.getMessageManager().reportException(wdComponentAPI.getTextAccessor().getText("InvalidFilePath") + " " + fileName, false);
  
throw new FileNotFoundException("No File found");
   
}

Besides File.exists(), there are also File.isDirectory() and File.isFile(). Please check them as well.

I hope this solves your issue. Please revert back in case you have any further issues else kindly close the thread.

Thanks and Regards,

Pravesh