4

I use upload component

source ..

    upload = new Upload(" ",  new Upload.Receiver() {

        @Override
        public OutputStream receiveUpload(String filename, String mimeType) {
            FileOutputStream fos = null ;
                if(filename.length() > 0){
                    try {
                        tempFile = File.createTempFile(filename, ".txt", new File("/home/nap/scroll/") ) ;
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    try {
                        fos = new FileOutputStream(tempFile) ;
                    } catch (FileNotFoundException e) {
                        e.printStackTrace();
                    }
                }else{
                    Notification.show(Messages.getString(Messages.Dialog_No_Selected_File),
                              "-",
                              Notification.Type.WARNING_MESSAGE);
                    portletUI.rePrint(request);
                    initListSelect();
                }
            return fos ;
        }
    });

I want to disable Upload button - not file select button.

When I clicked file select button and did not select file, upload button disabled state.

I tried upload.setButtonCaption(null), However Exeption ... TT

How can I disabled upload button ?

1 Answer 1

2

I don't know how you can disable the submit button but you can first hide it and render it when the user selects a file to upload.

ImageUploader receiver = new ImageUploader();
Upload upload = new Upload("Upload", receiver);
upload.setButtonCaption(null);
upload.addChangeListener(new ChangeListener()
{
    @Override
    public void filenameChanged(ChangeEvent event)
    {
        if (event.getFilename() != null)
            upload.setButtonCaption("Lets go");
    }
});

I hope this helps!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.