update an ice:inputRichText field after file is uploaded via a ace:fileUpload

68 views Asked by At

I have a prefilled inputRichText field, say A.

Now I want to provide users the option of uploading a file after which the value of A should be updated with the content of the file. Below are the code for xhtml and the controller's method:

XHTML:

        <td>
            <ice:inputRichText id="agenda" value="#{MyController.event.agenda}" required="true" toolbar="MyToolbar" height="100" saveOnSubmit="true" customConfigPath="resources/script/editor_config.js"/>
        </td>
        <td>
            <ace:fileEntry id="agenda_file" fileEntryListener="#{MyController.agendaAttachmentUploadListener}"
            maxFileCount="1" absolutePath="/quest/ODSLog/temp/"
            maxFileCountMessage="Only one File allowed"
            maxFileSize="2097152"
            immediate="true"
            maxFileSizeMessage="Maximum allowed file size is 2 Mb"/>
            <br/>
            <h:commandButton type="submit" value="Upload" update="agenda"/>
        </td>

MyController.java

public void agendaAttachmentUploadListener(FileEntryEvent event)
    {       
        // read the uploaded file and fetch data in the field theText.
        this.event.setAgenda(theText);      
    }

I am able to read the data from the file in the variable theText above. But in the form, the old value is not updated. If I manually clear the form's field value first and then upload the file, I can see the value in the text field.

How can I display the updated value in the text field after the file upload?

An image:

enter image description here

Here, after file upload, the text should change but it's not changing right now.

0

There are 0 answers