ICEfaces
  1. ICEfaces
  2. ICE-1601

<ice:inputFile/> does not set the "file" or "fileInfo" attributes via ValueBinding

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6DR#4
    • Fix Version/s: 1.6DR#5, 1.6
    • Component/s: None
    • Labels:
      None
    • Environment:
      Tomcat 5.5.17 / Liferay 4.3.0 (pre-release)

      Description

      The following markup was inspired by the ICEfaces inputFile tutorial, found here: http://facestutorials.icefaces.org/tutorial/inputFile-tutorial.html

      Which shows that you can bind the "file" attribute of the <ice:inputFile/> component to a bean property:

                              <ice:inputFile
                                  id="inputFile1" action="#{MyBean.action}" actionListener="#{MyBean.actionListener}"
                                  binding="#{MyBean.inputFile}" buttonClass="my-inputfile" file="#{MyBean.file}"
                                  label="#{MyMsgs.uploadResume}"
                                  progressListener="#{MyBean.progressListener}" styleClass="my-inputfile"/>

      However, the value binding on the "file" and "fileInfo" attributes are not setup right, because the bean's setFile() method is not called. Although I don't show "fileInfo" attribute in this example, I strongly suspect that a setFileInfo() bean method would not get called either.


      Neil

        Activity

        Hide
        Mark Collette added a comment -

        The file property of the ice:inputFile component is not related to the binding attribute. The file property is for a java.io.File object that represents the most recently uploaded file. Likewise, the fileInfo property contains more information on the status of a currently uploaded/uploading file. They are not meant to be bound to a bean property. Rather, if you use the binding attribute, then the bean with have a reference to the com.icesoft.faces.component.inputFile.InputFile object, and can then call getFile() and getFileInfo() on the InputFile, to query the status of the most recent upload, most likely while in an actionListener, action, or progressListener callback.

        Show
        Mark Collette added a comment - The file property of the ice:inputFile component is not related to the binding attribute. The file property is for a java.io.File object that represents the most recently uploaded file. Likewise, the fileInfo property contains more information on the status of a currently uploaded/uploading file. They are not meant to be bound to a bean property. Rather, if you use the binding attribute, then the bean with have a reference to the com.icesoft.faces.component.inputFile.InputFile object, and can then call getFile() and getFileInfo() on the InputFile, to query the status of the most recent upload, most likely while in an actionListener, action, or progressListener callback.
        Hide
        Neil Griffin added a comment -

        Fix for "file" attribute is attached, see InputFile.upload() method and search for ICE-1601

        Show
        Neil Griffin added a comment - Fix for "file" attribute is attached, see InputFile.upload() method and search for ICE-1601
        Hide
        Neil Griffin added a comment -

        Mark,

        If ICEsoft does not want to support the "fileInfo" attribute, that's OK with me.

        However, the "file" attribute was supported in 1.5.3, and my code in the attachment re-introduces it. I think that's best for backwards compatibility.

        Best Regards,

        Neil

        Show
        Neil Griffin added a comment - Mark, If ICEsoft does not want to support the "fileInfo" attribute, that's OK with me. However, the "file" attribute was supported in 1.5.3, and my code in the attachment re-introduces it. I think that's best for backwards compatibility. Best Regards, Neil
        Hide
        Mark Collette added a comment -

        I looked through the 1.5.3 code, and sure enough, you were right about the file attribute. I only got involved with the InputFile component from 1.6.0 onwards, so I missed that. It seems that the file property of InputFile was/will do double-duty, as a means of holding the current File, and as telling a bean about the most recently saved File.

        Show
        Mark Collette added a comment - I looked through the 1.5.3 code, and sure enough, you were right about the file attribute. I only got involved with the InputFile component from 1.6.0 onwards, so I missed that. It seems that the file property of InputFile was/will do double-duty, as a means of holding the current File, and as telling a bean about the most recently saved File.
        Hide
        Neil Griffin added a comment -

        Mark,

        Oh glad to hear it. One of the beautify things about the "file" attribute is that I can have my <ice:inputFile/> component behave very similarly in a getter/setter bean way with all my other field components. It is a very nice feature, and I would be very appreciative if you would reimplement it. The fix I provided is working well in my local copy.

        Thanks again,

        Neil

        Show
        Neil Griffin added a comment - Mark, Oh glad to hear it. One of the beautify things about the "file" attribute is that I can have my <ice:inputFile/> component behave very similarly in a getter/setter bean way with all my other field components. It is a very nice feature, and I would be very appreciative if you would reimplement it. The fix I provided is working well in my local copy. Thanks again, Neil
        Hide
        Mark Collette added a comment -

        I tweaked the file ValueBinding code a little, and committed it. But we decided not to add the fileInfo attribute, since we'd prefer people to use the actionListener and progressListener interfaces to access the fileInfo.

        Subversion 13947
        icefaces\component\src\com\icesoft\faces\component\inputfile\InputFile.java

        Show
        Mark Collette added a comment - I tweaked the file ValueBinding code a little, and committed it. But we decided not to add the fileInfo attribute, since we'd prefer people to use the actionListener and progressListener interfaces to access the fileInfo. Subversion 13947 icefaces\component\src\com\icesoft\faces\component\inputfile\InputFile.java
        Hide
        Neil Griffin added a comment -

        Mark,

        I did an "svn update" and tested your changes. Unfortunately, this code threw an exception:

        try

        { ValueBinding vb = getValueBinding("file"); if(vb != null) vb.setValue( FacesContext.getCurrentInstance(), getFile() ); }

        The message of the exception was "Context argument was null"

        So when I changed it to this:

        protected void updateFileValueBinding(FacesContext facesContext) {
        try

        { ValueBinding vb = getValueBinding("file"); if(vb != null) vb.setValue( facesContext, getFile() ); }

        ...
        }

        And passed the facesContext from the upload() calling method, the exception went away.

        I have no idea why this would be the case, but it is. I can't explain it!

        Thanks,

        Neil

        Show
        Neil Griffin added a comment - Mark, I did an "svn update" and tested your changes. Unfortunately, this code threw an exception: try { ValueBinding vb = getValueBinding("file"); if(vb != null) vb.setValue( FacesContext.getCurrentInstance(), getFile() ); } The message of the exception was "Context argument was null" So when I changed it to this: protected void updateFileValueBinding(FacesContext facesContext) { try { ValueBinding vb = getValueBinding("file"); if(vb != null) vb.setValue( facesContext, getFile() ); } ... } And passed the facesContext from the upload() calling method, the exception went away. I have no idea why this would be the case, but it is. I can't explain it! Thanks, Neil
        Hide
        Mark Collette added a comment -

        From reading the code, these should be completely equivalent. But, of course I changed it

        Subversion 13965
        icefaces\component\src\com\icesoft\faces\component\inputfile\InputFile.java

        Show
        Mark Collette added a comment - From reading the code, these should be completely equivalent. But, of course I changed it Subversion 13965 icefaces\component\src\com\icesoft\faces\component\inputfile\InputFile.java
        Hide
        Mark Collette added a comment -

        I added some example code of using the file attribute into the component-showcase. This is much after this Jira was fixed though, so this is on the trunk, in time for ICEfaces 1.7 DR3.

        Subversion 15240
        icefaces\samples\component-showcase\src\com\icesoft\icefaces\samples\showcase\components\fileUpload\InputFileBean.java
        icefaces\samples\component-showcase\web\inc\components\inputFile.jspx

        Show
        Mark Collette added a comment - I added some example code of using the file attribute into the component-showcase. This is much after this Jira was fixed though, so this is on the trunk, in time for ICEfaces 1.7 DR3. Subversion 15240 icefaces\samples\component-showcase\src\com\icesoft\icefaces\samples\showcase\components\fileUpload\InputFileBean.java icefaces\samples\component-showcase\web\inc\components\inputFile.jspx

          People

          • Assignee:
            Unassigned
            Reporter:
            Neil Griffin
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: