cancel
Showing results for 
Search instead for 
Did you mean: 

How i validate fileupload ui means it should not be blank

Former Member
0 Kudos

Hi,

How i validate fileupload ui means i have to put validation that fileupload ui should not be blank.So how i check that one ? please provide code if possible.

Regards,

Gurprit Bhatia

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi

Try putting this code in OnAction()


if (wdContext.currentTestElement().getValue() == null){
		wdComponentAPI.getMessageManager().reportException("Invalid File  ",true);
}

Mandeep Virk

Former Member
0 Kudos

Hi

Create an value attribute say Ctx_va_FilePath of type 'binary' in the context of the view.

Set the filepath property of the fileupload ui element to this value.

On pressing of upload button, simply check if the filepath is null or not

using the code

if (wdContext.currentContextElement().getCtx_va_FilePath() != null)

{

//code

}

If filepath is not null, carry on with the execution and if filepath is null , advise the user to select a file first.

Regards,

Sudeep

Former Member
0 Kudos

Hi,

let assume that Data is context attribute of type binary, and it is bind to a data propety of the fileupload ui element then use the following code

if(wdContext.currentContextElement().getData()==null){

// write ur code here

}

Regards,

Siva Sankar N

0 Kudos

hi,

Check whether file resource is null if it is null then display the message of no file


IPrivateFileUploadView.IContextElement element =
      wdContext.currentContextElement();

    //	if a file in the FileUpload field exists
if (element.getFileResource() != null) 
{
.......
}
else
{
    message of no file
} 

Former Member
0 Kudos

Thanks for quick ans.

i tried that one but it gives null pointer error.

Regards,

Gurprit Bhatia

Former Member
0 Kudos

Hi

Well can you give a print of the exception.

And also check if you have bound the property filename to a context attribute of type string.

Regards,

Sudeep