jsfjsf-2icefacesicefaces-2

How to override default file upload h:message in ICEfaces


i am using the ace:fileEntry component to upload files and after successful upload i get the message that:

'File Entry' uploaded successfully 'filename'.

and i want to override this message and display other message (some kind of a summary for parsing that uploaded file), any ideas how ?

here's my code:

<h:form>
        <ace:fileEntry id="fileEntryComp"
               label="File Entry"
               relativePath="uploaded"
               fileEntryListener="#{mybean.uploadFile}"/> 



        <h:commandButton value="Upload Excel File" />
        <h:message for="fileEntryComp" />         

    </h:form>

Solution

  • You have to create your own message and send it. It will overwrite the default message. Its a strange behavior but it will work.

    public void uploadFile(FileEntryEvent e) {
      FileEntry fe = (FileEntry)e.getComponent();
    
      FacesContext ctx = FacesContext.getCurrentInstance();
      FacesMessage msg = new FacesMessage();
      msg.setServity(FacesMessage.SERVITY_INFO);
      msg.setSummary("mysummary");
      msg.setDetail("mydetail");
      ctx.addMessage(fe.getClientId(),msg);
    }
    

    You can check the showcase: http://comp-suite.icefaces.org/comp-suite/showcase.jsf?grp=aceMenu&exp=fileEntry