0

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.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Pankaj
  • 346
  • 1
  • 3
  • 14
  • 2
    Hi, this is not webservices related and cannot be reproduced with a plain java jdk. Degarding your problem... a plain `h:commandButton` is not ajax enabled and has no `update attribute` – Kukeltje Oct 12 '19 at 12:22
  • Why is this not webservices related? Any thoughts on how can it be done? – Pankaj Oct 13 '19 at 16:34
  • Do a search in your post on webservice (or any related technology like rest, soap, jax-rs, jax-ws, with or without hyhens, spaces etc) and you won't find **anything**. So technically there is nothing in your question that makes it webservice related. Neither is it java(-se) related since you cannot reproduce this in java class with just a main method and no external libraries. Thirdly, the file upload is an icefaces component which you **DON'T** use in the tags – Kukeltje Oct 13 '19 at 16:47
  • Tried to update a plain jsf `h:inputText`? does that work? No? Then your title and question can be improved/simplified. And the 'solution' to your problem is called 'ajax'... Asuming you don't want a full page refresh, since that would be a straight forward solution – Kukeltje Oct 13 '19 at 16:50
  • @Kukeltje thanks, I thought having a front end and making query to the backend is considered as webservices. looks like I have learned something wrong. What were you saying about the ice faces tag? I have marked that tag in the post. – Pankaj Oct 14 '19 at 03:03
  • No, I marked that tag in the question. Just like I edited your title. See the edit history. – Kukeltje Oct 14 '19 at 05:44
  • Oh i dint see that. Thanks. But not much replies. Looks like not much people working on these technologies. – Pankaj Oct 14 '19 at 13:31
  • No idea about IceFaces. PrimeFaces is used a decent amount. But iirc, the ace components have commercial support. But I gave you a very good hint already about trying to use ajax. And that you are wrong in using the 'update' attribute there... https://stackoverflow.com/questions/25339056/understanding-primefaces-process-update-and-jsf-fajax-execute-render-attributes – Kukeltje Oct 14 '19 at 13:44

0 Answers0